当前位置: 首页 > 知识库问答 >
问题:

java.lang.UnsupportedClassVersionError-jdk版本

许波涛
2023-03-14

我在Windows7平台上使用JDK1.7.0_03在Eclipse中开发了一个API。当部署在其他Windows7系统上时,它运行良好。

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

有什么问题和我如何使API与所有系统兼容的帮助吗?

共有1个答案

冯阳成
2023-03-14

您正在使用两个不同的JDK来运行程序。Java不是向后兼容的,因此必须在编译的同一版本上运行。

jdk 1.7.0_03

而且

jdk 1.6
 类似资料: