Does jetty 6.1.8 supports jdk 1.5? - java

Hello i install jetty 6.1.8 on windows for development,
I configure it in eclipse to run with jdk 1.5, and my project is configured to build using the same jdk.
my problem is my project can't be runned using jetty server. it complained the below error message. Please note I can start jetty without error when there is no project added. If I configure jetty to use jdk 1.6, then i can add my project and everything works fine. so does it mean that jetty 6.1.8 doesn't support jdk 1.5?
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:366)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337)
at org.mortbay.util.Loader.loadClass(Loader.java:91)
at org.mortbay.util.Loader.loadClass(Loader.java:71)
at org.mortbay.jetty.servlet.Holder.doStart(Holder.java:73)
at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:233)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:612)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:510)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.deployer.ContextDeployer.deploy(ContextDeployer.java:268)
at org.mortbay.jetty.deployer.ContextDeployer.access$000(ContextDeployer.java:67)
at org.mortbay.jetty.deployer.ContextDeployer$ScannerListener.fileAdded(ContextDeployer.java:89)
at org.mortbay.util.Scanner.reportAddition(Scanner.java:417)
at org.mortbay.util.Scanner.reportDifferences(Scanner.java:331)
at org.mortbay.util.Scanner.scan(Scanner.java:286)
at org.mortbay.util.Scanner$1.run(Scanner.java:246)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

Yes it does: http://www.eclipse.org/jetty/about.php (bottom of the page)

According to this page, Jetty 6.1.x supported Java 1.6. I suspect that you have downloaded Jetty JAR files that were compiled using the Java 1.6 compilers. Get the 1.5 JARs and all should be well.
EDIT: I just downloaded the 6.1.8 ZIP file from here, and the JAR files therein were compiled for Java 1.4 or later (code version #48). You must have picked up a dodgy JAR file from somewhere!

Related

Java version in spring boot , docker and EC2

Spring boot version - 2.1.13.BUILD-SNAPSHOT
Java compiler version - Jdk11
AWS EC2 Java version - jdk7
I've started working on a microservice project. So the docker image of my service was compiled in Jdk11. When I try to download and run the container - it doesn't run. Now upon checking logs, I see - java.lang.UnsupportedClassVersionError
I'm using maven to build. Should I change the java version in pom.xml? I could not update the java version in the ec2. Please let me know how I can resolve this collision and go-ahead. I have many services and I'm trying to put it all in EC2.
Docker file: updated to Java 11
FROM openjdk:11.0-jdk-slim
VOLUME /tmp
COPY snapAppKey.jks snapAppKey.jks
COPY /target/SnapAppConfigServer-0.0.1-SNAPSHOT.jar ConfigServer.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","ConfigServer.jar"]
EC2
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/snapapp/config/api/SnapAppConfigServerApplication has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:46)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Migrating your existing code from JDK11 to JDK8 will be more effort that the above simple operations.
change openjdk:8-jdk-alpine to openjdk:11 in your Docker file

Build Java 6 Project with Maven 3.0 and Jenkins 2.1XX : Unsupported major.minor version 51.0

I am new to Jenkins and I am currently setting up some automated builds on a local server we have. Half of the projects are using JDK 8 with Maven 3.3+ and works pretty fine.
However, We have other older projects that we still need to build that requires JDK 6 and Maven 3.0 (it should work with Maven 3.2 too). Using Eclipse IDE, the project compile successfuly but when run by a Jenkins Maven job, it returns this error :
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/jvnet/hudson/maven3/agent/Maven3Main : Unsupported major.minor version 51.0
I checked that Jenkins uses the right JDK and Maven version which are mentionned in the trace :
$ /usr/lib/jvm/java-6-oracle/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.12-alpha-1.jar:/usr/share/maven-3.0.5/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /usr/share/maven-3.0.5 /var/cache/jenkins/war/WEB-INF/lib/remoting-3.17.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.12-alpha-1.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.12-alpha-1.jar 45589
I've read some thread about Jenkins no longer being able to build Java projects with JDK older than 8 (I've only searched about Maven though).
It makes sense looking at the console output, Jenkins looks like he tries to retrieve some of its own files using the job's specified JDK (6), but I don't really get why he needs to do so ? Is it related to Jenkins' Core ?
Upgrading the projects to Java 8 isn't an option, nor downgrading Jenkins.
Is there a workaround in order to build a Java 6 project with Jenkins using Maven ?
I've tried using -Dmaven.compiler.source=1.6 -Dmaven.compiler.target=1.6 in the MAVEN_OPTS but doesn't work either.
There's probably something I missed as I'm new to Jenkins but couldn't find out after some hours. I'm not against a helping hand, thanks.
Here is the end of the console output :
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/jvnet/hudson/maven3/agent/Maven3Main : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.jvnet.hudson.maven3.agent.Maven3Main. Program will exit.
ERROR: Failed to launch Maven. Exit code = 1
Finished: FAILURE

What Version of Maven is Compatible with Java 6?

I have to work in an older project that requires java 6 to run, as there are references to depreciated sun classes that have been removed in future versions. As part of the process, I changed my jdk from 8 in my system path to point to java 6 jdk. After doing so I get:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:254)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launcher.java:144)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:266)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
This is is similar to Maven Installation OSX Error Unsupported major.minor version 51.0 and Exception in thread "main" java.lang.UnsupportedClassVersionError: a (Unsupported major.minor version 51.0) however I'm not looking to upgrade, I'm looking to find a version of maven that is compatible with java 6. Any ideas on which version is compatible and where I can download/install it from for mac?
According to the Maven release history page, the last Maven version that works with JDK1.6 is 3.2.5.
Note that it's better to keep using the newer Maven version (and keep Java 8 as the default in the system path), and tell Maven that the project it's building should compile with source set to 1.6 - see source and target documentation for more info. Reverting to an old Maven will remove the bug fixes / enhancements of the newer versions.
If you have the problem you need to build with JDK 6 but you would like run Maven with JDK 7 (cause you like to use Maven 3.3+) you should consider using toolchain which makes this independent from each other.

Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file in Jenkins

I am using Jenkins ver. 1.565.11.1 (Jenkins Enterprise by CloudBees 14.05) and have JDK 1.5,1.5.0.22,1.6,1.7 all are installed and using different versions for different projects.
My question is I compiled one project with JDK 1.7 by mistake but I have to compile it using jdk 1.5 but not able to do it. Getting below error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:389)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:242)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
at jenkins.maven3.agent.Maven31Main.main(Maven31Main.java:138)
at jenkins.maven3.agent.Maven31Main.main(Maven31Main.java:67)
ERROR: Failed to parse POMs
java.io.EOFException: unexpected stream termination
at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:331)
at hudson.remoting.ChannelBuilder.build(ChannelBuilder.java:280)
at hudson.slaves.Channels.forProcess(Channels.java:114)
at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:280)
at hudson.maven.ProcessCache.get(ProcessCache.java:236)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:755)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1706)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:232)
Finished: FAILURE
Maven 3.2 requires at least jdk 1.6 for execution.
If you want to use maven 3.2 (or newer) and compile code using the 1.5 jdk, you can look at using toolchains.

Play! Framework run throws UnsupportedClassVersionError

Background, this application is running on Play! Framework 1.2.4 on a Mac OS X 10.5.8
The command I'm running: sudo play run
The exception thrown:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:676)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:317)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
at java.lang.Class.getConstructor0(Class.java:2671)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at play.plugins.PluginCollection.loadPlugins(PluginCollection.java:158)
at play.Play.init(Play.java:294)
at play.server.Server.main(Server.java:158)
The application.conf for the application and all dependent modules are set to java.source=1.6
sudo $JAVA_HOME/bin/java -version yields java version "1.6.0_26"
I've even pointed /System/Java/Home to the 1.6 installation.
What else could be causing this?
Which Java version(s) do you have in your PATH? We got a similar issue (not with Play, though) in which all the settings of the application seemed to point to 1.6 but the PATH had a reference to 1.5 that was loaded first due to its position inside the PATH string.
Check your PATH. And, I'm not a Mac user, but it's necessary to use sudo? In Ubuntu I run Play without. If possible, this may help to reduce unexpected conflicts due to root user paths and configuration.

Categories

Resources