2 Replies Latest reply on Dec 4, 2008 6:20 AM by je le

    pb : having a jboss service depending on jms or NamingContex

    je le Newbie

      hi,

      I have an entreprise application build like this :
      - an ejb module, with a jboss service (@service @management annotation), and a mdb
      - a war module with a servlet and a webservice

      Only use annotation ; jboss 4.2.1.GA, jdk 1.6.0.10 x64, linux, netbeans 6.1

      At startup, the start method of my jboss service trigger a mdb to do some loading process in the background.
      When hot deploying, no problems, everything fine.
      On cold start up (of jboss...), I'm getting a javax.naming.NameNotFoundException. Because my service start before the jms queue, the context cannot create my queue. Look simple, well... not :-)

      My problem is I'm cannot get @Depend annotation working. Actually, i cannot find doc on the subject. The closer is this one :
      http://www.jboss.org/file-access/default/members/jbossmc/freezone/docs/2.0.x/userGuide/ch12s03.html
      I looked at the xml config files, the jmx console, the jndi view...

      1) is this annotation working in this case ???
      2) what is the name of the bean responsible of creating "queue/jms" !?!!?

      Some part of my code :

      @Service(name = "FilterServiceBean", objectName = "org.filter.ejb:name=FilterServiceBean,type=ManagementInterface")
      @Local(FilterServiceBeanLocal.class)
      @Remote(FilterServiceBeanRemote.class)
      @Management(FilterServiceBeanManagement.class)
      @Depends("jboss.mq:service=JMSProviderLoader,name=HAJNDIJMSProvider")
      //@Depends("jboss.jms:alias=QueueConnectionFactory")
      //@Depends("jboss:service=Naming")
      public class FilterServiceBean implements FillterServiceBeanRemote, FilterServiceBeanLocal, FilterServiceBeanManagement {
      //...
      public static final String BUILDMESSAGEQUEUE = "queue/jms/MyFilter";
      private Queue queue = null;
      private QueueConnectionFactory factory = null;
      //...
      public void start() throws Exception {
       // *** call an mdb
       InitialContext ctx = new InitialContext();
       queue = (Queue) ctx.lookup(BUILDMESSAGEQUEUE);
       factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
       //...
       connection = factory.createQueueConnection();
       session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
       messageProducer = session.createProducer(queue);
       //...
       }
      
      //...
      }
      


      the exception : (I'm using a singleton - RebuildPostman -, pushed his code into the start method below to make thinks simple :-) )
      14:14:12,439 ERROR [STDERR] javax.naming.NameNotFoundException: jms not bound
      14:14:12,439 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
      14:14:12,439 ERROR [STDERR] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
      14:14:12,439 ERROR [STDERR] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
      14:14:12,439 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
      14:14:12,439 ERROR [STDERR] at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
      14:14:12,440 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
      14:14:12,440 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:589)
      14:14:12,440 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:392)
      14:14:12,440 ERROR [STDERR] at org.filter.mdb.RebuildPostman.<init>(RebuildPostman.java:35)
      14:14:12,440 ERROR [STDERR] at org.filter.mdb.RebuildPostman.getInstance(RebuildPostman.java:45)
      14:14:12,440 ERROR [STDERR] at org.filter.ejb.FilterServiceBean.start(FilterServiceBean.java:136)
      


      Thks.

        • 1. Re: pb : having a jboss service depending on jms or NamingCo
          jaikiran pai Master

          How about doing this:
          - Create a *-service.xml to define/configure the queue. For ex: myqueue-service.xml
          - Package this myqueue-service.xml at the root of the EAR.
          - Create a jboss-app.xml under the META-INF folder of the EAR with the following contents:

          <jboss>
          <module>
           <service>myqueue-service.xml</service>
           </module>
          </jboss>


          • 2. Re: pb : having a jboss service depending on jms or NamingCo
            je le Newbie

             

            "jaikiran" wrote:
            How about doing this:
            - Create a *-service.xml to define/configure the queue. For ex: myqueue-service.xml
            - Package this myqueue-service.xml at the root of the EAR.
            - Create a jboss-app.xml under the META-INF folder of the EAR with the following contents:

            <jboss>
            <module>
             <service>myqueue-service.xml</service>
             </module>
            </jboss>


            hi,
            thanks for your help.
            i were looking for this solution without succes, and in fact netbeans does expose a service.xml but do not include it in the jboss-app.xml neither in the ear !?! pb solved, thks :-) )

            after looking at jbossmq-destinations-service.xml sample I tried some more test with @depends and finally made my service depend on my..... mdb . ok, i know, now it's obvious !

            thks