4 Replies Latest reply on Jan 11, 2005 12:44 PM by Jens Mueller

    Docs\examples\ejb\simplemessage

    Andrej Tibaut Newbie

      I work on the simplemessage MDB example (in Docs\examples\ejb\ from jbossj2ee-src.zip). Originally the SimpleMessage.ear contains mdb-app-client.jar and the code in the client is:

      connectionFactory = (ConnectionFactory) jndiContext.lookup
       ("java:comp/env/jms/QueueConnectionFactory");
      
      destination = (Queue) jndiContext.lookup("java:comp/env/jms/QueueName");
      


      I want to separate the mdb-app-client.jar from SimpleMesage.ear part so that I can run them on different machines: MDB within the JBOSS 4.0 and the client on another machine without JBoss.
      I have removed mdb-client-jar from the SimpleMessage.ear, changed
      the lines:
      connectionFactory = (ConnectionFactory) jndiContext.lookup("jms/QueueConnectionFactory");
      destination = (Queue) jndiContext.lookup("avrisQueue");
      


      and I got the following error message:

      JNDI lookup failed: javax.naming.NameNotFoundException: jms not bound


      What am I doing wrong?
      Please help!?

        • 1. Re: Docs\examples\ejb\simplemessage
          Andrej Tibaut Newbie

          Here are also my configuration files:

          CLIENT:

          jboss-client.xml:

          <jboss-client>
           <jndi-name>SimpleMessageClient</jndi-name>
          
           <resource-ref>
           <res-ref-name>jms/QueueConnectionFactory</res-ref-name>
           <jndi-name>XAConnectionFactory</jndi-name>
           </resource-ref>
          
           <resource-env-ref>
           <resource-env-ref-name>jms/QueueName</resource-env-ref-name>
           <jndi-name>queue/avrisQueue</jndi-name>
           </resource-env-ref>
          
          </jboss-client>


          application-client.xml:

          <display-name>MyAppClient</display-name>
          
           <resource-ref>
           <res-ref-name>jms/QueueConnectionFactory</res-ref-name>
           <res-type>javax.jms.ConnectionFactory</res-type>
           <res-auth>Container</res-auth>
           <res-sharing-scope>Shareable</res-sharing-scope>
           </resource-ref>
          
           <resource-env-ref>
           <resource-env-ref-name>jms/QueueName</resource-env-ref-name>
           <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
           </resource-env-ref>
          

          MDB:

          jboss.xml:

          <jboss>
           <enterprise-beans>
           <message-driven>
           <ejb-name>SimpleMessageEJB</ejb-name>
           <destination-jndi-name>queue/avrisQueue</destination-jndi-name>
           </message-driven>
           </enterprise-beans>
          </jboss>
          


          ejb-jar.xml:

          <ejb-jar>
           <display-name>SimpleMessageJAR</display-name>
          
           <enterprise-beans>
           <message-driven>
           <display-name>SimpleMessageEJB</display-name>
           <ejb-name>SimpleMessageEJB</ejb-name>
           <ejb-class>si.avris.centrala.MessageBean</ejb-class>
           <transaction-type>Container</transaction-type>
           <message-driven-destination>
           <destination-type>javax.jms.Queue</destination-type>
           </message-driven-destination>
           </message-driven>
           </enterprise-beans>
          </ejb-jar>


          • 2. Re: Docs\examples\ejb\simplemessage
            Elias Ross Master

            What is your JNDI conf. on your client?

            • 3. Re: Docs\examples\ejb\simplemessage
              Andrej Tibaut Newbie

              Here is my jndi.properties:

              java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
              java.naming.provider.url=jnp://localhost:1099
              java.naming.factory.url.pkgs=org.jboss.naming.client
              j2ee.clientName=si.avris.prevoznik.SimpleMessageClient


              But in the mean time I have the solution. Look to the previous client code:

              connectionFactory = (ConnectionFactory) jndiContext.lookup("jms/QueueConnectionFactory");
              destination = (Queue) jndiContext.lookup("avrisQueue");
              


              The working version has queue/avrisQueue instead of avrisQueue:

              connectionFactory = (ConnectionFactory) jndiContext.lookup("jms/QueueConnectionFactory");
              destination = (Queue) jndiContext.lookup("queue/avrisQueue");



              And now it works. I think my example (client running outside JBoss and MDB running within JBoss) is more common for real situations where one programmer works on client code while another one works on the EJB code.

              I have one more question.
              I have seen examples where people use jndi properties in different ways.
              My setting is the default one (from Getting started example):
              java.naming.provider.url=jnp://localhost:1099


              Where on the JBoss is the port 1099 specified?




              • 4. Re: Docs\examples\ejb\simplemessage
                Jens Mueller Newbie

                Hi there,

                the JNDI Port (default 1099) is specified in your servers conf directory
                in the file jboss-service.xml.
                I had to change that due to conflicts with my virus protection software.

                Rgds

                Jens