We have a maven project to develop a jersey 2.0 REST service, on Eclipse (kepler)
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.9.1</version>
</dependency>
In conjunction with:
java8
tomcat7
When deploying the web application (using $ mvn install && mvn -X tomcat7:redeploy) we get the below exception:
Caused by: java.lang.UnsupportedClassVersionError: org/glassfish/jersey/servlet/init/JerseyServletContainerInitializer : Unsupported major.minor version 51.0 (unable to load class org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2840)
I examined the MANIFEST file in the org.glassfish.jersey.containers jar, and (as suspected) it says build on 1.7 JDK
Tomcat logs confirm that it uses java8 itself
We cannot move back to java8. Is there a way/hack we can get past this error?
From tomcat 7.0.26, I upgraded to next version > Tomcat 7.0.47, to see if that helps.
Things started working magically. Deployed app successfully
Would be glad if someone can explain how the same plugin started to ignore jdk versions, just due to a change in tomcat version.
Related
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.
I'm trying to run a Spring boot app using below versions:
<version>2.0.0.M4</version>
<java.version>1.9</java.version>
<spring.version>5.0.0.RELEASE</spring.version>
My application works as expected but when I add the below dependency (spring-boot-devtools), I'm getting an error when I try to run:
mvn spring-boot:run
Dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
Exception:
Exception in thread "main" java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader
I have tried to run with old version as below and it works fine.
<version>2.0.0.BUILD-SNAPSHOT</version>
<java.version>1.9</java.version>
<spring.version>5.0.0.BUILD-SNAPSHOT</spring.version>
I was wondering if someone can point us if I'm doing something wrong here, or do we have an issue with 2.0.0.M4?
Thanks
Singh
I encountered the same problem when I was using jdk 11 with my spring boot app. You have to use an older version of the jdk like version 8 and if that does not work then you upgrade your spring boot version. The former worked for me.
I think it is a spring boot dev-tool incompatibility with java version 9.
I met this problem using stable version of spring boot.
This is working in Spring Boot <version>2.0.0.M7</version>
with java 9
I faced the same problem. I had resolved it by reducing the version of JDK to 1.8. however, I am using a lower version of springboot but you can upgrade your JDK version in your case.
The error suggests there is an incompatible JDK, this could be due to multiple JDK on your classpath, and when dev-tool is trying to run the application, it ends up picking the wrong JDK.
I am trying to use "swagger-jaxrs-maven" plugin to generate RESTful API docs from the source code.
I followed this web site:
swagger-jaxrs-maven
but maven complained that it can't find this plugin, so I searched it on
maven central repository
It only finds it under groupId com.greensopinion.swagger. So I changed it accordingly.
But now I get this error:
[ERROR] Failed to execute goal
com.greensopinion.swagger:jaxrs-gen:1.3.0:generate (default) on
project treaty: Execution default of goal com.greensopinion.swagg
er:jaxrs-gen:1.3.0:generate failed: Unable to load the mojo 'generate'
in the plugin 'com.greensopinion.swagger:jaxrs-gen:1.3.0' due to an
API incompatibility:
org.codehaus.plexus.component.repository.exception.ComponentLookupException:
com/greensopinion/swagger/jaxrsgen/SwaggerJaxrsGeneratorMojo :
Unsupported major.mi nor version 52.0
I cleaned all my local maven repository and re-tried, it doesn't work.
My maven is 3.2.3 and JDK is 1.7.
My RESTful framework is Jersey2.17 with Jackson.
Any suggestion on how to make it work?
This issue is not related to swagger or maven but to your JDK version (version 52.0 means a JDK 8 is expected).
See https://stackoverflow.com/a/35866015/779338 for mode details.
Furthermore, if you download the pom.xml of swagger-jaxrs-maven available in maven central repository, you can see that a JDK8 (maven.compiler.source=1.8) has been used to generate a java 8 package (maven.compiler.target=1.8), then it can't be used with a JDK7.
I have following Maven dependencies, it turns out fine.
For Swagger, Phillip project which just plug and play.
<dependency>
<groupId>com.github.phillip-kruger</groupId>
<artifactId>apiee-core</artifactId>
<version>1.0.8</version>
</dependency>
JAVA EE - JAX-RS api
<!-- Java EE -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Use JDK 1.8 or above.
I use eclipse and wildly server.
I'm working on a project that incorporates some Jersey dependencies not packaged with Glassfish and need to know what version of Jersey Glassfish 4.1.1 is using.
In the Glassfish Maven pom.xml, here
https://maven.java.net/content/repositories/releases/org/glassfish/main/extras/glassfish-embedded-all/4.1.1/glassfish-embedded-all-4.1.1.pom, there is a reference to Jersey:
<dependency>
<groupId>org.glassfish.main.packager</groupId>
<artifactId>jersey</artifactId>
<version>${project.version}</version>
<type>zip</type>
<optional>true</optional>
</dependency>
Which is actually a reference to the Jersey version embedded in Glassfish, here https://maven.java.net/content/repositories/releases/org/glassfish/main/packager/jersey/4.1.1/jersey-4.1.1.pom.
So from my understanding, Glassfish copies its dependencies at the time they are included into its own repository without retaining version information. How do I get that version information?
As mentioned in Updating Jersey 2 in GlassFish 4, two options mentioned are to:
Just unzip one of the Jersey jars e.g. (jersey-common) and look at the Bundle-Version in the META-INF/MANIFEST.MF file. You can find the jars in <glassfish-home>/glasssfish/modules
Just start up the server, with a JAX-RS application running and
log
Initiating Jersey application, version Jersey: 2.5.1 2014-01-02 13:43:00...]]
I have followed this CXF Proxy Example and it runs successfully as described.
Now I want to deploy the CXF Proxy Example into JBoss-Fuse as OSGI Bundle. I am following this instruction Deploying the Apache Camel Route. But this popping me out with this error:
JBossFuse:admin#root> install -s mvn:org.apache.camel/camel-example-cxf-proxy/2.12.2
Bundle ID: 281
Error executing command: Error installing bundles:
Unable to start bundle mvn:org.apache.camel/camel-example-cxf-proxy/2.12.2:
Unresolved constraint in bundle org.apache.camel.camel-example-cxf-proxy [281]: Unable
to resolve 281.0: missing requirement [281.0] osgi.wiring.package;
(&(osgi.wiring.package=org.apache.camel.spring)(version>=2.12.0)(!(version>=2.13.0)))
JBossFuse:admin#root>
I didn't change anything. Just used their example as it is. They have this on their pom.xml
<parent>
<groupId>org.apache.camel</groupId>
<artifactId>examples</artifactId>
<version>2.12.2</version>
</parent>
I tried this by changing the version into 2.9.0.fuse-70-097 But the error is same(just with a changed version number)
osgi.wiring.package; (&(osgi.wiring.package=org.apache.camel.spring)
(version>=2.9.0)(!(version>=2.10.0)))
I randomly tried with several versions by replacing it in pom.xml and suddenly it worked for me when i hit the following version:
<version>2.10.0</version>
I don't know why it worked for me. But, just found me lucky!