Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: jms connection factory lookup troubles...

  1. #1
    Join Date
    Nov 2004
    Posts
    28

    Default jms connection factory lookup troubles...

    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.JndiObjectFactoryB ean">
    <property name="jndiName"><value>java:/ConnectionFactory</value></property>
    <property name="environment">
    <props>
    <prop key="java.naming.factory.initial">org.jnp.interfac es.NamingContextFactory</prop>
    <prop key="java.naming.provider.url">jnp://localhost:1099</prop>
    <prop key="java.naming.factory.url.pkgs">org.jboss.namin g: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

  2. #2
    Join Date
    Nov 2004
    Posts
    28

    Default Re: jms connection factory lookup troubles...

    Quote Originally Posted by lblaauw
    <property name="environment">
    <props>
    <prop key="java.naming.factory.initial">org.jnp.interfac es.NamingContextFactory</prop>
    <prop key="java.naming.provider.url">jnp://localhost:1099</prop>
    <prop key="java.naming.factory.url.pkgs">org.jboss.namin g: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

  3. #3
    Join Date
    Nov 2004
    Posts
    28

    Default

    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

  4. #4
    Join Date
    Nov 2004
    Posts
    28

    Default

    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

  5. #5
    Join Date
    Nov 2004
    Posts
    28

    Default Re: jms connection factory lookup troubles...

    Quote Originally Posted by lblaauw
    Quote Originally Posted by lblaauw
    <property name="environment">
    <props>
    <prop key="java.naming.factory.initial">org.jnp.interfac es.NamingContextFactory</prop>
    <prop key="java.naming.provider.url">jnp://localhost:1099</prop>
    <prop key="java.naming.factory.url.pkgs">org.jboss.namin g: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

  6. #6
    Join Date
    Nov 2004
    Posts
    28

    Default

    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.interfac es.NamingContextFactory</prop>
    <prop key="java.naming.provider.url">jnp://localhost:1099</prop>
    <prop key="java.naming.factory.url.pkgs">org.jboss.namin g: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

  7. #7
    Join Date
    Sep 2004
    Location
    San Diego, CA
    Posts
    49

    Default

    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
    Last edited by robyn; May 14th, 2006 at 05:05 PM.

  8. #8
    Join Date
    Nov 2004
    Posts
    28

    Default

    Quote Originally Posted by timmorrow
    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
    Last edited by robyn; May 14th, 2006 at 05:06 PM.

  9. #9
    Join Date
    Nov 2004
    Posts
    28

    Default

    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

  10. #10
    Join Date
    Nov 2004
    Posts
    28

    Default

    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

Similar Threads

  1. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  2. Replies: 1
    Last Post: Jul 28th, 2005, 05:08 PM
  3. Replies: 2
    Last Post: Jun 8th, 2005, 01:26 AM
  4. Troubles with a connection using HSQL
    By trilcejf in forum Data
    Replies: 1
    Last Post: Feb 10th, 2005, 08:40 AM
  5. Replies: 2
    Last Post: Aug 23rd, 2004, 09:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •