« Return to Thread: Mule - Spring - ActiveMQ - XML to wire up a JMSConnector without JNDI

Mule - Spring - ActiveMQ - XML to wire up a JMSConnector without JNDI

by Matt Vincent :: Rate this Message:

Reply to Author | View in Thread

Does anyone have some sample spring config for (auto)wiring up a JMSConnector * without JNDI * to a AutowireUMOManagerFactoryBean?  I continue to get this error Caused by: org.mule.umo.lifecycle.InitialisationException: The required object/property "jndiInitialFactory" is null

I've read many articles, tried a variety of configurations on a number of releases of Mule (1.4.3, 1.4.4, 2.0.0).

My environment: running activemq (4.1.1.) in the web app, running mule (1.4.3) in the web app, java 1.5.0_07, tomcat-5.0.28
My config generally looks like this:

################### ActiveMQ Spring Config #############################

        <bean id="brokerFactory" class="org.apache.activemq.xbean.BrokerFactoryBean ">
                <property name="config" value="classpath:/activemq-config.xml" />
        </bean>
       
        <bean id="jmsPooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
                <property name="connectionFactory">
                        <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                                <property name="brokerURL" value="vm://localhost?broker.useJmx=true" />
...
                        </bean>
                </property>
        </bean>

################### Mule Spring Config ################################

        <bean id="muleManager" class="org.mule.extras.spring.config.AutowireUMOManagerFactoryBean"/>
        <bean id="muleNameProcessor" class="org.mule.extras.spring.config.MuleObjectNameProcessor" />
        <bean id="applicationEventMulticaster" class="org.mule.extras.spring.events.MuleEventMulticaster">
                <property name="asynchronous" value="true"/>
        </bean>
       
<!-- I have tried both of the configs below to try to get jmsConnector wired in -->

   <bean id="jmsConnector" name="jmsConnector" class="org.mule.providers.jms.JmsConnector">
        <property name="specification" value="1.1"/>
        <property name="connectionFactoryJndiName" value="ConnectionFactory"/>
        <property name="jndiInitialFactory" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>
                <property name="jndiProviderUrl" value="tcp://localhost:61616"/>
                <property name="connectionFactoryClass" value="org.apache.activemq.ActiveMQConnectionFactory"/>
                <property name="connectionFactoryProperties">
                        <map>
                                <entry key="brokerURL" value="tcp://localhost:61616" />
                    </map>
                </property>
                <property name="persistentDelivery" value="true" />
     </bean>

<!-- and -->

   <bean id="jmsConnector" name="jmsConnector" class="org.mule.providers.jms.JmsConnector">
        <property name="specification" value="1.1"/>
        <property name="connectionFactory" >
            <ref bean="jmsPooledConnectionFactory" />
     </bean>

####################################################################
After still getting: org.mule.umo.lifecycle.InitialisationException: The required object/property "jndiInitialFactory" is null
I tried starting Mule using mule DSL instead of Spring (but still starting Mule through a listener)

######################### web.xml #################################

Added:
        <context-param>
    <param-name>org.mule.config</param-name>
    <param-value>/WEB-INF/classes/mule-config.xml</param-value>
        </context-param>

        <!-- Mule -->
        <listener>
            <listener-class>org.mule.config.builders.MuleXmlBuilderContextListener</listener-class>
        </listener>

#####################  mule-config.xml ###############################

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE mule-configuration PUBLIC "-//MuleSource //DTD mule-configuration XML V1.0//EN"
                                "http://mule.mulesource.org/dtds/mule-configuration.dtd">

<mule-configuration id="vp" version="1.0">
  <description>Configuration for the the "vp" project</description>

  <container-context className="org.mule.extras.spring.SpringContainerContext" name="spring" >
  <properties>
        <property name="configFile" value="/WEB-INF/classes/applicationContext-*.xml"/>
    </properties>
  </container-context>

        <connector name="jmsConnector" className="org.mule.providers.jms.JmsConnector">
            <properties>
                <property name="specification" value="1.1"/>
                <container-property name="connectionFactory"
                                    reference="jmsPooledConnectionFactory"
                                    container="spring"/>
            </properties>
        </connector>
</mule-configuration>

######################### Additional ############################

When adding this mule-config.xml file, I also commented out my Spring bean:
        <bean id="muleManager" class="org.mule.extras.spring.config.AutowireUMOManagerFactoryBean">

######################### Results #############################

Caused by: org.mule.providers.ConnectException: Failed to create Jms Connector
        at org.mule.providers.jms.JmsConnector.doConnect(JmsConnector.java:368)
        at org.mule.providers.AbstractConnector.connect(AbstractConnector.java:1159)
        at org.mule.providers.SingleAttemptConnectionStrategy.doConnect(SingleAttemptConnectionStrategy.java:25)
        ... 72 more
Caused by: org.mule.umo.lifecycle.InitialisationException: The required object/property "jndiInitialFactory" is null
        at org.mule.providers.jms.JmsConnector.initJndiContext(JmsConnector.java:203)
        at org.mule.providers.jms.JmsConnector.doConnect(JmsConnector.java:334)
        ... 74 more

org.mule.config.ConfigurationException: Failed to parse configuration resource "/WEB-INF/classes/mule-config.xml"
(no more detail than this on why parsing failed)

##############################################################

I thought that http://mule.mulesource.org/jira/browse/MULE-900 might fix this with the new connectionFactoryClass, but I can't figure out how to instantiate a PooledConnectionFactory (if that's what I should really be trying to do) based on the source code changes that were made in JmsConnector:

// have to instanciate it here, and not earlier in MuleXmlConfigurationBuilder, as
// native factory may initiate immediate connections, and that is not what we
// want if the descriptor's initial state is paused.
      if (connectionFactoryClass != null) {
      connectionFactory = (ConnectionFactory) ClassUtils.instanciateClass(connectionFactoryClass,
                                                                         ClassUtils.NO_ARGS);
}



Can anyone see what I can change in order to get rid of the "The required object/property "jndiInitialFactory" is null" error and get my JMSConnector wired into Mule by Spring?

 « Return to Thread: Mule - Spring - ActiveMQ - XML to wire up a JMSConnector without JNDI