How to set user/password on connection created from JNDI lookup ConnectionFactory

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

How to set user/password on connection created from JNDI lookup ConnectionFactory

lsclark
I am attempting to create a durable subscription to a topic on a JBoss Messaging broker.  I have a JMSComponent configured via spring and am using this component as an endpoint in a route.  I am looking up the ConnectionFactory via JNDI.

What I can't figure out how to do is the configuration in camel for passing in a username and password to be used by the connection factory when it obtains a connection.  I have tried a number of things, and searched around a bit, but haven't found anyone that has run into this particular issue.  The current configuration produces the exception:


 ERROR [org.springframework.jms.listener.DefaultMessageListenerContainer] Setup of JMS message listener invoker failed - trying to recover Logger=org.springframework.jms.listener.DefaultMessageListenerContainer
javax.jms.JMSSecurityException: User: null is not authorized to create durable sub on destination testTopic


Any help or leads would be appreciated!


Spring configuration:

<bean id="jmsProvider" class="org.apache.camel.component.jms.JmsComponent">
    <property name="connectionFactory" ref="jmsConnectionFactory" />
    <property name="destinationResolver" ref="jmsDestinationResolver" />
    <property name="deliveryPersistent" value="true" />
    <property name="timeToLive" value="0" />
    <property name="clientId" value="DurableSubscriberExample" />       
</bean>
   
<bean id="jmsDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver">
    <property name="jndiTemplate" ref="jndiTemplate" />
    <property name="cache" value="true" />
</bean>

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
        <props>
            <prop key="java.naming.factory.initial">${jms.jndiContextFactory}</prop>
            <prop key="brokerURL">${jms.jndiProviderUrl}</prop>
            <prop key="java.naming.provider.url">${jms.jndiProviderUrl}</prop>
        </props>
    </property>
</bean>
   
<bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate" ref="jndiTemplate" />
    <property name="jndiName">
            <value>${jms.connectionFactoryName}</value>
    </property>
</bean>
   
<bean id="testProcessor" class="com.test.TestProcessor"/>


Route DSL:

from("jmsProvider:topic:/topic/testTopic?durableSubscriptionName=john,clientId=DurableSubscriberExample")
            .to("bean:testProcessor");
Reply | Threaded
Open this post in threaded view
|

RE: How to set user/password on connection created from JNDI lookup ConnectionFactory

Claus Ibsen
Hi

There is a JIRA about this: CAMEL-246

And see the link to the nabble forum where a person using MQ found a solution. Maybe it can help you also.

Please feel free to comment on the JIRA or add a link to this forum as well.


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: lsclark [mailto:[hidden email]]
Sent: 23. juni 2008 23:48
To: [hidden email]
Subject: How to set user/password on connection created from JNDI lookup ConnectionFactory


I am attempting to create a durable subscription to a topic on a JBoss
Messaging broker.  I have a JMSComponent configured via spring and am using
this component as an endpoint in a route.  I am looking up the
ConnectionFactory via JNDI.

What I can't figure out how to do is the configuration in camel for passing
in a username and password to be used by the connection factory when it
obtains a connection.  I have tried a number of things, and searched around
a bit, but haven't found anyone that has run into this particular issue.
The current configuration produces the exception:


 ERROR [org.springframework.jms.listener.DefaultMessageListenerContainer]
Setup of JMS message listener invoker failed - trying to recover
Logger=org.springframework.jms.listener.DefaultMessageListenerContainer
javax.jms.JMSSecurityException: User: null is not authorized to create
durable sub on destination testTopic


Any help or leads would be appreciated!


Spring configuration:

<bean id="jmsProvider" class="org.apache.camel.component.jms.JmsComponent">
    <property name="connectionFactory" ref="jmsConnectionFactory" />
    <property name="destinationResolver" ref="jmsDestinationResolver" />
    <property name="deliveryPersistent" value="true" />
    <property name="timeToLive" value="0" />
    <property name="clientId" value="DurableSubscriberExample" />      
</bean>
   
<bean id="jmsDestinationResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver">
    <property name="jndiTemplate" ref="jndiTemplate" />
    <property name="cache" value="true" />
</bean>

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
        <props>
            <prop
key="java.naming.factory.initial">${jms.jndiContextFactory}</prop>
            <prop key="brokerURL">${jms.jndiProviderUrl}</prop>
            <prop
key="java.naming.provider.url">${jms.jndiProviderUrl}</prop>
        </props>
    </property>
</bean>
   
<bean id="jmsConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate" ref="jndiTemplate" />
    <property name="jndiName">
            <value>${jms.connectionFactoryName}</value>
    </property>
</bean>
   
<bean id="testProcessor" class="com.test.TestProcessor"/>


Route DSL:

from("jmsProvider:topic:/topic/testTopic?durableSubscriptionName=john,clientId=DurableSubscriberExample")
            .to("bean:testProcessor");
--
View this message in context: http://www.nabble.com/How-to-set-user-password-on-connection-created-from-JNDI-lookup-ConnectionFactory-tp18079250s22882p18079250.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

RE: How to set user/password on connection created from JNDI lookup ConnectionFactory

lsclark
Thanks Claus for pointing me in the right direction!  Using the UserCredentialsConnectionFactoryAdapter solved my problem.

-L

<snippet for those interested>

    <bean id="proxyConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
    <property name="targetConnectionFactory" ref="jmsConnectionFactory"/>
    <property name="username" value="guest"/>
    <property name="password" value="guest"/>
  </bean> 
   
    <bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="jndiTemplate" />
        <property name="jndiName">
            <value>${jms.connectionFactoryName}</value>
        </property>
    </bean>
   


Claus Ibsen wrote
Hi

There is a JIRA about this: CAMEL-246

And see the link to the nabble forum where a person using MQ found a solution. Maybe it can help you also.

Please feel free to comment on the JIRA or add a link to this forum as well.


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: lsclark [mailto:lisa.clark@rackspace.com]
Sent: 23. juni 2008 23:48
To: camel-user@activemq.apache.org
Subject: How to set user/password on connection created from JNDI lookup ConnectionFactory


I am attempting to create a durable subscription to a topic on a JBoss
Messaging broker.  I have a JMSComponent configured via spring and am using
this component as an endpoint in a route.  I am looking up the
ConnectionFactory via JNDI.

What I can't figure out how to do is the configuration in camel for passing
in a username and password to be used by the connection factory when it
obtains a connection.  I have tried a number of things, and searched around
a bit, but haven't found anyone that has run into this particular issue.
The current configuration produces the exception:


 ERROR [org.springframework.jms.listener.DefaultMessageListenerContainer]
Setup of JMS message listener invoker failed - trying to recover
Logger=org.springframework.jms.listener.DefaultMessageListenerContainer
javax.jms.JMSSecurityException: User: null is not authorized to create
durable sub on destination testTopic


Any help or leads would be appreciated!


Spring configuration:

<bean id="jmsProvider" class="org.apache.camel.component.jms.JmsComponent">
    <property name="connectionFactory" ref="jmsConnectionFactory" />
    <property name="destinationResolver" ref="jmsDestinationResolver" />
    <property name="deliveryPersistent" value="true" />
    <property name="timeToLive" value="0" />
    <property name="clientId" value="DurableSubscriberExample" />       
</bean>
   
<bean id="jmsDestinationResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver">
    <property name="jndiTemplate" ref="jndiTemplate" />
    <property name="cache" value="true" />
</bean>

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
        <props>
            <prop
key="java.naming.factory.initial">${jms.jndiContextFactory}</prop>
            <prop key="brokerURL">${jms.jndiProviderUrl}</prop>
            <prop
key="java.naming.provider.url">${jms.jndiProviderUrl}</prop>
        </props>
    </property>
</bean>
   
<bean id="jmsConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate" ref="jndiTemplate" />
    <property name="jndiName">
            <value>${jms.connectionFactoryName}</value>
    </property>
</bean>
   
<bean id="testProcessor" class="com.test.TestProcessor"/>


Route DSL:

from("jmsProvider:topic:/topic/testTopic?durableSubscriptionName=john,clientId=DurableSubscriberExample")
            .to("bean:testProcessor");
--
View this message in context: http://www.nabble.com/How-to-set-user-password-on-connection-created-from-JNDI-lookup-ConnectionFactory-tp18079250s22882p18079250.html
Sent from the Camel - Users mailing list archive at Nabble.com.