« Return to Thread: java.lang.NullPointerException: managedConnectionFactory is null

java.lang.NullPointerException: managedConnectionFactory is null

by Dave Cameron :: Rate this Message:

Reply to Author | View in Thread

Hi All,

I've seen something similar to this on the ActiveMQ forum.  But this smells different.

Can somebody shed any light on how I can at least quiet it down?

Any help would be greatly appreciated!

I have an inbound/outbound application with:
    Jencks 2.0
    ActiveMQ 4.1.1
    Geronimo 1.2-beta
    Spring Framework 2.0.6

I am doing full JCA with XA transactions.

It appears to be working complete with XA transactions except for this strange exception during startup of the JCAContainer.  The exception appears to generate from the tail end of the JCAContainer afterPropertiesSet.  So nothing fatal is going on.  Exceptions like this sure are annoying though!

Here is the exception that I get:

19:08:02,593 [      main] WARN  org.springframework.beans.factory.support.DefaultListableBeanFactory  - FactoryBean threw exception from getObjectType, despite the contract saying that it should return null if the type of its object cannot be determined yet
java.lang.NullPointerException: managedConnectionFactory is null
        at org.jencks.factory.ConnectionFactoryFactoryBean.getConnectionFactory(ConnectionFactoryFactoryBean.java:73)
        at org.jencks.factory.ConnectionFactoryFactoryBean.getObjectType(ConnectionFactoryFactoryBean.java:54)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:555)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:441)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:173)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:242)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:236)
        at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:790)
        at org.jencks.JCAContainer.afterPropertiesSet(JCAContainer.java:92)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:91)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:75)
        at com.myPackage.MyMain.main(MyMain.java:42)



My application context is kind of old fashioned.  I tried to modernize it with no happy result.
Here is what the relevant part of my application context:

  <bean id="userTransaction" class="org.jencks.factory.TransactionManagerFactoryBean"/>

  <bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
    <property name="userTransaction" ref="userTransaction" />
  </bean>
       

  <bean id="jmtlIntegrationFramework" class="com.lmco.axo.hasp.AXOTransactionIntegration">
    <property name="transactionManager" ref="userTransaction" />
  </bean>

  <bean id="activeMQResourceAdapter" class="org.apache.activemq.ra.ActiveMQResourceAdapter">
    <property name="serverUrl" value="tcp://localhost:61676"/>
    <property name="brokerXmlConfig" value="xbean:cauliflower-activemq.xml"/>
  </bean>
       
     
  <bean id="jencks" class="org.jencks.JCAContainer">
    <property name="bootstrapContext">
      <bean class="org.jencks.factory.BootstrapContextFactoryBean">
        <property name="threadPoolSize" value="25"/>
    <property name="transactionManager" ref="userTransaction"/>
       </bean>
    </property>
    <property name="resourceAdapter" ref="activeMQResourceAdapter"/>
  </bean>



  <bean id="inboundConnector" class="org.jencks.JCAConnector">
    <property name="jcaContainer" ref="jencks" />
    <!-- subscription details -->
    <property name="activationSpec">
      <bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
        <property name="destination" ref="cauliflowerListenerTopic"/>
        <property name="destinationType" value="javax.jms.Topic"/>
      </bean>
    </property>
    <!-- use XA transactions -->
    <property name="transactionManager" ref="userTransaction"/>
    <!-- Message Listener -->
    <property name="ref" value="listenerAdapter"/>
  </bean>
 

  <bean id="connectionManager" class="org.jencks.factory.ConnectionManagerFactoryBean">
    <property name="transactionManager" ref="userTransaction"/>
  </bean>


  <bean id="jmsManagedConnectionFactory" class="org.apache.activemq.ra.ActiveMQManagedConnectionFactory">
    <property name="resourceAdapter" ref="activeMQResourceAdapter"/>
  </bean>

  <bean id="jmsConnectionFactory" class="org.jencks.factory.ConnectionFactoryFactoryBean">
    <property name="managedConnectionFactory" ref="jmsManagedConnectionFactory"/>
    <property name="connectionManager" ref="connectionManager"/>
  </bean>

 « Return to Thread: java.lang.NullPointerException: managedConnectionFactory is null