2 Replies Latest reply on Sep 16, 2004 4:22 PM by Darran Lofthouse

    Multiple Ear Files - Deploying message driven beans

    John DiGrazia Newbie

      I have two enterprise applications (i.e. 2 .ear files) that I need to
      deploy into a single JBoss server instance. I have two message driven
      beans that I need to deploy in each app. The two MDB instances are
      identical (package, class name, EJB name, etc.) with the exception of a
      couple of lines of code. Each MDB listens to separate MQs (as specified
      in their deployment descriptors).

      Once I deploy my to EAR files, I pump a message into queue #1 and MDB #1 gets called. If I pump a message into queue #2, MDB #1 still gets called. MDB #2 *never* gets called.

      How can this be given that MDB1 is configured to listen to Q1 and MDB2
      is configured to listen to Q2? Why does JBoss deliver messages from Q2
      to MDB1 for processing?

      Any help would be greatly appreciated.

        • 1. Re: how to create ejbSelect using Xdoclet
          Darran Lofthouse Master

          Thanks, timkk.

          Indeed it works fine when you just put in the <query-method> stuff into jbosscmp-jdbc.xml by hand. For some reason XDoclet does not generate this for you with ejbSelect methods, while it does so for ejbFind. (Could this be a bug in XDoclet? or am I using the wrong tags?)

          If you're using Eclipse as your IDE you could use the Lomboz and/or JBoss IDE plugins. They both user XDoclet under the hood. It shields you somewhat from the daunting XDoclet and ANT configs you would need otherwise and they both integrate nicely with Eclipse. For an J2EE starter like me Lomboz/Eclipse makes for a good pair.

          On the Double / Integer issue I must correct myself; you are right! JBoss *does* seem to map a Double java type on the SQL INT type configured in the deployment descriptor and EJB class. Really anoying.

          I did not notice this until now since I had not proceeded yet to the point that I actually received a valid object back from the ejbSelect without JBoss throwing exceptions at me about my EJB-QL. And in the Lomboz/XDoclet generated interfaces and deployment descriptors all seemed fine. The last exception I had to fix was a ClasscastException at the point where the ejbSelect was called ; - ) The returned type indeed was Double instead of Integer.

          I solves this by casting the Double returned by the ejbSelect into an Integer in my wrapper home method, which I need anyway, since the ejbSelect is only visible to EJB's and normally you'd like it exposed to the outside world:

          /**
           * @ejb.select
           * query="SELECT MAX(m.myPrimKey) FROM MyTable AS m"
           * @jboss.query
           * query="SELECT MAX(m.myPrimKey) FROM MyTable AS m"
           */
          abstract public Double ejbSelectMyPrimKey() throws FinderException;
          
          /**
           * @ejb.home-method
           * view-type="local"
           */
          public static Integer ejbHomeGetNextPrimKey() throws Exception {
           int nextKey = 1 + ejbSelectMyPrimKey().intValue();
           return new Integer(nextKey);
          }


          Now the method getNextPrimKey() can be called on the (local) home object of the EJB to find the next primary key to be used in the create() method. Ofcourse you need to wrap getNextPrimKey() and create() in a user transaction to ensure concurrent inserts into your database succeed.

          I guess all this pretty much answer your question too, Ben!

          Cheers,
          Frank

          • 2. Re: Multiple Ear Files - Deploying message driven beans
            Chuck Harris Newbie

            post your jboss.xml and ejb-jar.xml for each mdb.