我有庞大的复杂 Spring 项目。当我添加新课程时:
@Service("zoneManagerDelegate")
@Cached(keyGeneratorClass=ServiceGlobalKeyGenerator.class,dataWrapperClass=ServiceDelegateDataWrapper.class, tags = {"service", "sapi"})
public class ZoneManagerDelegate extends SapiDelegate<ZoneManagerWS> {
public ZoneManagerDelegate(){
super(ZoneManagerWS.class);
}
@Cached
public Object[] getZones(SalesUserContext userContext) throws SalesAPIException {
return getWs().getZones(userContext);
}
}
并运行项目,我遇到了错误输出:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'conversionService' defined in ServletContext resource [/WEB-INF/context/common.xml]: Cannot resolve reference to bean 'rtChargeEntryDetailsToBookedInsertionInfo' while setting bean property 'converters' with key [14]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rtChargeEntryDetailsToBookedInsertionInfo': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.ms.adsp.objectFinder.ObjectFinderService com.ms.adsp.bean.payment.converter.RtChargeEntryDetailsToBookedInsertionInfo.objectFinderService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'objectFinderService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.ms.adsp.objectFinder.ObjectFinderService.setObjectFinderExts(java.util.Collection); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'objectFinderExtFactory': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'zoneManagerDelegate' must be of type [com.ms.adsp.delegate.sapi.ZoneManagerDelegate], but was actually of type [$Proxy20]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedSet(BeanDefinitionValueResolver.java:366)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:158)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1132)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:915)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:504)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
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.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
用法如下所示:
@Component
public class ObjectFinderExtFactory {
@Resource(name="zoneManagerDelegate")
private ZoneManagerDelegate zoneManagerDelegate;
...
}
当我在 ZoneManagerDelegate 中删除 @Cached 注释时 - 它工作正常。扩展 SapiDelegate 的所有其他代表 - 也可以正常工作。
附加信息:
public abstract class SapiDelegate<T> implements ApplicationListener<EnvironmentReloaded> {
private static final Logger logger = Logger.getLogger(SapiDelegate.class);
private T wsInstance;
private final Class<T> wsClass;
public SapiDelegate(Class<T> wsClass){
this.wsClass = wsClass;
}
@Override
public synchronized void onApplicationEvent(EnvironmentReloaded appReloaded) {
wsInstance = null;
logger.debug("Sales API client invalidated: " + wsClass.getName());
}
/**
* Returns webservice client object
*/
protected synchronized T getWs() {
try {
if (wsInstance == null) {
wsInstance = ClientFactory.createClient(wsClass, "adsalespro");
logger.debug("Sales API client created: " + wsClass.getName());
}
return (T) wsInstance;
} catch (Exception e) {
throw new SapiException(e);
}
}
}
版本:
Spring 3.2.0
apache-tomcat-6.0.36
有任何想法吗?谢谢。