在org.springframework.web.context.ContextLoaderListener中启动带有Spring的Tomcat服务器

时间:2012-05-08 00:27:26

标签: java eclipse spring apache tomcat

我目前正在努力让Tomcat启动并运行。看起来好像Spring出了问题。搜索周围,似乎我的common- *文件或类似的东西有问题。然而,我发现的任何东西似乎都很有希望。

我理解的一些事情是我可能在WEB-INF /文件夹中缺少.jar文件,或者我没有正确的DBCP版本。还有别的东西超出了我。

May 07, 2012 5:48:45 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.VerifyError: Expecting a stackmap frame at branch target 249 in method com.expertwebdev.tribe.auth.AuthServiceImpl.loadUserByUsername(Ljava/lang/String;)Lorg/springframework/security/core/userdetails/UserDetails; at offset 0
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getDeclaredConstructors(Unknown Source)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:227)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:930)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:903)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
    at     org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

May 07, 2012 5:48:45 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
May 07, 2012 5:48:45 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/utero] startup failed due to previous errors
May 07, 2012 5:48:45 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
May 07, 2012 5:48:45 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
May 07, 2012 5:48:45 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
May 07, 2012 5:48:45 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 8901 ms

1 个答案:

答案 0 :(得分:3)

好像你正试图在JRE 7 JVM上运行用java 6(spring framework's)编译的代码。

VerifyError很明显,类Class期望找到JRE getDeclaredConstructors0(Native Method)中不存在的一些本机方法。因此,Spring框架jar调用的实际类Class与JVM中可用的本机方法之间存在矛盾。

另外,请参阅this answer,其中显示了同一类Class方法中的类似问题。这也是那里的问题。

简而言之,检查您的弹簧罐是否与您使用的JRE兼容。