1

I developed an API in Eclipse using jdk 1.7.0_03 on the Windows 7 platform. It works fine when deployed on other Windows 7 systems.

On deploying it on a Windows 8 system using jdk 1.6 it gave the following exception:

HTTP Status 500 - Servlet.init() for servlet MediaPlayer-Backend-API threw exception

type Exception report

message Servlet.init() for servlet MediaPlayer-Backend-API threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet.init() for servlet MediaPlayer-Backend-API threw exception
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:931)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822)
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    java.lang.Thread.run(Thread.java:662)
root cause

java.lang.UnsupportedClassVersionError: favorite/api/VideoManager : Unsupported major.minor version 51.0 (unable to load class favorite.api.VideoManager)
    org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2908)
    org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    java.lang.Class.forName0(Native Method)
    java.lang.Class.forName(Class.java:247)
    com.sun.jersey.core.reflection.ReflectionHelper$3.run(ReflectionHelper.java:284)
    com.sun.jersey.core.reflection.ReflectionHelper$3.run(ReflectionHelper.java:279)
    java.security.AccessController.doPrivileged(Native Method)
    com.sun.jersey.spi.scanning.AnnotationScannerListener$AnnotatedClassVisitor.getClassForName(AnnotationScannerListener.java:224)
    com.sun.jersey.spi.scanning.AnnotationScannerListener$AnnotatedClassVisitor.visitEnd(AnnotationScannerListener.java:188)
    org.objectweb.asm.ClassReader.accept(Unknown Source)
    org.objectweb.asm.ClassReader.accept(Unknown Source)
    com.sun.jersey.spi.scanning.AnnotationScannerListener.onProcess(AnnotationScannerListener.java:138)
    com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner$1.f(FileSchemeScanner.java:86)
    com.sun.jersey.core.util.Closing.f(Closing.java:71)
    com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner.scanDirectory(FileSchemeScanner.java:83)
    com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner.scan(FileSchemeScanner.java:71)
    com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:226)
    com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:142)
    com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:80)
    com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)
    com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:78)
    com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:89)
    com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:696)
    com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:674)
    com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:205)
    com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:376)
    com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:559)
    javax.servlet.GenericServlet.init(GenericServlet.java:160)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:931)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822)
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    java.lang.Thread.run(Thread.java:662)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.33 logs.

Apache Tomcat/7.0.33

I referred to this answer and changed the Installed JRE and Compiler compliance level of the API Eclipse project to jdk 1.5.0_15.

Yet on deploying the API I got the same error.

Any help on whats going wrong and how I make the API compatible with all systems?

Community
  • 1
  • 1
Abhishek
  • 125
  • 2
  • 17
  • code that is compiled for 1.7 will not work for 1.6, so either compile or find a 1.6 version of `favorite.api.VideoManager` – Scary Wombat Apr 15 '14 at 06:50
  • Fact that class version is 51.0 indicates the class files are still in 1.7 , you have messed up your settings somewhere or copied a wrong jar file to your Windows 8 machine. Check the timestamps for clarity. – Puru-- Apr 15 '14 at 07:11

3 Answers3

0

You are using two different JDK's to run the program. Java is not backward compatible and so you must run on the same version you compiled with.

jdk 1.7.0_03

and

jdk 1.6
Bakstar
  • 76
  • 4
0

If you were able to compile the API in JDK 1.5 then the UnsupportedClassVersionError error couldn't have come up.

Make sure the compiler version settings is correct in Eclipse and also clean up the directory where .class files are generated. Make some trivial changes in some or all the java files using eclipse editor and generate the new class files and check the timestamp of the generated class files / jar before deploying.

RRM
  • 2,495
  • 29
  • 46
0

Change eclipse java version as jdk 1.7 and compile it. or check VideoManager.class has build by which version ? Get that version and build your project using that version.