2

春の 3.o では、次を使用して、DAO レイヤー オブジェクトを singleTon Bean に注入しようとしています。

ApplicationContext applicaionContext = new ClassPathXmlApplicationContext(ApplicationConstants.APP_PROPERTY_CONFIG_PATH);

        TemplateManagementDAO  templateManagementDAO =(TemplateManagementDAO) applicaionContext.getBean("templateManagementDAO");

しかし、それは例外を与えます:

java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:983)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:879)
    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:4655)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5364)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:345)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:986)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:970)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:704)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1649)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1254)
    at com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed(WebModuleDeployEventListener.java:182)
    at com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed(WebModuleDeployEventListener.java:278)
    at com.sun.enterprise.admin.event.AdminEventMulticaster.invokeModuleDeployEventListener(AdminEventMulticaster.java:1005)
    at com.sun.enterprise.admin.event.AdminEventMulticaster.handleModuleDeployEvent(AdminEventMulticaster.java:992)
    at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:470)
    at com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:182)
    at com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastEvent(DeploymentNotificationHelper.java:308)
    at com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent(DeploymentServiceUtils.java:231)
    at com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStartEvent(ServerDeploymentTarget.java:298)
    at com.sun.enterprise.deployment.phasing.ApplicationStartPhase.runPhase(ApplicationStartPhase.java:132)
    at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
    at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:966)
    at com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeploymentService.java:609)
    at com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeploymentService.java:653)
    at com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.start(ApplicationsConfigMBean.java:773)
    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 com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:390)
    at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:373)
    at com.sun.enterprise.admin.config.BaseConfigMBean.invoke(BaseConfigMBean.java:477)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
    at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:90)
    at $Proxy1.invoke(Unknown Source)
    at com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInterceptor.java:304)
    at com.sun.enterprise.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:170)
    at com.sun.enterprise.admin.jmx.remote.server.callers.InvokeCaller.call(InvokeCaller.java:69)
    at com.sun.enterprise.admin.jmx.remote.server.MBeanServerRequestHandler.handle(MBeanServerRequestHandler.java:155)
    at com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.processRequest(RemoteJmxConnectorServlet.java:122)
    at com.sun.enterprise.admin.jmx.remote.server.servlet.RemoteJmxConnectorServlet.doPost(RemoteJmxConnectorServlet.java:193)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1093)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1093)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:291)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:666)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:597)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:872)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:264)
    at com.sun.enterprise.web.connector.grizzly.WorkerThreadImpl.run(WorkerThreadImpl.java:117)

ビーンレイヤーにDAOオブジェクトにアクセスできないのはなぜですか?? ありがとう、グンジャン・シャー。

4

5 に答える 5

3

あなたのapplication-context.xml定義では:

<bean id="templateManagementDAO" class="yourPackage.TemplateManagementDAO" />

TemplateManagementDAOインターフェイスではなく実装クラスであることに注意してください。

于 2012-04-26T13:05:06.957 に答える
1

最初にこの例外を修正する必要があります

java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException

これは、Spring 構成エラーとは関係ありません。クラスパスに古いバージョンの Spring がありますか?

于 2012-04-26T13:12:56.840 に答える
0

Spring Context 構成ファイルで、アノテーション () に基づいて Bean を検出するためにパッケージ スキャンを有効にした場合、DAO クラスに @Repository でアノテーションを付けることができます。

于 2012-04-26T13:17:32.333 に答える
0

私にも同じ例外がありました。それは多くの情報を提供しません。多くのデバッグを行った結果、Bean をインスタンス化するときにスタック オーバーフロー例外が発生することがわかりました。これは、@Bean でアノテーションが付けられた 2 つのファクトリ メソッド間の無限の再帰呼び出しによって与えられました。

これは死ぬ前のスタック トレースです。おそらく同じことが起こっていて、@Lazy アノテーションがこれを回避するのに役立ちました...

"main" prio=10 tid=0x09151000 nid=0x4c10 runnable [0xf733b000]
   java.lang.Thread.State: RUNNABLE
        at com.cme.datamine.elephant.config.ElephantConfig.fileRouters(ElephantConfig.java:276)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7.CGLIB$fileRouters$14(<generated>)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7$$FastClassByCGLIB$$1e5bbc2f.invoke(<generated>)
        at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
        at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:280)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7.fileRouters(<generated>)
        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.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:149)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:570)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1015)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        - locked <0xe04f0fb8> (a java.util.concurrent.ConcurrentHashMap)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:292)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7.fileRouters(<generated>)
        at com.cme.datamine.elephant.config.ElephantConfig.faultToleranceArbiter(ElephantConfig.java:302)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7.CGLIB$faultToleranceArbiter$15(<generated>)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7$$FastClassByCGLIB$$1e5bbc2f.invoke(<generated>)
        at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
        at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:280)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7.faultToleranceArbiter(<generated>)
        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.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:149)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:570)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1015)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        - locked <0xe04f0fb8> (a java.util.concurrent.ConcurrentHashMap)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:292)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7.faultToleranceArbiter(<generated>)
        at com.cme.datamine.elephant.config.ElephantConfig.fileRouters(ElephantConfig.java:292)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7.CGLIB$fileRouters$14(<generated>)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7$$FastClassByCGLIB$$1e5bbc2f.invoke(<generated>)
        at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
        at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:280)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7.fileRouters(<generated>)
        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.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:149)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:570)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1015)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        - locked <0xe04f0fb8> (a java.util.concurrent.ConcurrentHashMap)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:292)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7.fileRouters(<generated>)
        at com.cme.datamine.elephant.config.ElephantConfig.writersRunners(ElephantConfig.java:256)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7.CGLIB$writersRunners$13(<generated>)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7$$FastClassByCGLIB$$1e5bbc2f.invoke(<generated>)
        at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
        at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:280)
        at com.cme.datamine.elephant.config.ElephantConfig$$EnhancerByCGLIB$$b38541f7.writersRunners(<generated>)
        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.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:149)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:570)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1015)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
        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:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        - locked <0xe04f0fb8> (a java.util.concurrent.ConcurrentHashMap)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        - locked <0xe04f0fb8> (a java.util.concurrent.ConcurrentHashMap)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
        - locked <0xe04f0fb8> (a java.util.concurrent.ConcurrentHashMap)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
        - locked <0xe04f1df0> (a java.util.concurrent.ConcurrentHashMap)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
        - locked <0xe04f1eb0> (a java.lang.Object)
        at com.cme.datamine.elephant.launch.Launcher.createSpringContext(Launcher.java:109)
        at com.cme.datamine.elephant.launch.Launcher.main(Launcher.java:55)
于 2013-02-15T14:16:51.853 に答える
0

この問題は、アプリケーションの初期化クラスがコンテナーによって読み込まれる前に DAO にアクセスしようとしたために発生しました。

したがって、 lazy-init = true オプションを使用した後は正常に動作します。

  <!-- LAZY LOAD THIS BEAN TO RESOLVE DAO INJECTION PROBLEM INTO THE BEAN -->
    <bean id="selStartUpDataInitializer" class="com.eks.sel.service.SELStartUpDataInitializer"
        factory-method="getInstance" lazy-init="true">
    </bean>

ご参考までに、例外が生成された場所からDAOを使用したクラスを次に示します。

public class SELStartUpDataInitializer  implements Cloneable{

    private static SELStartUpDataInitializer selStartUpDataInitializer;
    private static final Logger LOGGER =Logger.getLogger(SELStartUpDataInitializer.class);
    private static Map<String,Object> staticContextMap = new HashMap<String, Object>(); 


    //PRIVATE CONSTRUCTOR : FOR SINGLE TON
    private SELStartUpDataInitializer(){                
        initializeTempalteDataFieldMap();
    }

    //OVERRIDE CLONNABLE METHOD
    @Override
    protected Object clone() throws CloneNotSupportedException {
        if(selStartUpDataInitializer==null){
            selStartUpDataInitializer = new SELStartUpDataInitializer();
        }
        return selStartUpDataInitializer;
    }


    //GET INSTANCE : USED BY BEAN TO INITIALIZE THE BEAN 
    public static synchronized SELStartUpDataInitializer getInstance(){
        if(selStartUpDataInitializer==null){
            selStartUpDataInitializer = new SELStartUpDataInitializer();
        }
        return selStartUpDataInitializer;
    }   



    //INITIALIZE TEMPALTE DATA FILEDs : CALLED BY ONE TIME CONSTRUCTOR
    public  void initializeTempalteDataFieldMap(){      
        LOGGER.info("SELStartUPDataInitializer ... Initializing all temaplte data mapping fields ....");
        Map<Integer, Map<String,String>> templateDatafieldMap = new HashMap<Integer, Map<String,String>>();
        LOGGER.info("Loading application contex from the class path : STARTED");
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext(ApplicationConstants.APP_RELOAD_PROPERTY_CONFIG_PATH);
        LOGGER.info("Loading application contex from the class path : COMPLETED");
        //ITS MANDATORY TO CAST BY INTERFACE. OTHERWISE $PROXY ERROR WILL BE GENERATED
        ITemplateManagementDAO  templateManagementDAO =(ITemplateManagementDAO) applicationContext.getBean("templateManagementDAO");                

        List<Template> templates = templateManagementDAO.findByStatus(1);
        LOGGER.info("initializeDataFields, number of templates = "+templates.size());

        for (Template template : templates) {
            String base64TffFile = ApplicationConstants.BASE64_PREFIX + 
                            new String(Base64.encodeBase64(template.getTemplateFile().getBytes()));

            LOGGER.info("initializeDataFields, initializing templateId = "+template.getTemplateid()+".");
            templateDatafieldMap.put(template.getTemplateid(), SELUtil.getDatafieldNames(base64TffFile));
            LOGGER.info("initializeDataFields, templateId = "+template.getTemplateid()+" initialized.");
        }

        IDynamicAttributeDAO dynamicAttributeDAO =(IDynamicAttributeDAO) applicationContext.getBean("dynamicAttributeDAO");

        staticContextMap.put(ApplicationConstants.TEMPLATE_DATAFIELD_MAP, templateDatafieldMap);
        staticContextMap.put(ApplicationConstants.ECC5_SAPTODATAFIELD_MAP,dynamicAttributeDAO.getAllSAPtoDataFieldAttribsMap(SAPConstants.SAP_ECC5));
        staticContextMap.put(ApplicationConstants.ECC6_SAPTODATAFIELD_MAP,dynamicAttributeDAO.getAllSAPtoDataFieldAttribsMap(SAPConstants.SAP_ECC6));
        staticContextMap.put(ApplicationConstants.ALL_DYNAMICATTRIBS_MAP,dynamicAttributeDAO.getAllDynamicAttributesMap());

    }


    public  Map<String, Object> getStaticContextMap() {
        return staticContextMap;
    }



}

上記のクラスでは、ClassPathXMLApplicationContext を使用して Bean のリロード/再スキャンを試みていました。ここでは、DAO の使用中に例外が生成されました。

構成が完全にスキャンされ、すべての Bean が初期化される前に、DAO を取得しようとしていました。

于 2013-02-21T16:46:05.733 に答える