14 Replies Latest reply on Nov 24, 2003 7:36 PM by Adrian Brock

    jms and jndi lookup problem

    Chuck Harris Newbie

      I have been trying to post a message but get an error page instead. The attachment has the text of the post as well as logging.

        • 1. Re: jms and jndi lookup problem
          Adrian Brock Master

          You've broken jndi.properties or managed to
          get a bad one in the classpath.

          Regards,
          Adrian

          • 2. Re: jms and jndi lookup problem
            Adrian Brock Master

            To be explicit, do NOT specify a provider url inside the jboss
            server.

            If you want to access a resource on a remote server you
            should use a resource-ref that maps
            <jndi-name>jnp://remoteserver:1099/whatever</jndi-name>
            I think in your case you want it in jboss-web.xml

            Use search, I've posted examples many times.

            Regards,
            Adrian

            • 3. Re: jms and jndi lookup problem
              Chuck Harris Newbie

              I cannot get my messages to post so I have place my reply in the attachment. I tried rplacing all of the reserve character to no avail. Sorry.

              • 4. Re: jms and jndi lookup problem
                Adrian Brock Master

                The queue is just a name.
                Which JMS server you talk to depends upon how
                you lookup the connection factory.

                i.e. create a resource-ref for your connection factory.

                Regards,
                Adrian

                • 5. Re: jms and jndi lookup problem
                  Chuck Harris Newbie

                  Thanks again for all the help. I apologize for not getting this.
                  I have been reviewing the forums all over and am still beyond lost. Where does the

                  <resource-ref> go and what does it look like? Do i create separate file(s)(below) or can I

                  modify an existing file(jms-ds.xml)? I need to keep it out of the ear since the same code

                  moves between environments and I would rather not re-build at every promotion. That makes

                  using jboss-web.xml the least appealing option. I tried adding this as a jms-service.xml to

                  deploy:
                  <resource-ref>
                  <res-ref-name>javax.jms.QueueConnectionFactory</res-ref-name>
                  <jndi-name>jnp://myip:1099/queue/AFSP_Efiling</jndi-name> (and with /queue removed)
                  </resource-ref>
                  and:
                  <resource-ref>
                  <res-ref-name>javax.jms.ConnectionFactory</res-ref-name>
                  <jndi-name>jnp://myip:1099/queue/AFSP_Efiling</jndi-name> (and with /queue removed)
                  </resource-ref>
                  but the message was still processed locally.
                  I tried adding java.naming.provider.url=jnp://myip:1099 to jndi.properties of the web server

                  but the same errors were generated. Is there an example that you can point me to? This is

                  the last obstacle to moving from jboss 2.4 to 3.2.2 (that I am aware of :)).
                  I also tried changing the config file that the queue is pulled from. It was

                  queue/AFSP_Efiling and changed it to jnp://myip:1099/queue/AFSP_Efiling to no avail. I get

                  a:
                  16:09:20,307 ERROR [Thread-5] [afsp.messages.JMSMessageUtils] Could not create JNDI context:

                  \\myip:1099\queue\AFSP_Efiling not bound
                  javax.naming.NameNotFoundException: \\myip:1099\queue\AFSP_Efiling not bound
                  at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
                  Thanks

                  • 6. Re: jms and jndi lookup problem
                    Adrian Brock Master

                    resource-ref goes in ejb-jar.xml
                    and the jndi mappings for the resource-ref go in jboss.xml

                    Regards,
                    Adrian

                    • 7. Re: jms and jndi lookup problem
                      Chuck Harris Newbie

                      The queue name is the same in all env. The jndi is different though. Can they be placed in outside the application? Where would be best if so? Thanks for the help.

                      • 8. Re: jms and jndi lookup problem
                        Chuck Harris Newbie

                        I modified ejb-jar.xml to look like:
                        <?xml version="1.0"?>
                        <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
                        "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
                        <ejb-jar>
                        AFSP workflow engine
                        <display-name>WorkFlowEngine EJB</display-name>
                        <enterprise-beans>
                        <message-driven>
                        <ejb-name>WorkflowEngine</ejb-name>
                        <ejb-class>afsp.ejb.jms.WorkflowEngine</ejb-class>
                        <transaction-type>Container</transaction-type>
                        <message-driven-destination>
                        <destination-type>javax.jms.Queue</destination-type>
                        </message-driven-destination>
                        <env-entry>
                        <env-entry-name>requeueDelayInMillis</env-entry-name>
                        <env-entry-type>java.lang.String</env-entry-type>
                        <env-entry-value>10000</env-entry-value>
                        </env-entry>
                        <resource-ref>
                        <!-- <res-ref-name>queue/AFSP_Efiling</res-ref-name> -->
                        <res-ref-name>jnp://myip:1099/queue/AFSP_Efiling</res-ref-name>
                        <res-type>javax.jms.QueueConnectionFactory</res-type>
                        <res-auth>Container</res-auth>
                        </resource-ref>
                        </message-driven>
                        </enterprise-beans>
                        <assembly-descriptor>
                        <container-transaction>

                        <ejb-name>WorkflowEngine</ejb-name>
                        <method-name>*</method-name>

                        <trans-attribute>Required</trans-attribute>
                        </container-transaction>
                        </assembly-descriptor>
                        </ejb-jar>
                        and jboss.xml:
                        <?xml version="1.0"?>
                        <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN"
                        "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
                        <!-- Version: $Id: jboss.xml,v 1.6.2.4 2003/07/29 00:06:20 sreich Exp $ -->

                        <enterprise-beans>
                        <message-driven>
                        <ejb-name>WorkflowEngine</ejb-name>
                        <!-- destination-jndi-name>queue/AFSP_Efiling</destination-jndi-name> -->

                        <destination-jndi-name>jnp://myip:1099/queue/AFSP_Efiling</destination-jndi-name>

                        <configuration-name>Standard Message Driven Bean</configuration-name>
                        <resource-ref>

                        <res-ref-name>jnp://myip:1099/queue/AFSP_Efiling</res-ref-name>
                        <!-- <jndi-name>queue/AFSP_Efiling</jndi-name> -->

                        <jndi-name>QueueConnectionFactory</jndi-name>
                        </resource-ref>
                        </message-driven>
                        </enterprise-beans>

                        and the message is still processed locally on the web server rather than sent to the app
                        server. The client run from the command line on the web server sends the message to the
                        app. The client has a jndi.properties in the classpath that jboss does not (since it causes
                        exceptions galore). All that said, having the jndi name in the ear is not really the best
                        way since I'll have to have a separate build for every environment. Not that this was
                        working anyway. Did I get the files configured incorrectly? I tried building a web server
                        build that did not contain the mdb. That threw:

                        16:09:20,307 ERROR [Thread-5] [gov.ca.boe.afsp.messages.JMSMessageUtils] Could not create
                        JNDI context: \\168.71.206.252
                        :1099\queue\AFSP_Efiling not bound
                        javax.naming.NameNotFoundException: \\168.71.206.252:1099\queue\AFSP_Efiling not bound
                        at org.jnp.server.NamingServer.getBinding(NamingServer.java:495)
                        14:31:48,234 DEBUG [Thread-5] [gov.ca.boe.afsp.messages.JMSMessageUtils] Looking up
                        jnp://168.71.206.252/queue/AFSP_Efiling in JNDI
                        14:31:48,250 WARN [OIL Worker-0] [org.jboss.mq.il.oil.OILServerILService] Client request
                        resulted in a server exception:
                        javax.jms.InvalidDestinationException: This destination does not exist! QUEUE.AFSP_Efiling
                        at
                        org.jboss.mq.server.JMSDestinationManager.addMessage(JMSDestinationManager.java:401)
                        Any other ideas? Thanks for taking the time to look into this.

                        • 9. Re: jms and jndi lookup problem
                          Chuck Harris Newbie

                          I am still trying to get this to work without success and have been reading through the forums. I see there are others with similar problems. One thing, I noticed that there was a newer version of jboss3.2.2. I downloaded it and changed jndi.properties on the web server to java.naming.provider.url=appserverip:1099 and most of the exceptions in my previous post disappeared. That did not resolve the problem however. Adding :
                          <resource-ref>
                          <res-ref-name>QueueConnectionFactory</res-ref-name>
                          <jndi-name>jnp://appserverip:1099/queue/AFSP_Efiling</jndi-name>
                          </resource-ref>
                          to jboss.xml
                          and :
                          <resource-ref>
                          <res-ref-name>QueueConnectionFactory</res-ref-name>
                          <res-type>javax.jms.QueueConnectionFactory</res-type>
                          <res-auth>Container</res-auth>
                          </resource-ref>
                          to ejb-jar.xml is still processing the jms on the web server rather than sending the jms to the app server. At least the client run from the command line sends the message to the app server. Is there a way to first get this to work - that is send the message to the app server? And second - remove the jndi mapping from the ear/jar place it in a config file that can be specific for the dev\test\prod environment the application is running?

                          • 10. Re: jms and jndi lookup problem
                            Jon Barnett Master

                            Have you tried to generate a direct lookup via code?
                            e.g.

                            Properties jndiProps = new Properties();
                             jndiProps.setProperty(Context.INITIAL_CONTEXT_FACTORY,
                             "org.jnp.interfaces.NamingContextFactory");
                             jndiProps.setProperty(Context.URL_PKG_PREFIXES,
                             "org.jboss.naming:org.jnp.interface");
                             jndiProps.setProperty(Context.PROVIDER_URL, "jnp://appserverip:1099")
                             Object reference = (new InitialContext(jndiProps)).lookup
                             ("queue/AFSP_Efiling");


                            I guess you would use a getResourceAsStream() to read your configuration, placed in the appropriate package but I've never tried it from an EJB.

                            • 11. Re: jms and jndi lookup problem
                              Jon Barnett Master

                              That suggestion was merely one for a sanity check, not a permanent solution.

                              The two JBoss installations are at the same version level, right? Otherwise the JNDI lookup might break due to class UID/version differences.

                              • 12. Re: jms and jndi lookup problem
                                Chuck Harris Newbie

                                Both versions are the same.

                                • 13. Re: jms and jndi lookup problem
                                  Chuck Harris Newbie

                                  The problem was with the jndi lookup. It was written with the assumption that jndi.properties were set to the app server. Since 3.2.2 complains badly, Adding:
                                  Hashtable props = new Hashtable();
                                  props.put(Context.INITIAL_CONTEXT_FACTORY,
                                  "org.jnp.interfaces.NamingContextFactory");
                                  props.put(Context.PROVIDER_URL,
                                  "myip" + ":1099");
                                  ...
                                  jndiContext = new InitialContext(props);
                                  corrected the problem.

                                  • 14. Re: jms and jndi lookup problem
                                    Adrian Brock Master

                                    Your properties are missing
                                    Context.URL_PKG_PREFIXES
                                    or is that included in ...

                                    Certainly the \ in your debug statements above are incorrect
                                    for jndi.

                                    Regards,
                                    Adrian