对于最新的Java版本感到沮丧,Spring Context无法加载

时间:2015-03-25 20:35:02

标签: spring java-8 tomcat8 manifest.mf

提前感谢任何阅读此内容并且可以提供帮助的人。

我有一个现有的代码库,我必须更新到Java8,它在AWS EB中运行。所以我试图在Java8 + Tomcat8 ami下运行它。当应用程序启动时,Spring会在init上抛出错误:

  

引起:org.springframework.beans.factory.BeanCreationException:   在ServletContext中定义名为'config'的bean时出错   resource [/WEB-INF/spring/servlet-context.xml]:调用init   方法失败;嵌套异常是java.lang.IllegalArgumentException:   资源路径[META-INF / MANIFEST.MF]无效

Maven Generated Manifest文件如下所示:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: mgriffith-contractor
Build-Jdk: 1.7.0_71
artifactId: quirinus
build-id: 
build-number: 
build-tag: 2.0-${BUILD_NUMBER}
build-time: 2015-03-25_18-40-13
groupId: com.zappos
version: 2.0

使用Tomcat8在Java 7下编译和运行代码时,不会显示此错误。 Google没有合作 - 所以如果您能提供任何见解,那么任何/所有回复都会受到赞赏。

**编辑** 我也尝试将目标设置为1.7。使用Java 8编译,部署到Java8 JVM和Tomcat 8 AMI,整个堆栈如下所示:

25 Mar 2015 22:21:05,473 ERROR: org.springframework.web.servlet.DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'propertyConfigurer' defined in ServletContext resource [/WEB-INF/spring/servlet-context.xml]: Cannot resolve reference to bean 'config' while setting bean property 'location'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'config' defined in ServletContext resource [/WEB-INF/spring/servlet-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: The resource path [META-INF/MANIFEST.MF] is not valid
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:334)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1419)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1160)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:659)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
    at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:602)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:521)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:462)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    at javax.servlet.GenericServlet.init(GenericServlet.java:158)
    at com.zappos.zommons.web.servlet.DelayedInitHttpServletWrapper.doDelayedInit(DelayedInitHttpServletWrapper.java:86)
    at com.zappos.zommons.web.servlet.DelayedInitHttpServletWrapper.delayedInit(DelayedInitHttpServletWrapper.java:79)
    at com.zappos.zommons.web.DelayedInitResourceRegistry.isInitialized(DelayedInitResourceRegistry.java:140)
    at com.zappos.zommons.web.servlet.DelayedInitHttpServletWrapper.isInitialized(DelayedInitHttpServletWrapper.java:38)
    at com.zappos.zommons.web.servlet.DelayedInitHttpServletWrapper.service(DelayedInitHttpServletWrapper.java:101)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.zappos.quirinus.filters.JsonpCallbackFilter.doFilter(JsonpCallbackFilter.java:58)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:673)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'config' defined in ServletContext resource [/WEB-INF/spring/servlet-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: The resource path [META-INF/MANIFEST.MF] is not valid
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    ... 51 more
Caused by: java.lang.IllegalArgumentException: The resource path [META-INF/MANIFEST.MF] is not valid
    at org.apache.catalina.webresources.StandardRoot.validate(StandardRoot.java:250)
    at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:212)
    at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:206)
    at org.apache.catalina.core.ApplicationContext.getResourceAsStream(ApplicationContext.java:559)
    at org.apache.catalina.core.ApplicationContextFacade.getResourceAsStream(ApplicationContextFacade.java:210)
    at com.zappos.zommons.util.VersionUtils.getAttributes(VersionUtils.java:159)
    at com.zappos.zommons.util.VersionUtils.getVersion(VersionUtils.java:122)
    at com.zappos.zommons.spring.ExternalPropertiesResource.getVersion(ExternalPropertiesResource.java:471)
    at com.zappos.zommons.spring.ExternalPropertiesResource.getVersion(ExternalPropertiesResource.java:459)
    at com.zappos.zommons.spring.ExternalPropertiesResource.getVersionedFilename(ExternalPropertiesResource.java:441)
    at com.zappos.zommons.spring.ExternalPropertiesResource.getConfigurations(ExternalPropertiesResource.java:365)
    at com.zappos.zommons.spring.ExternalPropertiesResource.afterPropertiesSet(ExternalPropertiesResource.java:333)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
    ... 58 more

1 个答案:

答案 0 :(得分:1)

事实证明,依赖是试图通过引用Jarfile.MANIFEST来读取Manifest文件 - 显然需要

  

/META-INF/MANIFEST.MF

在Java 8中而不是

  

META-INF / MANIFEST.MF

以前的版本......