You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by sureshshine <su...@gmail.com> on 2016/07/21 08:42:50 UTC

Tomme+ and JMS with JNDI configuration

Hi All, 

I integrated ActiveMQ with Tomee+ and I tried to configure JMS connection by
using jndi but it was not working. 

I created jndi.properties and placed that in webapps\activemq\WEB-INF\ ,
ActiveMQ console war which is running in the tomee+ 


java.naming.factory.initial =
org.apache.activemq.jndi.ActiveMQInitialContextFactory 

# use the following property to configure the default connector 
#java.naming.provider.url = vm://localhost 
java.naming.provider.url = tcp://localhost:61616 

# use the following property to specify the JNDI name the connection factory 
# should appear as. 
connectionFactoryNames = connectionFactory, queueConnectionFactory,
topicConnectionFactry 

# register some queues in JNDI using the form 
# queue.[jndiName] = [physicalName] 
queue.MyQueue = MyDestQueue 


# register some topics in JNDI using the form 
# topic.[jndiName] = [physicalName] 
#topic.MyTopic = example.MyTopic 

# END SNIPPET: jndi 

Please let know the where i need to add these configuration , in tomee+ or
activemq war 

Thanks in Advance 



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomme-and-JMS-with-JNDI-configuration-tp4679415.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: Tomme+ and JMS with JNDI configuration

Posted by sureshshine <su...@gmail.com>.
Finally , the issue has been resolved , I added the below configuration in my
application web.xml , it's works fine.

resource-ref> 
                <description>JMS JNDI Connection</description>
                <res-ref-name>jms/ConnectionFactory</res-ref-name>
                <res-type>javax.jms.ConnectionFactory</res-type>
                <res-auth>Container</res-auth>
        </resource-ref> 


Thanks



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomme-and-JMS-with-JNDI-configuration-tp4679415p4679457.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: Tomme+ and JMS with JNDI configuration

Posted by sureshshine <su...@gmail.com>.
Thanks much , After adding openejb:Resource in spring context , the issue has
been resolved. The problem was in my sample application code.



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomme-and-JMS-with-JNDI-configuration-tp4679415p4679484.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: Tomme+ and JMS with JNDI configuration

Posted by Romain Manni-Bucau <rm...@gmail.com>.
https://github.com/rmannibucau/lookup-from-spring-in-tomee uses that,
lookup works and is done with first solution:
https://github.com/rmannibucau/lookup-from-spring-in-tomee/blob/master/src/main/webapp/WEB-INF/applicationContext.xml#L13


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-07-22 14:44 GMT+02:00 sureshshine <su...@gmail.com>:

> Thanks .. It's not working, Still i am getting null exception for
> connectionFactory. I changed the spring configuration as you suggested ( I
> tried both )
>
> <jee:jndi-lookup id="connectionFactory"
> jndi-name="openejb:Resource/jms/ConnectionFactory"
> lookup-on-startup="false"
> proxy-interface="javax.jms.ConnectionFactory"/>
>
> and
>
> <jee:jndi-lookup id="connectionFactory"
> jndi-name="java:openejb/Resource/ConnectionFactory"
> lookup-on-startup="false" proxy-interface="javax.jms.ConnectionFactory"/>
>
> Please help me to get it resolved.
>
> Thanks much.
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Tomme-and-JMS-with-JNDI-configuration-tp4679415p4679459.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>

Re: Tomme+ and JMS with JNDI configuration

Posted by sureshshine <su...@gmail.com>.
Thanks .. It's not working, Still i am getting null exception for
connectionFactory. I changed the spring configuration as you suggested ( I
tried both )

<jee:jndi-lookup id="connectionFactory"
jndi-name="openejb:Resource/jms/ConnectionFactory" lookup-on-startup="false"
proxy-interface="javax.jms.ConnectionFactory"/>

and 

<jee:jndi-lookup id="connectionFactory"
jndi-name="java:openejb/Resource/ConnectionFactory"
lookup-on-startup="false" proxy-interface="javax.jms.ConnectionFactory"/>

Please help me to get it resolved.

Thanks much.





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomme-and-JMS-with-JNDI-configuration-tp4679415p4679459.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: Tomme+ and JMS with JNDI configuration

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Add prefix openejb:Resource/ or java:openejb/Resource/ to id value for
spring lookup

Le 22 juil. 2016 12:19, "sureshshine" <su...@gmail.com> a écrit :

> Thanks much for your reply.
>
> I need one more clarification and added a jndi resource in tomee.xml as
> follows,
>
> <Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
>                 BrokerXmlConfig = xbean:file:/conf/activemq.xml
>                 ServerUrl = tcp://localhost:61616
>     </Resource>
>
>   <Resource id="jms/ConnectionFactory" type="javax.jms.ConnectionFactory">
>                 connectionMaxIdleTime = 15 Minutes
>                 connectionMaxWaitTime = 5 seconds
>                 poolMaxSize = 10
>                 poolMinSize = 0
>                 resourceAdapter = MyJmsResourceAdapter
>                 transactionSupport = xa
>   </Resource>
>
> I am able to see the resource id "jms/ConnectionFactory" in tomee+ catalina
> log. I tried to get that instance in my application context file as
> follows,
> but instance (connectionFactory) was null.
>
> <jee:jndi-lookup id="connectionFactory" jndi-name="jms/ConnectionFactory"
> lookup-on-startup="false" proxy-interface="javax.jms.ConnectionFactory"/>
>
> private ConnectionFactory connectionFactory;
>
> Also added the following configuration in tomee+ web.xml and context.xml
> and
> tried , but i am unable to get that instance (
> connectionFactory)
>
> resource-ref>
>                 <description>JMS JNDI Connection</description>
>                 <res-ref-name>jms/ConnectionFactory</res-ref-name>
>                 <res-type>javax.jms.ConnectionFactory</res-type>
>                 <res-auth>Container</res-auth>
>         </resource-ref>
>
> Please let me know what's needs to be done to get the connectionFactory
> instance in my application.
>
> Thanks
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Tomme-and-JMS-with-JNDI-configuration-tp4679415p4679454.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>

Re: Tomme+ and JMS with JNDI configuration

Posted by sureshshine <su...@gmail.com>.
Thanks much for your reply.

I need one more clarification and added a jndi resource in tomee.xml as
follows,

<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
		BrokerXmlConfig = xbean:file:/conf/activemq.xml
		ServerUrl = tcp://localhost:61616
    </Resource>
	 
  <Resource id="jms/ConnectionFactory" type="javax.jms.ConnectionFactory">
		connectionMaxIdleTime = 15 Minutes
		connectionMaxWaitTime = 5 seconds
		poolMaxSize = 10
		poolMinSize = 0
		resourceAdapter = MyJmsResourceAdapter
		transactionSupport = xa
  </Resource> 

I am able to see the resource id "jms/ConnectionFactory" in tomee+ catalina
log. I tried to get that instance in my application context file as follows,
but instance (connectionFactory) was null.

<jee:jndi-lookup id="connectionFactory" jndi-name="jms/ConnectionFactory"
lookup-on-startup="false" proxy-interface="javax.jms.ConnectionFactory"/> 

private ConnectionFactory connectionFactory;

Also added the following configuration in tomee+ web.xml and context.xml and
tried , but i am unable to get that instance (
connectionFactory)

resource-ref>
		<description>JMS JNDI Connection</description>
		<res-ref-name>jms/ConnectionFactory</res-ref-name>
		<res-type>javax.jms.ConnectionFactory</res-type>
		<res-auth>Container</res-auth>
	</resource-ref> 

Please let me know what's needs to be done to get the connectionFactory
instance in my application.

Thanks




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Tomme-and-JMS-with-JNDI-configuration-tp4679415p4679454.html
Sent from the TomEE Dev mailing list archive at Nabble.com.

Re: Tomme+ and JMS with JNDI configuration

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

not sure if this jndi.properties is expected to work but tomee
configuration is intended to go in tomee.xml:
- http://tomee.apache.org/jms-resources-and-mdb-container.html
- http://tomee.apache.org/jmsconnectionfactory-config.html
- http://tomee.apache.org/ng/admin/configuration/resources.html


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-07-21 10:42 GMT+02:00 sureshshine <su...@gmail.com>:

> Hi All,
>
> I integrated ActiveMQ with Tomee+ and I tried to configure JMS connection
> by
> using jndi but it was not working.
>
> I created jndi.properties and placed that in webapps\activemq\WEB-INF\ ,
> ActiveMQ console war which is running in the tomee+
>
>
> java.naming.factory.initial =
> org.apache.activemq.jndi.ActiveMQInitialContextFactory
>
> # use the following property to configure the default connector
> #java.naming.provider.url = vm://localhost
> java.naming.provider.url = tcp://localhost:61616
>
> # use the following property to specify the JNDI name the connection
> factory
> # should appear as.
> connectionFactoryNames = connectionFactory, queueConnectionFactory,
> topicConnectionFactry
>
> # register some queues in JNDI using the form
> # queue.[jndiName] = [physicalName]
> queue.MyQueue = MyDestQueue
>
>
> # register some topics in JNDI using the form
> # topic.[jndiName] = [physicalName]
> #topic.MyTopic = example.MyTopic
>
> # END SNIPPET: jndi
>
> Please let know the where i need to add these configuration , in tomee+ or
> activemq war
>
> Thanks in Advance
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Tomme-and-JMS-with-JNDI-configuration-tp4679415.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>