Setting javax.xml.ws.Service from JDK, instead of javaee-api with maven - maven

I'm facing with this problem:
The method getPort(QName, Class<T>) in the type Service is not applicable for the arguments (QName, Class<AcessoDadosGeolocalizacao>, WebServiceFeature[])
I used wsimport to generate my clients, but now my maven application is using the class javax.xml.ws.Service from
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
<scope>provided</scope>
</dependency>
How can I use the javax.xml.ws.Service from the JDK 6?

I've added the webservices-api to my pom.xml and the problem is gone.
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>2.1-b14</version>
</dependency>

If I am adding this entry(webservices-api) ;it is giving run time error while accessing JAXB-API.I found that the JDK6 should be the first in the order of classpath and then maven library.I moved up the JDK6 above the Maven library.Then it worked.

I ran into a similar issue with Eclipse and a Dynamic Web Application. Its not Maven related however googling for that error gets you all of about 7 results in Google as of today's date with about three or more of them being relisting at other websites of the same stack exchange question - so I thought in case others had a similar issue I'd add what helped me. The WAR was set to use JBoss AS5, the VM was set to use Java 6. Because its eclipse and I had already consumed the web service - the error was not occurring on import as the stubs had already been created. I ensured the Java facet was set to use 1.6 (it had been 1.5), I cleaned and built but the error persisted. I then noticed I had a reference on my build path to Java EE 1.5. I removed this, cleaned and built and the error went away.
Hope this helps anyone else faced with the same issue!

Related

How to solve Maven JSF project : java: package org.primefaces.model.chart does not exist?

this is my first time ever working on JavaEE project. I want to add primefaces so I can use it in a JSF xhtml page. I added the dependency to the Maven file as follows.
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>10.0.0</version>
<scope>compile</scope>
</dependency>
the primefaces got indexed to IntelliJ, and I was able to import it in the java code and on the xhtml page. But when I run WildFly to build and deploy the project I got this error.
jee/bravo/web/beans/ResultsBean.java:6:34
java: package org.primefaces.model.chart does not exist
How to solve this error?
Try removing the line <scope>compile</scope>.
It means it will only be available at compile time, but not at runtime. So everything looks OK in IntelliJ (during compile) but it is still missing on the Application Server like WildFly (during runtime).

Invalid web-app-versionType after Spring Upgrade

To support JUnit 5, I recently upgraded a Spring Boot application to version 2.4.7.
Local development uses an embedded Tomcat server, while all other environments run on a Weblogic server 12.1.3.
Everything runs locally, but using the Weblogic Server results in the following exception:
Caused By: weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
/weblogic.utils.classloaders.GenericClassLoader#700d06bb finder: weblogic.utils.classloaders.CodeGenClassFinder#40ce7cdd annotation: APP#/WEB-INF/lib/tomcat-embed-websocket-9.0.46.jar!/META-INF/web-fragment.xml:18:3:18:3: problem: cvc-enumeration-valid: string value '4.0' is not a valid enumeration value for web-app-versionType in namespace http://xmlns.jcp.org/xml/ns/javaee
at weblogic.descriptor.internal.MarshallerFactory$1.evaluateResults(MarshallerFactory.java:249)
Other questions on the topic led me to check web.xml, but it contains version="3.0".
I don't know how to proceed because I don't understand where this comes from.
Do you have this in your pom.xml to exclude packaging of the tomcat jar files when creating the war file?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
The spring-boot-starter-tomcat dependencies must have provided scope.

Spark-submit is not using the protobuf version of my project

In my work project, I use spark-submit to launch my application into a yarn cluster. I am quite new to Maven projects and pom.xml use, but the problem I seem to be having is that hadoop is using an older version of google protobuf (2.5.0) than the internal dependencies I'm importing at work (2.6.1).
The error is here:
java.lang.NoSuchMethodError:
com/google/protobuf/LazyStringList.getUnmodifiableView()Lcom/google/protobuf/LazyStringList;
(loaded from file:/usr/hdp/2.6.4.0-91/spark2/jars/protobuf-java-2.5.0.jar
by sun.misc.Launcher$AppClassLoader#8b6f2bf7)
called from class protobuf.com.mycompany.group.otherproject.api.JobProto$Query
Since I'm not quite sure how to approach dependency issues like this, and I can't change the code of the internal dependency that uses 2.6.1, I added the required protobuf version as a dependency to my project, as well:
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.6.1</version>
</dependency>
Unfortunately, this hasn't resolved the issue. When the internal dependency (which does import 2.6.1 on its own) tries to use its proto, the conflict occurs.
Any suggestions on how I could force the usage of the newer, correct version would be greatly appreciated.
Ultimately I found the Maven Shade Plugin to be the answer. I shaded my company's version of protobufs, deployed our service as an uber jar, and the conflict was resolved.

java.lang.NoSuchMethodError: com.google.common.collect.Sets$SetView.iterator()Lcom/google/common/collect/UnmodifiableIterator;

I've been trying to connect kafka to elasticsearch using kafka-connect api.Kafka version is 0.11.0.0.These are the steps I followed:
1.Buiding Elasticsearch Connector:
https://github.com/confluentinc/kafka-connect-elasticsearch.git
2.Build the connector
$ cd kafka-connect-elasticsearch
$ mvn clean package
3.Finally running the script:
$ bin/connect-standalone.sh config/connect-standalone.properties config/elasticsearch-connect.properties
It throws the following exception:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.Sets$SetView.iterator()Lcom/google/common/collect/UnmodifiableIterator;
at org.reflections.Reflections.expandSuperTypes(Reflections.java:380)
at org.reflections.Reflections.<init>(Reflections.java:126)
at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.scanPluginPath(DelegatingClassLoader.java:221)
at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.scanUrlsAndAddPlugins(DelegatingClassLoader.java:198)
at org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader.initLoaders(DelegatingClassLoader.java:159)
at org.apache.kafka.connect.runtime.isolation.Plugins.<init>(Plugins.java:47)
at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone.java:68)
Can't understand what's going wrong.
From experience, this error means that you are bringing an older version of guava earlier in your classpath. Connect worker requires guava >= 20 for org.reflections to work correctly.
kafka-connect-elasticsearch or any other connector that brings with it guava 18.0 or older will prohibit the worker from starting up. This error message means that the older guava jar was encountered first in the classpath.
Two solutions:
Indeed, as Hans Jespersen mentions, using classloading isolation by setting your plugin.path in Connect worker's configuration, will allow the connector to work as-is without interfering with the Connect framework.
If adding the connector to the CLASSPATH is your only option, make sure it's added after Kafka Connect's dependencies, so that the most recent guava will be picked up.
This appears to describe the answer for your problem https://github.com/confluentinc/kafka-connect-elasticsearch/issues/104
It's a little confusing, but after you build the connector there are a
number of things in the target directory. The
kafka-connect-elasticsearch-.jar is only the JAR file with
the connector code, but that doesn't include all the libraries. One of
those directories in the target directory, namely
target/kafka-connect-elasticsearch-*-development/share/java/kafka-connect-elasticsearch/,
does contain all the libraries. Add this directory to the Kafka
Connect worker's classpath, or copy all of those JAR files into a
directory that is already on the classpath.
For future readers, I have a similar issue w/ no usage for kafka. I spent a lot of hours to try to figure out the issue, and finally, I have a pattern.
In my project, I used ro.isdc.wro4j:wro4j-extensions:1.8.0, and org.reflections:reflections:0.9.11
<dependency>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-extensions</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>
The conflict happened becuase ro.isdc.wro4j:wro4j-extensions:1.8.0 used com.google.javascript:closure-compiler:jar:v20160315, I solved it by exclude com.google.javascript:closure-compiler:jar:v20160315 from the pom.
<dependency>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-extensions</artifactId>
<version>1.8.0</version>
<exclusions>
<exclusion>
<groupId>com.google.javascript</groupId>
<artifactId>closure-compiler</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>
However, the problem is a build-dependent which we don't know which jar may cause the conflict. In this case, you need to know the location of the jar by running something like the following:
CodeSource source = com.google.common.collect.Sets.class.getProtectionDomain().getCodeSource();
if(source != null)
logger.warn(source.getLocation().toString());
and see what is the output. In my case, the output is
file:/tmp/jetty-0.0.0.0-8087-ROOT.war-_-any-1541284168668078443.dir/webapp/WEB-INF/lib/closure-compiler-v20160315.jar
Hopefully, the answer will help you to find a way to solve the issue,
Mughrabi
I ran into this error recently (Jan 2020) on my localhost (macOS Catalina) and was able to resolve this by updating my .zprofile file (zsh shell). If you have bash shell, you can make changes to .bash_profile or .bashrc file.
• Error was caused because my jvm.classpath was including dependencies of guava verison < 20. My .zprofile file had exports to hadoop-3.1.1 and apache-hive-3.1.1 which was the issue for error.
• I am using kafka_2.12-2.0.0. So, I just commented the hadoop-3.1.1 & apache-hive-3.1.1in my .zprofile and ran my twitter kafka connector successfully.
• I was able to trace this error by following the comments in this thread by #Konstantine Karantasis.
Hope this is helpful.

Maven ERROR: package javax.servlet does not exist [duplicate]

This question already has answers here:
error: package javax.servlet does not exist
(8 answers)
Closed 5 years ago.
I am starting on a legacy project and trying to get it to build using Maven. I'm using Eclipse EE and Tomcat v7.0. The error in the Title line above arises when I run "mvn package" in Terminal. This error is really stumping me because in my pom.xml file I have the following dependency
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
I've also checked in the Properties>Targeted Runtimes and made sure Tomcat v7.0 is the selected runtime. I'm fairly certain it's a problem with my eclipse environment, and would like some suggestions on how to fix it.
EDIT: Here's some additional information. The first output after I run "mvn package" is
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project myProject: Compilation failure: Compilation failure:
This is followed by another strange error that I forgot to include in the original posting. I say it's weird because, like the package javax.servlet, org.apache.catalina should also be included in tomcat
[ERROR] /path/to/Main.java:[7,26] error: package org.apache.catalina does not exist
Also, I think I mixed up the meaning of legacy project, because this isn't an old project. It's just a project that already had a lot of work done on that I'm now helping the original creator with.
The dependency you're missing is probably the Servlet API.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
Be sure to import the correct version of the API. For a legacy project, that could be an older version than 2.5.
As mentionned by Grzegorz, you should also use the scope provided since the Servlet API should be provided by your application server (e.g. Tomcat).
Add server runtime to your project.
Example - for Tomcat
1 - right click on your project
2- select build path
3- Go to Libraries tab
4- Add Library
5- Select Server Run time
6- Here you should get the Apache Tomcat
If you don't get Apache Tomcat in here you need to add your server in Project Facets as below -
1- right click on your project
2- Select Project Facets
3- If you dont get options click on the link 'Convert to faceted form'
4- Go to Runtime tab at right side and select your runtime

Resources