View Full Version : jms connection factory lookup troubles...
lblaauw
Nov 18th, 2004, 08:03 AM
Hi all,
I have been trying today to lookup the JMS connection factory on my local JBOSS server to use it from the JMS template via Spring...
Not much luck so far basically it says connection factory not bound, so it seems it cannot find it...
I tried following some posts on this forum to set the properties of the environement in the applicationContext.xml as follows to resolve this problem:
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"><value>java:/ConnectionFactory</value></property>
<property name="environment">
<props>
<prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
<prop key="java.naming.provider.url">jnp://localhost:1099</prop>
<prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
</props>
</property>
<property name="resourceRef"><value>true</value></property>
</bean>
As per one of the posts in this forum, but then it throws an exception stating environment property cannot be written to ??
This is a stand allone java application so not much use using web.xml to pass in jndi references etc..
Hopefully somebody will have some suggestions or examples on how to get a stand allone java appliation to talk JMS trough to JBOSS MQ
THanks and sincere greetings,
Leo de Blaauw
lblaauw
Nov 18th, 2004, 08:27 AM
<property name="environment">
<props>
<prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
<prop key="java.naming.provider.url">jnp://localhost:1099</prop>
<prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
</props>
</property>
Ah well,
It seems like the property environment is changed to jndiEnvironment in my version 1.1.1 of Spring....
Still says ConnectionFactory not bound....
Any ideas suggestions welcome !
Sincere greetings,
Leo de Blaauw
lblaauw
Nov 18th, 2004, 08:35 AM
hmm
Well learning along the way here so i figured i just post my findings....
Seems resourceref must be set to false, if not it will automatically add:
java:/comp/env to your JNDI lookup via Spring.
As i said learning along the way. Next problem:
java.lang.NoSuchMethodError: javax.jms.ConnectionFactory.createConnection()Ljav ax/jms/Connection;
I will post any findings or any help still appreciated lol
Greetings,
Leo de Blaauw
lblaauw
Nov 18th, 2004, 09:23 AM
Well,
After changing to JNDITemplate102( yes i know i should have read it !) it all works like a dream !!
Thanks guys for this great framework !!
Sincere greetings,
Leo de Blaauw
lblaauw
Nov 19th, 2004, 02:51 AM
<property name="environment">
<props>
<prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
<prop key="java.naming.provider.url">jnp://localhost:1099</prop>
<prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
</props>
</property>
Ah well,
It seems like the property environment is changed to jndiEnvironment in my version 1.1.1 of Spring....
Still says ConnectionFactory not bound....
Any ideas suggestions welcome !
Sincere greetings,
Leo de Blaauw
Hmm thats too bad the above jndiEnvironment settings dont seem to get picked up by the client appliation. It seems i still need a jndi.properties in the classpath ??
Any suggestions on how to get these props into the spring applicationContext ?
Greetz
Leo de Blaauw
lblaauw
Nov 19th, 2004, 09:08 AM
Well,
I got rid of jndi.properties in the claspath. Only thing now is that i have
to define:
<property name="jndiEnvironment">
<props>
<prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
<prop key="java.naming.provider.url">jnp://localhost:1099</prop>
<prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
</props>
</property>
For both my connectionFactory and the queue on the lookup hmmm
Wouldnt there be a better global way to instantiate these environment properties so that both JndiObjectFactoryBeans could pick them up ?
Wel let me know, but it seems activity on this forum on JMS is pretty low unfortunately. When i do figur it out i will post my solution in this thread
Greetz
Leo de Blaauw
timmorrow
Nov 19th, 2004, 12:38 PM
You seem to be doing a pretty good job of figuring things out!
You can define the environment once. Define a org.springframework.jndi.JndiTemplate then pass that to the jndiTemplate property of each of your JndiObjectFactoryBean instances.
When running in an app server, you can also avoid specifying any of the server's jndi properties at all. You'll need to define your JNDI resource in web.xml and jboss-web.xml. You can then leave resourceRref set to true and Spring will look it up from the container's environment. See this thread for examples: http://forum.springframework.org/showthread.php?t=10207
Tim
lblaauw
Nov 19th, 2004, 12:50 PM
You seem to be doing a pretty good job of figuring things out!
You can define the environment once. Define a org.springframework.jndi.JndiTemplate then pass that to the jndiTemplate property of each of your JndiObjectFactoryBean instances.
When running in an app server, you can also avoid specifying any of the server's jndi properties at all. You'll need to define your JNDI resource in web.xml and jboss-web.xml. You can then leave resourceRref set to true and Spring will look it up from the container's environment. See this thread for examples: http://forum.springframework.org/showthread.php?t=10207
Tim
Tim,
Thanks, getting there. Thing is i want to be able to run my junit tests outside of the jboss server just as inside. So inside is not much of a problem but outside is. Usually what i have done so far is a different applicationContext.xml for the unit tests...
hmm i tried to put a JndiTemplate in my applicationContext file and to set its property called jndiEnvironment with the same props definition i used earlier... but it says in and exception cannot write property jndiEnvironment
Weird.. oh well i will keep on tryin lol
Greetrz
Leo
Greetz
Leo
lblaauw
Nov 19th, 2004, 01:20 PM
Well
It works !!! Offcourse the property on the JNDITemplate is environment !!!
and not jndiEnvironment anymore ;-)
Works like a charm, thanks for putting me in the right direction here Tim
appreciated
Greetz
Leo
lblaauw
Nov 22nd, 2004, 12:33 PM
hmm,
The next challenge, our should i say thing to figur out, will be to create a message converter for the JMSTemplate using castor....
I will keep you updated here.
Greetz
Leo de Blaauw
lblaauw
Nov 22nd, 2004, 02:48 PM
hmm,
The next challenge, our should i say thing to figur out, will be to create a message converter for the JMSTemplate using castor....
I will keep you updated here.
Greetz
Leo de Blaauw
Ok, done castor is now used to serialize our objects onto JMS queues using the JMSTemplate with a Castor converter, tomorrow i will do the read from the message queue convert stuff
Let me know if i need to post how
Greetz
Leo de Blaauw
magpor
Nov 19th, 2005, 04:25 AM
Well,
After changing to JNDITemplate102( yes i know i should have read it !) it all works like a dream !!
Thanks guys for this great framework !!
Sincere greetings,
Leo de Blaauw
Hey Leo
Im having the same problem as you and your saying that using JNDITemplate102 solved it but I cant find it! Has it been replaced or is there some otherway I can connect to JBoss MQ?
Appriciate your help,thx
Maghnus
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.