我有一个在本地工作的项目,但是当我尝试将其部署到tomcat 7服务器时,会出现以下异常:
ERROR: [Feb-05 16:39:30,240] web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.webservices.rest.CategoryController] for bean with name 'categoryController' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/webservices/rest/CategoryController.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/webservices/rest/CategoryController : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.webservices.rest.CategoryController)
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.webservices.rest.CategoryController] for bean with name 'categoryController' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/webservices/rest/CategoryController.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/webservices/rest/CategoryController : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.webservices.rest.CategoryController)
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.webservices.rest.CheopsController] for bean with name 'cheopsController' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/webservices/rest/CheopsController.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/webservices/rest/CheopsController : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.webservices.rest.CheopsController)
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.webservices.rest.StatusController] for bean with name 'statusController' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/webservices/rest/StatusController.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/webservices/rest/StatusController : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.webservices.rest.StatusController)
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.webservices.rest.SurveyController] for bean with name 'surveyController' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/webservices/rest/SurveyController.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/webservices/rest/SurveyController : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.webservices.rest.SurveyController)
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.webservices.rest.ThresholdController] for bean with name 'thresholdController' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/webservices/rest/ThresholdController.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/webservices/rest/ThresholdController : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.webservices.rest.ThresholdController)
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.services.impl.CategoryServiceImpl] for bean with name 'categoryServiceImpl' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/services/impl/CategoryServiceImpl.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/services/impl/CategoryServiceImpl : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.services.impl.CategoryServiceImpl)
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.services.impl.CheopsServiceImpl] for bean with name 'cheopsServiceImpl' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/services/impl/CheopsServiceImpl.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/services/impl/CheopsServiceImpl : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.services.impl.CheopsServiceImpl)
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.services.impl.StatusServiceImpl] for bean with name 'statusServiceImpl' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/services/impl/StatusServiceImpl.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/services/impl/StatusServiceImpl : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.services.impl.StatusServiceImpl)
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.services.impl.ThresholdServiceImpl] for bean with name 'thresholdServiceImpl' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/services/impl/ThresholdServiceImpl.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/services/impl/ThresholdServiceImpl : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.services.impl.ThresholdServiceImpl)
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.services.SurveyService] for bean with name 'surveyService' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/services/SurveyService.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/services/SurveyService : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.services.SurveyService)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:525)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1359)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1500)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:252)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.webservices.rest.CategoryController] for bean with name 'categoryController' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/webservices/rest/CategoryController.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/webservices/rest/CategoryController : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.webservices.rest.CategoryController)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1330)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1396)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:385)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:362)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:348)
at org.springframework.context.support.AbstractApplicationContext.getBeanNamesForType(AbstractApplicationContext.java:1051)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:119)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:103)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:126)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
... 45 more
Caused by: java.lang.UnsupportedClassVersionError: se/kth/example-project/webservices/rest/CategoryController : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.webservices.rest.CategoryController)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2737)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1124)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1612)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:247)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:395)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1348)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1319)
... 56 more
Related cause:
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [se.kth.example-project.webservices.rest.CategoryController] for bean with name 'categoryController' defined in file [/proj/webdocs/test-project/root/example-project/WEB-INF/classes/se/kth/example-project/webservices/rest/CategoryController.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: se/kth/example-project/webservices/rest/CategoryController : Unsupported major.minor version 52.0 (unable to load class se.kth.example-project.webservices.rest.CategoryController)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1330)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594)
这是什么原因?我没有编辑任何东西..它在本地工作,但没有部署......
编辑1
添加了完整的堆栈跟踪
编辑2
这不是版本不匹配错误,因为我已将IDE上的tomcat版本更改为6.0(这也是我尝试部署到的服务器上的tomcat版本)。请帮忙..
答案 0 :(得分:2)
这表示类不兼容。您应该确保客户端具有与服务器相同的类版本。如果您在谷歌搜索“不支持的主要次要版本”或“Java不支持的主要次要版本”,您将获得大量的点击(也来自SO)。
另见:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
答案 1 :(得分:2)
您有一些类加载问题。类java.lang.UnsupportedClassVersionError
(也适用于se.kth.webservices.rest.CategoryController
)报告了CheopsController
,这意味着您在容器中有多个版本的类。也许在Tomcat上部署了旧版本?
修改强>
我没有充分阅读这个例外,所以我误导了你。 peter.petrov是对的,这是一个Java版本问题。您的项目是使用Java 8编译的,而您的Tomcat服务器是在以前的某些Java版本上运行的。您应该使用与您计划部署的服务器相同的Java版本编译项目,或者使用以前的版本,因为Java是向后兼容的。