使用mvn exec:java命令启动项目时出现异常
跟踪:
2015-08-11 16:57:58 INFO DatabaseBeansConfig:60 - Creating bean connectionFactory
Exception in thread "main" java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.instantiateUsingFactoryMethod(AbstractAutowireCapablebeanfactory.java:1123)
at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBeanInstance(AbstractAutowireCapablebeanfactory.java:1018)
at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.doCreateBean(AbstractAutowireCapablebeanfactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBean(AbstractAutowireCapablebeanfactory.java:482)
at org.springframework.beans.factory.support.Abstractbeanfactory$1.getObject(Abstractbeanfactory.java:305)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.Abstractbeanfactory.doGetBean(Abstractbeanfactory.java:301)
at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:196)
at org.springframework.beans.factory.support.DefaultListablebeanfactory.preInstantiateSingletons(DefaultListablebeanfactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishbeanfactoryInitialization(AbstractApplicationContext.java:834)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:798)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:530)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:771)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:342)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:735)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.server.Server.start(Server.java:405)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.Server.doStart(Server.java:372)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.phistory.app.jetty.JettyInitializer.startJetty(JettyInitializer.java:41)
at com.phistory.app.Main.main(Main.java:13)
2015-08-11 16:57:58 ERROR ContextLoader:358 - Context initialization Failed
java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.instantiateUsingFactoryMethod(AbstractAutowireCapablebeanfactory.java:1123)
at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBeanInstance(AbstractAutowireCapablebeanfactory.java:1018)
at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.doCreateBean(AbstractAutowireCapablebeanfactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBean(AbstractAutowireCapablebeanfactory.java:482)
at org.springframework.beans.factory.support.Abstractbeanfactory$1.getObject(Abstractbeanfactory.java:305)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.Abstractbeanfactory.doGetBean(Abstractbeanfactory.java:301)
at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:196)
at org.springframework.beans.factory.support.DefaultListablebeanfactory.preInstantiateSingletons(DefaultListablebeanfactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishbeanfactoryInitialization(AbstractApplicationContext.java:834)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:798)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:530)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:771)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:342)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:735)
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:259)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.server.Server.start(Server.java:405)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:106)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
at org.eclipse.jetty.server.Server.doStart(Server.java:372)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at com.phistory.app.jetty.JettyInitializer.startJetty(JettyInitializer.java:41)
at com.phistory.app.Main.main(Main.java:13)
– 我的类路径中的罐子:
mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building XXXXXX 1.0.61
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ XXXXXX -
--
[INFO] XXXXXX:war:1.0.61
[INFO] +- javax:javaee-web-api:jar:7.0:provided
[INFO] +- javax:javaee-web-api:jar:javadoc:7.0:compile
[INFO] +- com.the-carpedia:the-carpedia-data:jar:1.2.11:compile
[INFO] | +- javax.servlet:javax.servlet-api:jar:javadoc:3.1.0:compile
[INFO] | +- org.hibernate:hibernate-entitymanager:jar:4.3.10.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging-annotations:jar:1.2.0.Beta1:compile
[INFO] | | +- org.hibernate:hibernate-core:jar:4.3.10.Final:compile
[INFO] | | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | | \- org.jboss:jandex:jar:1.1.0.Final:compile
[INFO] | | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | | | \- xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] | | +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.5.Final:compile
[INFO] | | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec: jar:1.0.0.Final:compile
[INFO] | | \- org.javassist:javassist:jar:3.18.1-GA:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:javadoc:1.0.0.Final:compile
[INFO] | +- org.hibernate:hibernate-search-orm:jar:5.3.0.Final:compile
[INFO] | | \- org.hibernate:hibernate-search-engine:jar:5.3.0.Final:compile
[INFO] | | +- org.apache.lucene:lucene-core:jar:4.10.4:compile
[INFO] | | +- org.apache.lucene:lucene-analyzers-common:jar:4.10.4:compile
[INFO] | | \- org.apache.lucene:lucene-facet:jar:4.10.4:compile
[INFO] | | \- org.apache.lucene:lucene-queries:jar:4.10.4:compile
[INFO] | +- org.hibernate:hibernate-search-orm:jar:javadoc:5.3.0.Final:compile
[INFO] | +- org.hibernate:hibernate-validator:jar:5.2.1.Final:compile
[INFO] | | +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] | | \- com.fasterxml:classmate:jar:1.1.0:compile
[INFO] | +- org.apache.lucene:lucene-core:jar:javadoc:5.2.1:compile
[INFO] | +- org.springframework:spring-web:jar:4.2.0.RELEASE:compile
[INFO] | | \- org.springframework:spring-aop:jar:4.2.0.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-web:jar:javadoc:4.2.0.RELEASE:compile
[INFO] | +- org.springframework:spring-orm:jar:4.2.0.RELEASE:compile
[INFO] | | +- org.springframework:spring-jdbc:jar:4.2.0.RELEASE:compile
[INFO] | | \- org.springframework:spring-tx:jar:4.2.0.RELEASE:compile
[INFO] | +- org.springframework:spring-orm:jar:javadoc:4.2.0.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:javadoc:4.2.0.RELEASE:compile
[INFO] | +- org.apache.commons:commons-dbcp2:jar:2.1:compile
[INFO] | | +- org.apache.commons:commons-pool2:jar:2.3:compile
[INFO] | | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] | +- org.apache.commons:commons-dbcp2:jar:javadoc:2.1:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.10:compile
[INFO] | +- org.slf4j:slf4j-api:jar:javadoc:1.7.10:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.0:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-annotations:jar:javadoc:2.6.0:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.2.0.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.2.0.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.2.0.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:4.2.0.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:javadoc:4.2.0.RELEASE:compile
[INFO] +- org.springframework:spring-context-support:jar:4.2.0.RELEASE:runtime
[INFO] +- org.springframework:spring-beans:jar:4.2.0.RELEASE:runtime
[INFO] +- org.freemarker:freemarker:jar:2.3.23:compile
[INFO] +- org.freemarker:freemarker:jar:javadoc:2.3.23:compile
[INFO] +- commons-collections:commons-collections:jar:3.2.1:runtime
[INFO] +- MysqL:MysqL-connector-java:jar:5.1.36:runtime
[INFO] +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:provided
[INFO] +- org.eclipse.jetty:jetty-webapp:jar:9.3.2.v20150730:compile
[INFO] | +- org.eclipse.jetty:jetty-xml:jar:9.3.2.v20150730:compile
[INFO] | | \- org.eclipse.jetty:jetty-util:jar:9.3.2.v20150730:compile
[INFO] | \- org.eclipse.jetty:jetty-servlet:jar:9.3.2.v20150730:compile
[INFO] +- org.eclipse.jetty:jetty-webapp:jar:javadoc:9.3.2.v20150730:compile
[INFO] +- org.eclipse.jetty:jetty-servlet:jar:javadoc:9.3.2.v20150730:compile
[INFO] | \- org.eclipse.jetty:jetty-security:jar:9.3.2.v20150730:compile
[INFO] | \- org.eclipse.jetty:jetty-server:jar:9.3.2.v20150730:compile
[INFO] +- org.eclipse.jetty:jetty-server:jar:javadoc:9.3.2.v20150730:compile
[INFO] | +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] | +- org.eclipse.jetty:jetty-http:jar:9.3.2.v20150730:compile
[INFO] | \- org.eclipse.jetty:jetty-io:jar:9.3.2.v20150730:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.12:compile
[INFO] | \- log4j:log4j:jar:1.2.17:compile
[INFO] \- org.slf4j:slf4j-log4j12:jar:javadoc:1.7.12:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.317 s
[INFO] Finished at: 2015-08-11T17:01:19+02:00
[INFO] Final Memory: 17M/222M
[INFO] ------------------------------------------------------------------------
的pom.xml
MysqL.connector.version>5.1.36MysqL.connector.version>
MysqLMysqL-connector-javaMysqL.connector.version}
正如你所看到的,我的classpath中有org.springframework:spring-beans:jar:4.2.0.RELEASE jar.直到最近这个项目一直很好,但我不知道我必须做出哪些改变才能引入这个错误.
我尝试在Jetty和Wildfly 8.2上运行它,输出相同.
问题解决了
我发现我的数据库bean @Configuration有问题,我有一个循环引用,如下所示:
2015-08-15 18:50:07 INFO DatabaseBeansConfig:60 - Creating bean connectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
2015-08-15 18:50:07 INFO DatabaseBeansConfig:74 - Creating bean poolableConnectionFactory
2015-08-15 18:50:07 INFO DatabaseBeansConfig:88 - Creating bean objectPool
这种情况一直发生,直到它抛出NoClassDefFoundError异常.
最佳答案
原文链接:https://www.f2er.com/spring/431778.html