我的工作中有一个不寻常的问题,除了一个应用程序外,所有服务器上的应用程序启动都很好。我不得不在这里更改一些类名,而且我无法轻松发布所有启动日志,但我想知道是否有某些东西可以控制启动时组件扫描的顺序。 / p>
在服务器配置方面,机器是使用puppet构建的,代码是自动部署的。我甚至试过从一台服务器到另一台服务器的rsyncing。我还比较了包裹清单。我也在本地运行Postgres数据库。应用程序在自定义滚动java和tomcat运行时内的lxc容器内的ubuntu上运行。
ERROR [2014-12-31 16:18:44,754] org.springframework.web.servlet.DispatcherServlet - [] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'onePetroCartController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.company.internalproductname.p13n.service.spring.UserAuthenticationService com.company.customer.project.web.controllers.OnePetroCartController.userAuthenicationService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.company.internalproductname.p13n.service.spring.UserAuthenticationService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
配置
@Configuration
@ComponentScan(basePackages = {
"com.company.customer.project.web.controllers",
"com.company.customer.project.frontend",
"com.company.customer.project.managers",
"com.company.customer.project.service",
"com.company.customer.project.authorization",
"com.company.customer.project.authentication",
"com.company.internalproductname.frontend.controllers",
"com.company.internalproductname.dao",
"com.company.internalproductname.utils",
"com.company.internalproductname.web.controllers.robots",
"com.company.internalproductname.service",
"com.company.internalproductname.managers",
"com.company.internalproductname.search.metasearch",
"com.company.internalproductname.freemarker"
},
Jar文件。
activation-1.1.jar jasypt-1.4.1.jar scala-library-2.10.4.jar
annotations-1.0.0.jar JavaEWAH-0.7.9.jar company-util-querymap-1.5.jar
antlr-2.7.7.jar javagit-0.2.1.jar sgk-3.4.1.jar
aopalliance-1.0.jar javassist-3.17.1-GA.jar internalproductname-commons-1.5.4.jar
apache-mime4j-core-0.7.2.jar java-xmlbuilder-0.4.jar internalproductname-config-1.5.4.jar
apache-mime4j-dom-0.7.2.jar jaxb-api-2.1.jar internalproductname-counter-release4-1.5.4.jar
asm-3.3.1.jar jaxb-impl-2.1.jar internalproductname-ecommerce-1.5.4.jar
asm-commons-3.1.jar jboss-logging-3.1.0.GA.jar internalproductname-fragr-1.5.4.jar
asm-tree-3.1.jar jboss-transaction-api_1.1_spec-1.0.0.Final.jar internalproductname-frontend-1.5.4.jar
aspectjrt-1.7.3.jar jcl-over-slf4j-1.6.4.jar internalproductname-loader-1.5.4.jar
aspectjweaver-1.7.3.jar jdom-1.0.jar internalproductname-locator-1.5.4.jar
async-http-client-1.7.22.jar jedis-2.4.2.jar internalproductname-p13n-1.5.4.jar
aws-utils-1.5.4.jar jempbox-1.7.1.jar slf4j-api-1.6.4.jar
bcmail-jdk15-1.45.jar jersey-client-1.0.jar snakeyaml-1.6.jar
bcprov-jdk15-1.45.jar jersey-core-1.0.jar solr-appender-1.2.0.jar
bcprov-jdk16-1.46.jar jersey-server-1.0.jar solr-commons-csv-3.5.0.jar
boilerpipe-1.1.0.jar jets3t-0.9.0.jar solr-solrj-4.3.0.jar
braintree-java-2.34.0.jar jettison-1.1.jar spring-aop-3.2.4.RELEASE.jar
c3p0-0.9.1.2.jar jetty-util-8.1.8.v20121106.jar spring-aspects-3.2.4.RELEASE.jar
cglib-2.2.2.jar jing-20091111.jar spring-batch-core-2.2.2.RELEASE.jar
citeproc-data-0.1.jar joda-money-0.9.jar springbatch-exist-1.5.4.jar
citeproc-java-1.0.jar joda-time-2.3.jar spring-batch-infrastructure-2.2.2.RELEASE.jar
commons-beanutils-1.8.3.jar jsch-0.1.50.jar springbatch-solr-1.5.4.jar
commons-codec-1.6.jar jsoup-1.7.2.jar springbatch-utils-1.5.4.jar
commons-compiler-2.6.1.jar jsr305-1.3.9.jar spring-beans-3.2.4.RELEASE.jar
commons-compress-1.4.jar jsr311-api-1.0.jar spring-context-3.2.4.RELEASE.jar
commons-fileupload-1.2.2.jar jul-to-slf4j-1.6.4.jar spring-context-support-3.2.4.RELEASE.jar
commons-io-2.4.jar juniversalchardet-1.0.3.jar spring-core-3.2.4.RELEASE.jar
commons-lang-2.6.jar lesscss-1.3.3.1.resource.jar spring-data-commons-core-1.3.0.RELEASE.jar
commons-lang3-3.1.jar liquibase-core-3.0.2.jar spring-data-jpa-1.1.0.RELEASE.jar
commons-pool2-2.0.jar liquibase-slf4j-logger-1.0.0.jar spring-expression-3.2.4.RELEASE.jar
core-1.1.79.jar loader-1.30.6.jar spring-jdbc-3.0.7.RELEASE.jar
db-config-1.5.4.jar log4j-over-slf4j-1.6.4.jar spring-orm-3.2.4.RELEASE.jar
dom4j-1.6.1.jar logback-classic-1.0.3.jar spring-oxm-3.2.4.RELEASE.jar
domain-1.1.79.jar logback-core-1.0.3.jar spring-retry-1.0.2.RELEASE.jar
ehcache-core-2.5.1.jar logback-gelf-0.9.6p2.jar spring-security-acl-3.1.4.RELEASE.jar
ehcache-spring-annotations-1.2.0.jar mail-1.4.5.jar spring-security-config-3.1.4.RELEASE.jar
email-utils-1.5.4.jar metadata-extractor-2.6.2.jar spring-security-core-3.1.4.RELEASE.jar
exist-2.0-preview.jar metrics-core-2.2.0.jar spring-security-javaconfig-1.0.0.M1.jar
exist-utils-1.5.4.jar metrics-core-3.0.1.jar spring-security-taglibs-3.1.4.RELEASE.jar
fluent-hc-4.3.2.jar metrics-ehcache-2.2.0.jar spring-security-web-3.1.4.RELEASE.jar
fontbox-1.7.1.jar metrics-graphite-2.2.0.jar spring-tx-3.2.4.RELEASE.jar
fragr-api-1.3.1.jar metrics-healthchecks-3.0.1.jar spring-web-3.2.4.RELEASE.jar
freemarker-2.3.19.jar metrics-servlet-2.2.0.jar spring-webmvc-3.2.4.RELEASE.jar
freemarker-utils-1.5.4.jar metrics-web-2.2.0.jar stax2-api-3.1.1.jar
frontend-0.25.jar mime-util-2.1.3.jar stax-api-1.0.1.jar
gag-1.0.1.jar model-1.30.6.jar stax-api-1.0-2.jar
gag-agent-1.0.1.jar neo4j-graph-algo-2.1.2.jar staxmate-2.2.0.jar
geo-ip-0.4.jar neo4j-kernel-2.1.2.jar tagsoup-1.2.1.jar
geronimo-jta_1.1_spec-1.1.1.jar neo4j-primitive-collections-2.1.2.jar tika-core-1.3.jar
geronimo-stax-api_1.0_spec-1.0.1.jar netcdf-4.2-min.jar tika-parsers-1.3.jar
google-http-client-1.8.3-beta.jar netty-3.6.6.Final.jar tika-utils-1.5.4.jar
gson-2.1.jar newrelic-api-2.14.1.jar urlrewritefilter-3.2.0.jar
guava-15.0.jar noggit-0.5.jar utils-1.1.79.jar
hamcrest-core-1.3.RC2.jar openpojo-0.4.4.jar validation-api-1.0.0.GA.jar
hamcrest-integration-1.3.jar org.eclipse.jgit-3.4.1.201406201815-r.jar vorbis-java-core-0.1.jar
hamcrest-library-1.3.RC2.jar org.eclipse.persistence.antlr-2.5.0.jar vorbis-java-core-0.1-tests.jar
hibernate-commons-annotations-4.0.1.Final.jar org.eclipse.persistence.asm-2.5.0.jar vorbis-java-tika-0.1.jar
hibernate-core-4.2.0.Final.jar org.eclipse.persistence.core-2.5.0.jar woodstox-core-asl-4.1.3.jar
hibernate-entitymanager-4.2.0.Final.jar org.eclipse.persistence.moxy-2.5.0.jar ws-commons-util-1.0.2.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar pdfbox-1.7.1.jar xalan-2.7.0.jar
hibernate-validator-4.2.0.Final.jar persistence-1.1.79.jar xercesImpl-2.9.1.jar
HikariCP-java6-2.0.1.jar poi-3.9.jar xml-apis-1.0.b2.jar
httpclient-4.3.2.jar poi-ooxml-3.8.jar xmlbeans-2.3.0.jar
httpcore-4.3.2.jar poi-ooxml-schemas-3.8.jar xmldb-2.0-preview.jar
httpmime-4.3.2.jar poi-scratchpad-3.8.jar xml-resolver-1.2.jar
icu4j-3.4.4.jar postgresql-9.2-1002.jdbc4.jar xmlrpc-client-3.1.3.jar
im4java-1.3.2.jar postgresql-9.3-1102-jdbc4.jar xmlrpc-common-3.1.3.jar
imgscalr-lib-4.2.jar prettytime-1.0.8.Final.jar xmlunit-1.3.jar
isoparser-1.0-RC-1.jar protobuf-java-2.2.0.jar xml-utils-1.5.4.jar
isorelax-20030108.jar reflections-0.9.9-RC1.jar xmpcore-5.1.2.jar
jackson-annotations-2.1.1.jar rhino-1.7R3.jar xom-1.2.5.jar
jackson-core-2.1.1.jar ris-utils-0.7.jar xstream-1.4.2.jar
jackson-core-asl-1.9.7.jar rome-1.0.jar xz-1.0.jar
jackson-databind-2.1.1.jar sams-comms-1.11.jar zookeeper-3.4.5.jar
jackson-mapper-asl-1.9.7.jar sanselan-0.97-incubator.jar
janino-2.6.1.jar saxonhe-9.4.0.4J.jar
完整筹码: -
ERROR [2015-01-02 18:13:31,503] org.springframework.web.servlet.DispatcherServlet - [] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'onePetroCartController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.company.internalproductname.p13n.service.spring.UserAuthenticationService com.company.customer.project.web.controllers.OnePetroCartController.userAuthenicationService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.company.internalproductname.p13n.service.spring.UserAuthenticationService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1116) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) ~[spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) ~[spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:505) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459) ~[spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) [spring-webmvc-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at javax.servlet.GenericServlet.init(GenericServlet.java:160) [servlet-api.jar:3.0.FR]
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1267) [catalina.jar:7.0.34]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1084) [catalina.jar:7.0.34]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027) [catalina.jar:7.0.34]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314) [catalina.jar:7.0.34]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.34]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) [catalina.jar:7.0.34]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) [catalina.jar:7.0.34]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) [catalina.jar:7.0.34]
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657) [catalina.jar:7.0.34]
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1637) [catalina.jar:7.0.34]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_09]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [na:1.7.0_09]
at java.util.concurrent.FutureTask.run(FutureTask.java:166) [na:1.7.0_09]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_09]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_09]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_09]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.company.internalproductname.p13n.service.spring.UserAuthenticationService com.company.customer.project.web.controllers.OnePetroCartController.userAuthenicationService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.company.internalproductname.p13n.service.spring.UserAuthenticationService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:514) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
... 31 common frames omitted
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.company.internalproductname.p13n.service.spring.UserAuthenticationService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:988) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:858) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
... 33 common frames omitted
导致失败的完整调试堆栈: -
https://gist.github.com/gilesw/1d24ba50685bbc2d4401
好的,在所有的诊断和系统工作之后,我把我的Intellij副本拂去,然后回去查看代码。我假设已经对此进行了尽职调查,但似乎没有: -
private UserAuthenticationService userAuthenicationService;
错字。然而,我还没有找到的原因是,这只能在一台服务器上显示,因为相同的代码在其他服务器上。
答案 0 :(得分:0)
根据错误跟踪,
在OnePetroCartController中,您正在对UserAuthenticationService服务进行自动装配
但是,UserAuthenticationService中的问题是拥有bean名称。你没有访问
UserAuthenticationService使用该bean名称。
<强>解决方案强>
解决方案1 :user @Qualifier(beanName),然后您就可以使用其bean名称访问UserAuthenticationService bean。
解决方案2 :使用@Resource注入Bean。