项目增加依赖报错
最近进行图片迁移的改造,在本地window Xp环境下做好代码后,进行提交测试时候,发现应用居然跑步起来,测试环境是生成RPM包,但是不管是什么包不要影响
应用的启动,这个问题困扰啊!!!!!!!!!!!
下面是本人在众多大虾帮助下进行问题排除的一些小节!!!!!!!!!!!!!!!!!!!!!!!!!!!
pom增加依赖报错:
<dependency> <groupId>com.alibaba.platform.shared</groupId> <artifactId>aranda.client</artifactId> <version>1.3.0</version> <exclusions> <exclusion> <groupId>com.alibaba.platform.shared</groupId> <artifactId>aranda.core</artifactId> </exclusion> </exclusions> </dependency>
在总控文件中增加依赖,红色的部分表示aranda.core对spring的依赖不影响本应用的spring依赖。
错误描述:
2011-08-23 20:15:43,414 [] ERROR service.ServiceManager - Service beanfactoryService.quan Failed to initialize com.alibaba.service.ServiceInitializationException: Failed to initialize beanfactory at com.alibaba.service.spring.DefaultbeanfactoryService.init(DefaultbeanfactoryService.java:79) at com.alibaba.service.GenericService.init(GenericService.java:26) at com.alibaba.service.DefaultServiceManager.initService(DefaultServiceManager.java:453) at com.alibaba.service.DefaultServiceManager.getService(DefaultServiceManager.java:813) at com.alibaba.service.DefaultServiceManager.initAll(DefaultServiceManager.java:187) at com.alibaba.webx.WebxLoader.configureAllServices(WebxLoader.java:676) at com.alibaba.webx.WebxLoader.configure(WebxLoader.java:266) at com.alibaba.webx.WebxControllerListener.contextInitialized(WebxControllerListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3763) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503) at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.apache.catalina.core.StandardContext.init(StandardContext.java:5052) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503) at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:297) at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:103) at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:371) at org.jboss.web.WebModule.startModule(WebModule.java:83) at org.jboss.web.WebModule.startService(WebModule.java:61) at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289) at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245) at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:@H_301_22@
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'placeholderConfig' defined in resource loader resource [/bizquan/beans/biz-common.xml]: Initialization of bean Failed; nested exception is java.lang.IllegalArgumentException: Method must not be null at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.doCreateBean(AbstractAutowireCapablebeanfactory.java:480) at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory$1.run(AbstractAutowireCapablebeanfactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.createBean(AbstractAutowireCapablebeanfactory.java:380) at org.springframework.beans.factory.support.Abstractbeanfactory$1.getObject(Abstractbeanfactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.Abstractbeanfactory.doGetBean(Abstractbeanfactory.java:261) at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:185) at org.springframework.beans.factory.support.Abstractbeanfactory.getBean(Abstractbeanfactory.java:164) at org.springframework.context.support.AbstractApplicationContext.invokebeanfactoryPostProcessors(AbstractApplicationContext.java:515) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:362) at com.alibaba.service.spring.DefaultbeanfactoryService.init(DefaultbeanfactoryService.java:75) ... 142 more Caused by: java.lang.IllegalArgumentException: Method must not be null at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:63) at org.springframework.beans.GenericTypeAwarePropertyDescriptor.<init>(GenericTypeAwarePropertyDescriptor.java:58) at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:250) at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:144) at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:252) at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:259) at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.unsatisfiedNonSimpleProperties(AbstractAutowireCapablebeanfactory.java:1109) at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.autowireByName(AbstractAutowireCapablebeanfactory.java:1025) at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.populateBean(AbstractAutowireCapablebeanfactory.java:977)
at org.springframework.beans.factory.support.AbstractAutowireCapablebeanfactory.doCreateBean(AbstractAutowireCapablebeanfactory.java:472) ... 153 more
@H_301_22@排查方案:
@H_301_22@1)我先是在本地把maven.lib下的所有的文件删除,重新拉依赖包,看应用起来没有,如果没有是本地应用问题。
@H_301_22@2)查看本地依赖树结构,
D:\bizcom\qun>mvn dependency:tree -Dexcludes=org.springframework.beans.factory.c
onfig.PropertyPlaceholderConfigurer
mvn dependency:tree >a.txt 发现aranda对spring的依赖是2.5.6,而应用对spring的依赖是2.5.5.,这个需要大家关注的。
发现项目中的依赖众多:
INFO] ------------------------------------------------------------------------ INFO] Building bizquan-deploy INFO] task-segment: [dependency:tree] INFO] ------------------------------------------------------------------------ INFO] [dependency:tree {execution: default-cli}] INFO] com.alibaba.china.app:bizquan.deploy:jar:1.0-SNAPSHOT INFO] \- com.alibaba.china.app:bizquan.bundle.war:ali-war:1.0-SNAPSHOT:runtime INFO] +- com.alibaba.shared:toolkit.webx.filter:jar:2.0:runtime INFO] | +- com.alibaba.external:java.j2ee:jar:1.4:provided (version managed from 0.0.0; scope managed from runtime) INFO] | +- com.alibaba.shared:toolkit.common.logging:jar:1.0:runtime INFO] | | +- com.alibaba.shared:toolkit.common.lang:jar:1.0:runtime INFO] | | \- com.alibaba.external:jakarta.log4j:jar:0.0.0:runtime INFO] | \- com.alibaba.shared:toolkit.webx.framework:jar:2.0:runtime INFO] | +- com.alibaba.shared:toolkit.service.framework:jar:1.0:runtime INFO] | | +- com.alibaba.shared:toolkit.common.collection:jar:1.0:runti e INFO] | | \- com.alibaba.shared:toolkit.common.configuration:jar:1.0:ru time INFO] | | +- com.alibaba.external:jakarta.commons.jelly:jar:0.0.0:ru time INFO] | | \- com.alibaba.external:jakarta.commons.beanutils:jar:0.0. :runtime INFO] | +- com.alibaba.shared:toolkit.service.jsp:jar:1.0:runtime INFO] | +- com.alibaba.shared:toolkit.service.localization:jar:1.0:runti e INFO] | +- com.alibaba.shared:toolkit.service.mimetype:jar:1.0:runtime INFO] | +- com.alibaba.shared:toolkit.service.naming:jar:1.0:runtime INFO] | +- com.alibaba.shared:toolkit.service.pipeline:jar:1.0:runtime INFO] | +- com.alibaba.shared:toolkit.service.pool:jar:1.0:runtime INFO] | +- com.alibaba.shared:toolkit.service.pull:jar:1.0:runtime INFO] | +- com.alibaba.shared:toolkit.service.resource:jar:1.0:runtime INFO] | | \- com.alibaba.shared:toolkit.common.regexp:jar:1.0:runtime INFO] | +- com.alibaba.shared:toolkit.service.rundata:jar:1.0:runtime INFO] | | \- com.alibaba.shared:toolkit.webx.request:jar:2.0:runtime INFO] | | +- com.alibaba.shared:toolkit.common.convert:jar:1.0:runti e INFO] | | \- com.alibaba.external:jakarta.commons.digester:jar:0.0.0 runtime INFO] | +- com.alibaba.shared:toolkit.service.template:jar:1.0:runtime INFO] | +- com.alibaba.shared:toolkit.service.threadcontext:jar:1.0:runt me INFO] | +- com.alibaba.shared:toolkit.service.upload:jar:1.0:runtime INFO] | | \- com.alibaba.external:jakarta.commons.fileupload:jar:0.0.0: untime INFO] | +- com.alibaba.shared:toolkit.service.velocity:jar:1.5:runtime ( ersion managed from 1.0) INFO] | | \- com.alibaba.external:jakarta.velocity:jar:1.6.1:runtime (v rsion managed from 1.5) INFO] | | \- com.alibaba.external:jakarta.commons.collections:jar:0. .0:runtime INFO] | \- com.alibaba.shared:toolkit.service.freemarker:jar:1.0:runtime
3)
一步一步增加依赖,看是什么导致这个问题。
调试发现这个配置文件中的bean出问题,但是无解,到底是什么问题?
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="bizquan/commonConfig.properties"/>
</bean>
4)源码调试,进行中,
学习体会:
1) maven命令查询:
mvn dependency:tree -Dincludes=velocity:velocity
Which outputs:
[INFO] [dependency:tree] [INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT [INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile [INFO] \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile [INFO] \- velocity:velocity:jar:1.4:compile
Specifying multiple patterns
Multiple patterns can be specified when filtering the dependency tree by separating the patterns with commas. For example,to exclude Maven and Plexus dependencies from the tree,we can execute the following:
mvn dependency:tree -Dexcludes=org.apache.maven*,org.codehaus.plexus
Including and excluding dependencies from the tree
Both include and exclude patterns and be specified together to filter the dependency tree. For example,to locate all non-snapshot Plexus dependencies in the tree,153); overflow-x:auto; overflow-y:auto">
mvn dependency:tree -Dincludes=org.codehaus.plexus -Dexcludes=:::*-SNAPSHOT