Announcement Announcement Module
Collapse
No announcement yet.
Initialization of bean failed; InvocationTargetException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Initialization of bean failed; InvocationTargetException

    While the beans are being created I sometimes get the following error :

    "org.springframework.beans.factory.BeanCreationExc eption: Error creating bean with name 'remoteTicketGenerator' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested
    exception is java.lang.reflect.InvocationTargetException: null"

    I'm using the MethodInvokingFactoryBean to get access to the RemoteTicketGeneratorFactory and retrieve the method getTicketGenerator

    Here are the beans that are involved if anybody has a clue why I sometimes receive an InvocationTargetException please let me know because I've been searching for days :

    <!-- The parameters needed to perform jndi lookup for base services -->
    <!-- As all base services should be deployed on our machines, they should all use this template -->
    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
    <props>
    <prop key="java.naming.factory.initial">${java.naming.fa ctory.initial}</prop>
    <prop key="java.naming.provider.url">${java.naming.provi der.url}</prop>
    <prop key="java.naming.security.principal">${java.naming .security.principal}</prop>
    <prop key="java.naming.security.credentials">${java.nami ng.security.credentials}</prop>
    </props>
    </property>
    </bean>
    <!-- A reference to a RipService instance -->
    <bean id="ripService" class="org.springframework.ejb.access.SimpleRemote StatelessSessionProxyFactoryBean">
    <property name="jndiTemplate">
    <ref local="jndiTemplate" />
    </property>
    <property name="jndiName">
    <value>${ripService.jndiName}</value>
    </property>
    <property name="businessInterface">
    <value>be.smalsmvm.common.businessservices.rip.ser vice.RipService</value>
    </property>
    </bean>

    <!-- A reference to a RemoteTicketGeneratorFactory -->
    <bean id="remoteTicketGeneratorFactory" class="org.springframework.jndi.JndiObjectFactoryB ean" destroy-method="close">
    <property name="jndiTemplate">
    <ref local="jndiTemplate" />
    </property>
    <property name="jndiName">
    <value>${ticketGeneratorFactory.jndiName}</value>
    </property>
    </bean>
    <!-- Retrieve a RemoteTicketGenerator instance from remoteTicketGeneratorFactory -->
    <bean id="remoteTicketGenerator" class="org.springframework.beans.factory.config.Me thodInvokingFactoryBean">
    <property name="targetObject">
    <ref local="remoteTicketGeneratorFactory"/>
    </property>
    <property name="targetMethod">
    <value>getTicketGenerator</value>
    </property>
    <property name="arguments">
    <list>
    <value>${application.name}</value>
    </list>
    </property>
    </bean>

  • #2
    Could you show a full stack trace?

    Comment


    • #3
      Here is the stack trace, you can see that there is a sqlException.
      But this is not always the case.... Thanks for any info !



      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'remoteTicketGenerator' defined in class path resource [applicationContext-rip.xml]: Initialization of bean failed; nested exception is java.lang.reflect.InvocationTargetException: null
      java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.springframework.util.MethodInvoker.invoke(Meth odInvoker.java:221)
      at org.springframework.beans.factory.config.MethodInv okingFactoryBean.afterPropertiesSet(MethodInvoking FactoryBean.java:100)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1057)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:287)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:205)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:204)
      at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:136)
      at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:230)
      at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:284)
      at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:80)
      at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:65)
      at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:56)
      at be.smalsmvm.genesis.business.service.RipBusinessSe rviceTest.setUp(RipBusinessServiceTest.java:56)
      at junit.framework.TestCase.runBare(TestCase.java:125 )
      at junit.framework.TestResult$1.protect(TestResult.ja va:106)
      at junit.framework.TestResult.runProtected(TestResult .java:124)
      at junit.framework.TestResult.run(TestResult.java:109 )
      at junit.framework.TestCase.run(TestCase.java:118)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:421)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:305)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:186)
      Caused by: be.smalsmvm.common.systemservices.identifier.Ticke tException: Problem with the Tickets database : java.sql.SQLException: ORA-00904: invalid column name

      at weblogic.rjvm.BasicOutboundRequest.sendReceive(Bas icOutboundRequest.java:108)
      at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicR emoteRef.java:137)
      at be.smalsmvm.common.systemservices.identifier.rmi.R emoteTicketGeneratorFactoryServer_813_WLStub.getTi cketGenerator(Unknown Source)
      ... 25 more
      Caused by: be.smalsmvm.common.systemservices.identifier.Ticke tException: Problem with the Tickets database : java.sql.SQLException: ORA-00904: invalid column name

      at be.smalsmvm.common.systemservices.identifier.Ticke tGeneratorFactory.getApplicationId(TicketGenerator Factory.java:285)
      at be.smalsmvm.common.systemservices.identifier.Ticke tGeneratorFactory.getTicketGenerator(TicketGenerat orFactory.java:89)
      at be.smalsmvm.common.systemservices.identifier.rmi.R emoteTicketGeneratorFactoryServer.getTicketGenerat or(RemoteTicketGeneratorFactoryServer.java:32)
      at be.smalsmvm.common.systemservices.identifier.rmi.R emoteTicketGeneratorFactoryServer_WLSkel.invoke(Un known Source)
      at weblogic.rmi.internal.BasicServerRef.invoke(BasicS erverRef.java:477)
      at weblogic.rmi.internal.BasicServerRef$1.run(BasicSe rverRef.java:420)
      at weblogic.security.acl.internal.AuthenticatedSubjec t.doAs(AuthenticatedSubject.java:363)
      at weblogic.security.service.SecurityManager.runAs(Se curityManager.java:144)
      at weblogic.rmi.internal.BasicServerRef.handleRequest (BasicServerRef.java:415)
      at weblogic.rmi.internal.BasicExecuteRequest.execute( BasicExecuteRequest.java:30)
      at weblogic.kernel.ExecuteThread.execute(ExecuteThrea d.java:219)
      at weblogic.kernel.ExecuteThread.run(ExecuteThread.ja va:178)

      [/code]

      Comment


      • #4
        I guess the reason for the failure could always be found in the nested stacktrace. Here it is a SqlException. In your other cases it might be something different.

        What I notice however, is a subobtimal handling of InvocationTargetException in AbstractAutowireCapableBeanFactory#getBean. In this method there is a catch-block for Throwable. Maybe an additional distinction should be made to extract the nested exception of the InvocationTargetException.

        Regards,
        Andreas

        Comment

        Working...
        X