[servicemix-user] Need help with ServiceMix 1.0 Jms+Jndi configuration

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[servicemix-user] Need help with ServiceMix 1.0 Jms+Jndi configuration

Peter Smith-2
Hi,

I wonder if anybody out there would like to look at this ServiceMix 1.0
configuration and tell me what I've done wrong.

This configuration is supposed to set up a JMS receiver (listening on
queue/Q1) which routes to a JMS sender (sending to queue/Q2). The
QueueConnectionFactory is queue/QCF. Another complication is I am using
my own vendor JNDI.

Externally, I have already configured Queues and JNDI and I already have
working JMS clients to sit at the fringes of this configuration.

I am kind of working from a Spring JMS configuration I found here:
http://www-128.ibm.com/developerworks/web/library/wa-spring4/?ca=drs-tp4005 
but really the main problem is I am new to Spring so I was always going
to come to grief sooner or later.

BTW, is there any Spring logging I can somehow enable that will help
understand is going on?

Thanks in advance for any help.
Peter.



Here is my servicemix.xml

---------

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:my="http://servicemix.org/demo/">

  <!-- the JBI container -->
  <container id="jbi">
    <property name="createMBeanServer" value="true"/>
    <property name="dumpStats" value="true"/>
    <property name="statsInterval" value="10"/>

    <components>
      <!-- 1st. Subscribe to a JMS destination Q1 -->
      <component id="inputReceiver" service="my:inputReceiver"
class="org.servicemix.components.jms.JmsReceiverComponent"
destinationService="my:outputSender">
        <property name="template">
          <bean class="org.springframework.jms.core.JmsTemplate102">
            <property name="connectionFactory"
ref="myQueueConnectionFactory"/>
            <property name="defaultDestinationName"
value="java:comp/env/jms/queue/Q1"/>
            <property name="pubSubDomain" value="false"/>
          </bean>
        </property>
      </component>
      <!-- 2nd. Publish the result to a JMS destination Q2 -->
      <component id="outputSender" service="my:outputSender"
class="org.servicemix.components.jms.JmsSenderComponent">
        <property name="template">
          <bean class="org.springframework.jms.core.JmsTemplate102">
            <property name="connectionFactory"
ref="myQueueConnectionFactory"/>
            <property name="defaultDestinationName"
value="java:comp/env/jms/queue/Q2"/>
            <property name="pubSubDomain" value="false"/>
            <property name="explicitQosEnabled" value="true"/>
            <property name="timeToLive" value="60000"/>
          </bean>
        </property>
      </component>      
    </components>  
     
    <!-- Use our JNDI - The JMS Administered objects are already in here -->
    <bean id="myJndi" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
          <props>
            <prop
key="java.naming.factory.initial">com.fujitsu.interstage.j2ee.jndi.InitialContextFactoryForClient</prop>
          </props>
        </property>
    </bean>

    <!-- The QueueConnectionFactory is in the JNDI -->
    <bean id="myQueueConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiTemplate" ref="myJndi"/>
      <property name="jndiName" value="java:comp/env/jms/queue/QCF"/>
    </bean>

    <!-- Needed for SpringJBIContainer? -->    
    <bean id="transactionManager"
class="org.jencks.factory.TransactionManagerFactoryBean"/>

  </container>
 
</beans>

---------

And here are my errors:

Loading ServiceMix from file: servicemix.xml
9/11/2005 14:35:46
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from file
[D:\starteam\j2ee14\ESB\proj-prototype\MyExample\jms-binding\servicemix.xml]
9/11/2005 14:35:56
org.springframework.context.support.AbstractRefreshableApplicationContext
refreshBeanFactory
INFO: Bean factory for application context
[org.springframework.context.support.FileSystemXmlApplicationContext;hashCode=8785225]:
org.springframework.beans.factory.support.DefaultListableBeanFactory
defining beans [jbi]; root of BeanFactory hierarchy
9/11/2005 14:35:56
org.springframework.context.support.AbstractApplicationContext refresh
INFO: 1 beans defined in application context
[org.springframework.context.support.FileSystemXmlApplicationContext;hashCode=8785225]
9/11/2005 14:35:56 org.springframework.core.CollectionFactory <clinit>
INFO: JDK 1.4+ collections available
9/11/2005 14:35:56 org.springframework.core.CollectionFactory <clinit>
INFO: Commons Collections 3.x available
9/11/2005 14:35:56
org.springframework.context.support.AbstractApplicationContext
initMessageSource
INFO: Unable to locate MessageSource with name 'messageSource': using
default
[org.springframework.context.support.DelegatingMessageSource@1d95da8]
9/11/2005 14:35:56
org.springframework.context.support.AbstractApplicationContext
initApplicationEventMulticaster
INFO: Unable to locate ApplicationEventMulticaster with name
'applicationEventMulticaster': using default
[org.springframework.context.event.SimpleApplicationEventMulticaster@61736e]
9/11/2005 14:35:56
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
INFO: Pre-instantiating singletons in factory
[org.springframework.beans.factory.support.DefaultListableBeanFactory
defining beans [jbi]; root of BeanFactory hierarchy]
9/11/2005 14:35:56
org.springframework.beans.factory.support.AbstractBeanFactory getBean
INFO: Creating shared instance of singleton bean 'jbi'
9/11/2005 14:36:01
org.springframework.beans.factory.support.AbstractBeanFactory
destroySingletons
INFO: Destroying singletons in factory
{org.springframework.beans.factory.support.DefaultListableBeanFactory
defining beans [jbi]; root of BeanFactory hierarchy}
Caught: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'org.springframework.jms.core.JmsTemplate102'
defined in file
[D:\starteam\j2ee14\ESB\proj-prototype\MyExample\jms-binding\servicemix.xml]:
Can't resolve reference to bean 'myQueueConnectionFactory' while setting
property 'connectionFactory'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'myQueueConnectionFactory' is defined:
org.springframework.beans.factory.support.DefaultListableBeanFactory
defining beans[jbi]; root of BeanFactory hierarchy
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'org.springframework.jms.core.JmsTemplate102' defined in
file
[D:\starteam\j2ee14\ESB\proj-prototype\MyExample\jms-binding\servicemix.xml]:
Can't resolve reference to bean 'myQueueConnectionFactory' while setting
property 'connectionFactory'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'myQueueConnectionFactory' is defined:
org.springframework.beans.factory.support.DefaultListableBeanFactory
defining beans [jbi]; root of BeanFactory
hierarchyorg.springframework.beans.factory.NoSuchBeanDefinitionException:
No bean named 'myQueueConnectionFactory' is defined:
org.springframework.beans.factory.support.DefaultListableBeanFactory
defining beans [jbi]; root of BeanFactory hierarchy
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:351)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:640)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:920)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:731)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:340)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:147)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:96)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:920)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:731)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:340)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:147)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:96)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:920)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:731)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:340)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:147)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:96)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:193)
        at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:920)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:731)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:340)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:223)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:312)
        at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:82)
        at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:67)
        at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:58)
        at org.servicemix.Main.main(Main.java:76)

[end]

Reply | Threaded
Open this post in threaded view
|

Re: [servicemix-user] Need help with ServiceMix 1.0 Jms+Jndi configuration

Guillaume Nodet-3
The container (ServiceMix specific element) must only contains components.
The other beans that you defined (myQueueConnectionFactory and myJndi)
must appear
outside of the container element.

You can see the bean defined in the spring configuration in the log.
The org.springframework.beans.factory.support.DefaultListableBeanFactory
defining beans [jbi];
statement says that there is only one bean defined named jbi.

Cheers,
Guillaume Nodet

Peter Smith wrote:

> Hi,
>
> I wonder if anybody out there would like to look at this ServiceMix
> 1.0 configuration and tell me what I've done wrong.
>
> This configuration is supposed to set up a JMS receiver (listening on
> queue/Q1) which routes to a JMS sender (sending to queue/Q2). The
> QueueConnectionFactory is queue/QCF. Another complication is I am
> using my own vendor JNDI.
>
> Externally, I have already configured Queues and JNDI and I already
> have working JMS clients to sit at the fringes of this configuration.
>
> I am kind of working from a Spring JMS configuration I found here:
> http://www-128.ibm.com/developerworks/web/library/wa-spring4/?ca=drs-tp4005 
> but really the main problem is I am new to Spring so I was always
> going to come to grief sooner or later.
>
> BTW, is there any Spring logging I can somehow enable that will help
> understand is going on?
>
> Thanks in advance for any help.
> Peter.
>
>
>
> Here is my servicemix.xml
>
> ---------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns:my="http://servicemix.org/demo/">
>
>  <!-- the JBI container -->
>  <container id="jbi">
>    <property name="createMBeanServer" value="true"/>
>    <property name="dumpStats" value="true"/>
>    <property name="statsInterval" value="10"/>
>
>    <components>
>      <!-- 1st. Subscribe to a JMS destination Q1 -->
>      <component id="inputReceiver" service="my:inputReceiver"
> class="org.servicemix.components.jms.JmsReceiverComponent"
> destinationService="my:outputSender">
>        <property name="template">
>          <bean class="org.springframework.jms.core.JmsTemplate102">
>            <property name="connectionFactory"
> ref="myQueueConnectionFactory"/>
>            <property name="defaultDestinationName"
> value="java:comp/env/jms/queue/Q1"/>
>            <property name="pubSubDomain" value="false"/>
>          </bean>
>        </property>
>      </component>
>      <!-- 2nd. Publish the result to a JMS destination Q2 -->
>      <component id="outputSender" service="my:outputSender"
> class="org.servicemix.components.jms.JmsSenderComponent">
>        <property name="template">
>          <bean class="org.springframework.jms.core.JmsTemplate102">
>            <property name="connectionFactory"
> ref="myQueueConnectionFactory"/>
>            <property name="defaultDestinationName"
> value="java:comp/env/jms/queue/Q2"/>
>            <property name="pubSubDomain" value="false"/>
>            <property name="explicitQosEnabled" value="true"/>
>            <property name="timeToLive" value="60000"/>
>          </bean>
>        </property>
>      </component>          </components>          <!-- Use our JNDI -
> The JMS Administered objects are already in here -->
>    <bean id="myJndi" class="org.springframework.jndi.JndiTemplate">
>        <property name="environment">
>          <props>
>            <prop
> key="java.naming.factory.initial">com.fujitsu.interstage.j2ee.jndi.InitialContextFactoryForClient</prop>
>
>          </props>
>        </property>
>    </bean>
>
>    <!-- The QueueConnectionFactory is in the JNDI -->
>    <bean id="myQueueConnectionFactory"
> class="org.springframework.jndi.JndiObjectFactoryBean">
>      <property name="jndiTemplate" ref="myJndi"/>
>      <property name="jndiName" value="java:comp/env/jms/queue/QCF"/>
>    </bean>
>
>    <!-- Needed for SpringJBIContainer? -->        <bean
> id="transactionManager"
> class="org.jencks.factory.TransactionManagerFactoryBean"/>
>
>  </container>
>
> </beans>
>
> ---------
>
> And here are my errors:
>
> Loading ServiceMix from file: servicemix.xml
> 9/11/2005 14:35:46
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader
> loadBeanDefinitions
> INFO: Loading XML bean definitions from file
> [D:\starteam\j2ee14\ESB\proj-prototype\MyExample\jms-binding\servicemix.xml]
>
> 9/11/2005 14:35:56
> org.springframework.context.support.AbstractRefreshableApplicationContext
> refreshBeanFactory
> INFO: Bean factory for application context
> [org.springframework.context.support.FileSystemXmlApplicationContext;hashCode=8785225]:
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> defining beans [jbi]; root of BeanFactory hierarchy
> 9/11/2005 14:35:56
> org.springframework.context.support.AbstractApplicationContext refresh
> INFO: 1 beans defined in application context
> [org.springframework.context.support.FileSystemXmlApplicationContext;hashCode=8785225]
>
> 9/11/2005 14:35:56 org.springframework.core.CollectionFactory <clinit>
> INFO: JDK 1.4+ collections available
> 9/11/2005 14:35:56 org.springframework.core.CollectionFactory <clinit>
> INFO: Commons Collections 3.x available
> 9/11/2005 14:35:56
> org.springframework.context.support.AbstractApplicationContext
> initMessageSource
> INFO: Unable to locate MessageSource with name 'messageSource': using
> default
> [org.springframework.context.support.DelegatingMessageSource@1d95da8]
> 9/11/2005 14:35:56
> org.springframework.context.support.AbstractApplicationContext
> initApplicationEventMulticaster
> INFO: Unable to locate ApplicationEventMulticaster with name
> 'applicationEventMulticaster': using default
> [org.springframework.context.event.SimpleApplicationEventMulticaster@61736e]
>
> 9/11/2005 14:35:56
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> preInstantiateSingletons
> INFO: Pre-instantiating singletons in factory
> [org.springframework.beans.factory.support.DefaultListableBeanFactory
> defining beans [jbi]; root of BeanFactory hierarchy]
> 9/11/2005 14:35:56
> org.springframework.beans.factory.support.AbstractBeanFactory getBean
> INFO: Creating shared instance of singleton bean 'jbi'
> 9/11/2005 14:36:01
> org.springframework.beans.factory.support.AbstractBeanFactory
> destroySingletons
> INFO: Destroying singletons in factory
> {org.springframework.beans.factory.support.DefaultListableBeanFactory
> defining beans [jbi]; root of BeanFactory hierarchy}
> Caught: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'org.springframework.jms.core.JmsTemplate102'
> defined in file
> [D:\starteam\j2ee14\ESB\proj-prototype\MyExample\jms-binding\servicemix.xml]:
> Can't resolve reference to bean 'myQueueConnectionFactory' while
> setting property 'connectionFactory'; nested exception is
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No
> bean named 'myQueueConnectionFactory' is defined:
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> defining beans[jbi]; root of BeanFactory hierarchy
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'org.springframework.jms.core.JmsTemplate102'
> defined in file
> [D:\starteam\j2ee14\ESB\proj-prototype\MyExample\jms-binding\servicemix.xml]:
> Can't resolve reference to bean 'myQueueConnectionFactory' while
> setting property 'connectionFactory'; nested exception is
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No
> bean named 'myQueueConnectionFactory' is defined:
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> defining beans [jbi]; root of BeanFactory
> hierarchyorg.springframework.beans.factory.NoSuchBeanDefinitionException:
> No bean named 'myQueueConnectionFactory' is defined:
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> defining beans [jbi]; root of BeanFactory hierarchy
>        at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:351)
>
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java:640)
>
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
>
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
>
>        at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
>
>        at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
>
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:920)
>
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:731)
>
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:340)
>
>        at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:147)
>
>        at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:96)
>
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:920)
>
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:731)
>
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:340)
>
>        at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:147)
>
>        at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:96)
>
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:920)
>
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:731)
>
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:340)
>
>        at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:147)
>
>        at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:96)
>
>        at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:193)
>
>        at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
>
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:920)
>
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:731)
>
>        at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:340)
>
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:223)
>
>        at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
>
>        at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
>
>        at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:312)
>
>        at
> org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:82)
>
>        at
> org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:67)
>
>        at
> org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:58)
>
>        at org.servicemix.Main.main(Main.java:76)
>
> [end]
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: [servicemix-user] Need help with ServiceMix 1.0 Jms+Jndi configuration

Peter Smith-2
Obvious in hindsight. Thanks very much!

----

My next stumpling block is inside the JmsReceiverComponent:

....
        template.execute(new SessionCallback() {
            public Object doInJms(Session session) throws JMSException {
                Destination defaultDestination =
template.getDefaultDestination();
                if (defaultDestination == null) {
                    defaultDestination =
template.getDestinationResolver().resolveDestinationName(session,
template.getDefaultDestinationName(), template.isPubSubDomain());
                }
                consumer = session.createConsumer(defaultDestination,
selector);
                return null;
            }
        }, true);
        consumer.setMessageListener(this); // ******
IllegalStateException THROWN FROM HERE ******
....

---

I am finding that the template.execute is closing the session as it
completes
Closing the session causes my consumer to become closed also
Because the consumer is closed, the setMessageListener API fails with an
IllegalStateException

Do you know is this behaviour something I can affect by configuring
(what?) differently or is it somehow a quirk of my JMS Provider or what?

Note that I am using
- ServiceMix 1.0
- The JmsReceiverComponent (not the JmsInUsingJCABinding like in the SM
examples)

My configuration is as follows

===
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:my="http://servicemix.org/demo/">

  <!-- the JBI container -->
  <container id="jbi">
    <property name="createMBeanServer" value="true"/>
    <property name="dumpStats" value="true"/>
    <property name="statsInterval" value="10"/>


    <components>
      <!-- 1st. Subscribe to a JMS destination Q1 -->
      <component id="inputReceiver" service="my:inputReceiver"
class="org.servicemix.components.jms.JmsReceiverComponent"
destinationService="my:outputSender">
        <property name="template">
          <bean class="org.springframework.jms.core.JmsTemplate102">
            <property name="connectionFactory"><ref
bean="myQueueConnectionFactory"/></property>
            <property name="destinationResolver"><ref
bean="myJmsDestinationResolver"/></property>
            <property name="defaultDestinationName"
value="java:comp/env/jms/queue/Q1"/>
            <property name="pubSubDomain" value="false"/>
          </bean>
        </property>
        <property name="selector" value=""/>
      </component>
      <!-- 2nd. Publish the result to a JMS destination Q2 -->
      <component id="outputSender" service="my:outputSender"
class="org.servicemix.components.jms.JmsSenderComponent">
        <property name="template">
          <bean class="org.springframework.jms.core.JmsTemplate102">
            <property name="connectionFactory"><ref
bean="myQueueConnectionFactory"/></property>
            <property name="destinationResolver"><ref
bean="myJmsDestinationResolver"/></property>
            <property name="defaultDestinationName"
value="java:comp/env/jms/queue/Q2"/>
            <property name="pubSubDomain" value="false"/>
            <property name="explicitQosEnabled" value="true"/>
            <property name="timeToLive" value="60000"/>
          </bean>
        </property>
      </component>      
    </components>  
     
  </container>

  <!-- Use my own JNDI - The JMS objects are already binded in here -->
  <bean id="myJndi" class="org.springframework.jndi.JndiTemplate">
      <property name="environment">
        <props>
          <prop
key="java.naming.factory.initial">com.fujitsu.interstage.j2ee.jndi.InitialContextFactoryForClient</prop>
        </props>
      </property>
  </bean>

  <!-- The QueueConnectionFactory is in my JNDI -->
  <bean id="myQueueConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate" ref="myJndi"/>
    <property name="jndiName" value="java:comp/env/jms/queue/QCF"/>
  </bean>
 
  <!-- The JMS Destinations are resolved by looking them up in my JNDI -->
  <bean id="myJmsDestinationResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver">
    <property name="jndiTemplate" ref="myJndi"/>
  </bean>

  <!-- Needed for SpringJBIContainer? -->    
  <bean id="transactionManager"
class="org.jencks.factory.TransactionManagerFactoryBean"/>
 
</beans>

===

Thanks again.
Peter.

Guillaume Nodet wrote:

> The container (ServiceMix specific element) must only contains
> components.
> The other beans that you defined (myQueueConnectionFactory and myJndi)
> must appear
> outside of the container element.
>
> You can see the bean defined in the spring configuration in the log.
> The
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> defining beans [jbi];
> statement says that there is only one bean defined named jbi.
>
> Cheers,
> Guillaume Nodet
>
> Peter Smith wrote:
>
<snip>

Reply | Threaded
Open this post in threaded view
|

Re: [servicemix-user] Need help with ServiceMix 1.0 Jms+Jndi configuration

James Strachan-4

On 11 Nov 2005, at 06:22, Peter Smith wrote:

> Obvious in hindsight. Thanks very much!
>
> ----
>
> My next stumpling block is inside the JmsReceiverComponent:
>
> ....
>        template.execute(new SessionCallback() {
>            public Object doInJms(Session session) throws  
> JMSException {
>                Destination defaultDestination =  
> template.getDefaultDestination();
>                if (defaultDestination == null) {
>                    defaultDestination =  
> template.getDestinationResolver().resolveDestinationName(session,  
> template.getDefaultDestinationName(), template.isPubSubDomain());
>                }
>                consumer = session.createConsumer
> (defaultDestination, selector);
>                return null;
>            }
>        }, true);
>        consumer.setMessageListener(this); // ******  
> IllegalStateException THROWN FROM HERE ******
> ....

After reviewing the Spring code, this looks like a mis-use of the  
JmsTemplate. The execute(SessionCallback()) will close the session  
after the execute() method finishes :). So you should not use this  
method to create consumers :)

I've patched the JmsReceiverComponent which should make it into the  
2.0.2 release shortly.

James Strachan
Chief Architect
LogicBlaze, Inc. - a Simula Labs Enterprise
[hidden email]
www.logicblaze.com