未找到Spring应用程序上下文

时间:2016-05-18 08:02:52

标签: java spring maven vaadin

我在阅读应用程序的应用程序上下文时遇到问题。我正在使用Vaadin进行实验。我的配置类以我之前在其他项目中使用过的方式进行注释并始终有效,注释如下:

@ImportResource("classpath:applicationContext.xml")

这是多么奇怪的是,无论我做什么,甚至用它来明确地找到文件,例如:

@ImportResource("/tmp/classpath:applicationContext.xml")

它仍然不起作用! 我现在正在使用Spring 3(出于历史原因......)

  

2016/05/17 13:39 ContextLoader.initWebApplicationContext:319 - 上下文   初始化失败java.lang.IllegalArgumentException           在org.springframework.asm.ClassReader。(未知来源)           在org.springframework.asm.ClassReader。(未知来源)           在org.springframework.asm.ClassReader。(未知来源)           在org.springframework.core.type.classreading.SimpleMetadataReader。(SimpleMetadataReader.java:52)           在org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)           在org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)           在org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76)           在org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:70)           在org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:253)           在org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)           在org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)           在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)           at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)           在org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)           在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)           at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:782)           at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:424)           at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:774)           at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:249)           at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1242)           在org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)           在org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)           在org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:298)           at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)           在org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)           at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:172)           at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)           在org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229)           at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)           在org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)           在org.eclipse.jetty.server.Server.doStart(Server.java:282)           在org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:65)           at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)           在org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:520)           在org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:365)           在org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:523)           在org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)           在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)           在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)           在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)           在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)           在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)           在org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)           在org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)           在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)           在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)           在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)           在org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)           在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)           在org.apache.maven.cli.MavenCli.main(MavenCli.java:199)           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)           at java.lang.reflect.Method.invoke(Method.java:498)           在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)           在org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)           在org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)           在org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

1 个答案:

答案 0 :(得分:0)

经过大量研究后,我们终于找到了正在发生的事情。非常棘手,但它有道理:

Java 1.8 ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet

基本上,新的ASM不像以前那样读取类,而Spring 3正在使用旧的ASM兼容性读取它们。这导致我只有在更改为Spring 4时才能在Java 8中运行应用程序.Spring确保Spring 4与Java 6之后的任何旧Java版本之间的兼容性:

https://spring.io/blog/2015/04/03/how-spring-achieves-compatibility-with-java-6-7-and-8

oposite不正确,这意味着我无法使用Java 8运行Spring 3,因此我们现在有一个很好的迁移工作:)。