8 Replies Latest reply on Jul 21, 2015 12:57 PM by chandrasachin16

    Issues facing while deploying MDB on JBOSS 7

    chandrasachin16

      Hi,

       

      I am trying to make my application run on JBOSS AS 7.1.1 which is already running on webspshere. While doing this task I found something strange.So just wanted to share if somebody knows about this-

       

      I have a jar file which has two MDB's(message driven bean) named JMSListner and JMSListner1.For the first mdb (JMSListner) I have used ejb-jar.xml for configuring the destination and for the second one (JMSListner1), I have used annotations for configuring destination.I deploy this jar having both the mdb and both gets started as listner which is perfect.I put message using my client application and both the MDB's receive message as they are listening to the same topic.

       

      But when I package this jar in a war file, I found something very strange.The MDB for which I used annotations only gets started but the other one which uses the ejb-jar.xml does not.

       

      Can anybody please explain me what exactly is the reason.

       

       

      Regards

      Sachin

        • 1. Re: Issues facing while deploying MDB on JBOSS 7
          wdfink

          Hello Sachin,

           

          do you have an example project to show the differences and to reproduce?

          This will be better that explaining further

           

          BTW 7.1 is quite old, could you do a quick check with WildFly 8 or 9 to check whether it is solved here?

          • 2. Re: Issues facing while deploying MDB on JBOSS 7
            chandrasachin16

            Hi,

             

            First of thanks for your reply.Given Below is the my code.

            My first MDB is as below-

            package com.te.sachin;

             

            import javax.jms.JMSException;

            import javax.jms.Message;

            import javax.jms.MessageListener;

            import javax.jms.TextMessage;

             

            public class JMSListner implements MessageListener {

             

                @Override

                public void onMessage(Message arg0) {

                    TextMessage msg = (TextMessage) arg0;

                    try {

                        System.out.println("message received in JMSListner-----" + msg.getText());

             

                    } catch (JMSException e) {

                        // TODO Auto-generated catch block

                        e.printStackTrace();

                    }

             

                }

             

            }

             

            And the ejb-jar.xml is as below--------------->>>>

            <ejb-jar id="ejb-jar_ID" version="3.1"

                  xmlns="http://java.sun.com/xml/ns/javaee"

                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

                                      http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">

             

                <enterprise-beans>

                    <message-driven>

                        <ejb-name>TextMDB</ejb-name>

                        <ejb-class>com.te.sachin.JMSListner</ejb-class>

                        <transaction-type>Container</transaction-type>

                           

                            <activation-config>

                                <activation-config-property>

                                  <activation-config-property-name>destinationType</activation-config-property-name>

                                  <activation-config-property-value>javax.jms.Topic</activation-config-property-value>

                                </activation-config-property>

                                <activation-config-property>

                                  <activation-config-property-name>destination</activation-config-property-name>

                                  <activation-config-property-value>java:jboss/exported/jms/topic/test</activation-config-property-value>

                                </activation-config-property>

                              </activation-config>

                   </message-driven>

                </enterprise-beans>

            </ejb-jar>

             

            The second MDB is as below------------>

             

            package com.te.sachin;

             

            import javax.ejb.ActivationConfigProperty;

            import javax.ejb.MessageDriven;

            import javax.jms.JMSException;

            import javax.jms.Message;

            import javax.jms.MessageListener;

            import javax.jms.TextMessage;

             

            @MessageDriven(activationConfig = {

                    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),

                    @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/exported/jms/topic/test"),

                    @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })

            public class JMSListner1 implements MessageListener {

             

                @Override

                public void onMessage(Message arg0) {

                    TextMessage msg = (TextMessage) arg0;

                    try {

                        System.out.println("Message Received in JMSListner1-----------"

                                + msg.getText());

             

                    } catch (JMSException e) {

                        // TODO Auto-generated catch block

                        e.printStackTrace();

                    }

             

                }

             

            }

             

            If u see both MDB are in the same package.The above ejb-jar.xml is in the META-INF folder.I have created a jar named MDBJar.jar and deployed in deployments folder.If you see the logs  below both of them get started.(I have highlighted in bold)

             

              JBoss Bootstrap Environment

             

              JBOSS_HOME: /home/sachin/InstalledSoftwares/JBOSS7/jboss-as-7.1.1.Final

             

              JAVA: java

             

              JAVA_OPTS:  -server -XX:+UseCompressedOops -XX:+TieredCompilation -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.server.default.config=standalone-full.xml

             

            =========================================================================

             

            22:47:43,123 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA

            22:47:43,269 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA

            22:47:43,311 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting

            22:47:44,247 INFO  [org.xnio] XNIO Version 3.0.3.GA

            22:47:44,253 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)

            22:47:44,266 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA

            22:47:44,280 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA

            22:47:44,319 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers

            22:47:44,352 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 32) JBAS016200: Activating ConfigAdmin Subsystem

            22:47:44,366 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 37) JBAS010280: Activating Infinispan subsystem.

            22:47:44,388 INFO  [org.jboss.as.jacorb] (ServerService Thread Pool -- 38) JBAS016300: Activating JacORB Subsystem

            22:47:44,423 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)

            22:47:44,455 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 49) JBAS011940: Activating OSGi Subsystem

            22:47:44,465 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 54) JBAS013101: Activating Security Subsystem

            22:47:44,475 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 48) JBAS011800: Activating Naming Subsystem

            22:47:44,532 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 58) JBAS015537: Activating WebServices Extension

            22:47:44,541 INFO  [org.jboss.as.connector] (MSC service thread 1-3) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final)

            22:47:44,566 INFO  [org.jboss.as.naming] (MSC service thread 1-7) JBAS011802: Starting Naming Service

            22:47:44,593 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]

            22:47:44,594 INFO  [org.jboss.as.security] (MSC service thread 1-8) JBAS013100: Current PicketBox version=4.0.7.Final

            22:47:44,649 INFO  [org.jboss.jaxr] (MSC service thread 1-7) JBAS014000: Started JAXR subsystem, binding JAXR connection factory into JNDI as: java:jboss/jaxr/ConnectionFactory

            22:47:44,836 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-7) JBoss Web Services - Stack CXF Server 4.0.2.GA

            22:47:44,866 WARN  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011600: AIO wasn't located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install LibAIO to enable the AIO journal

            22:47:44,955 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-8) Starting Coyote HTTP/1.1 on http-localhost-127.0.0.1-8080

            22:47:45,039 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=/home/sachin/InstalledSoftwares/JBOSS7/jboss-as-7.1.1.Final/standalone/data/messagingjournal,bindingsDirectory=/home/sachin/InstalledSoftwares/JBOSS7/jboss-as-7.1.1.Final/standalone/data/messagingbindings,largeMessagesDirectory=/home/sachin/InstalledSoftwares/JBOSS7/jboss-as-7.1.1.Final/standalone/data/messaginglargemessages,pagingDirectory=/home/sachin/InstalledSoftwares/JBOSS7/jboss-as-7.1.1.Final/standalone/data/messagingpaging)

            22:47:45,042 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) Waiting to obtain live lock

            22:47:45,128 INFO  [org.hornetq.core.persistence.impl.journal.JournalStorageManager] (MSC service thread 1-2) Using NIO Journal

            22:47:45,171 INFO  [org.jboss.as.jacorb] (MSC service thread 1-3) JBAS016330: CORBA ORB Service started

            22:47:45,380 INFO  [org.hornetq.core.server.impl.FileLockNodeManager] (MSC service thread 1-2) Waiting to obtain live lock

            22:47:45,381 INFO  [org.hornetq.core.server.impl.FileLockNodeManager] (MSC service thread 1-2) Live Server Obtained live lock

            22:47:45,402 INFO  [org.jboss.as.jacorb] (MSC service thread 1-5) JBAS016328: CORBA Naming Service started

            22:47:45,428 INFO  [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on localhost/127.0.0.1:4447

            22:47:45,429 INFO  [org.jboss.as.remoting] (MSC service thread 1-6) JBAS017100: Listening on /127.0.0.1:9999

            22:47:45,455 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) JBAS015012: Started FileSystemDeploymentService for directory /home/sachin/InstalledSoftwares/JBOSS7/jboss-as-7.1.1.Final/standalone/deployments

            22:47:45,498 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-5) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]

            22:47:45,935 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-2) Started Netty Acceptor version 3.2.5.Final-a96d88c localhost:5455 for CORE protocol

            22:47:45,936 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-2) Started Netty Acceptor version 3.2.5.Final-a96d88c localhost:5445 for CORE protocol

            22:47:45,938 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) Server is now live

            22:47:45,939 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) HornetQ Server version 2.2.13.Final (HQ_2_2_13_FINAL_AS7, 122) [5e679486-0c0e-11e5-aa2e-9c2a70d7155f]) started

            22:47:45,942 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-7) trying to deploy queue jms.topic.testTopic

            22:47:45,986 INFO  [org.jboss.as.messaging] (MSC service thread 1-7) JBAS011601: Bound messaging object to jndi name java:/topic/test

            22:47:45,988 INFO  [org.jboss.as.messaging] (MSC service thread 1-7) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/topic/test

            22:47:45,990 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-8) trying to deploy queue jms.queue.testQueue

            22:47:46,002 INFO  [org.jboss.as.messaging] (MSC service thread 1-8) JBAS011601: Bound messaging object to jndi name java:/queue/test

            22:47:46,007 INFO  [org.jboss.as.messaging] (MSC service thread 1-8) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/queue/test

            22:47:46,030 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory

            22:47:46,031 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:/RemoteConnectionFactory

            22:47:46,032 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory

            22:47:46,058 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-4) JBAS010406: Registered connection factory java:/JmsXA

            22:47:46,090 INFO  [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-4) HornetQ resource adaptor started

            22:47:46,091 INFO  [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-4) IJ020002: Deployed: file://RaActivatorhornetq-ra

            22:47:46,094 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-8) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]

            22:47:46,143 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015876: Starting deployment of "MDBJar.jar"

            22:47:46,496 INFO  [org.jboss.as.ejb3] (MSC service thread 1-6) JBAS014142: Started message driven bean 'JMSListner1' with 'hornetq-ra' resource adapter

            22:47:46,497 INFO  [org.jboss.as.ejb3] (MSC service thread 1-7) JBAS014142: Started message driven bean 'TextMDB' with 'hornetq-ra' resource adapter

            22:47:46,545 INFO  [org.jboss.as] (MSC service thread 1-8) JBAS015951: Admin console listening on http://127.0.0.1:9990

            22:47:46,546 INFO  [org.jboss.as] (MSC service thread 1-8) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 3636ms - Started 223 of 304 services (80 services are passive or on-demand)

            22:47:46,745 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "MDBJar.jar"

             

             

            But if I package this jar in a war which is simple servlet application then only JMSListner1 starts please see the logs below----------------------------------------->>>>>>

             

            22:55:17,434 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-4) Started Netty Acceptor version 3.2.5.Final-a96d88c localhost:5455 for CORE protocol

            22:55:17,437 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-4) Started Netty Acceptor version 3.2.5.Final-a96d88c localhost:5445 for CORE protocol

            22:55:17,438 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-4) Server is now live

            22:55:17,439 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-4) HornetQ Server version 2.2.13.Final (HQ_2_2_13_FINAL_AS7, 122) [5e679486-0c0e-11e5-aa2e-9c2a70d7155f]) started

            22:55:17,459 INFO  [org.jboss.as.messaging] (MSC service thread 1-4) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory

            22:55:17,466 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-2) trying to deploy queue jms.queue.testQueue

            22:55:17,474 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:/queue/test

            22:55:17,476 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/queue/test

            22:55:17,477 INFO  [org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) trying to deploy queue jms.topic.testTopic

            22:55:17,522 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:/topic/test

            22:55:17,523 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/topic/test

            22:55:17,525 INFO  [org.jboss.as.messaging] (MSC service thread 1-7) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory

            22:55:17,528 INFO  [org.jboss.as.messaging] (MSC service thread 1-7) JBAS011601: Bound messaging object to jndi name java:/RemoteConnectionFactory

            22:55:17,548 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-8) JBAS010406: Registered connection factory java:/JmsXA

            22:55:17,573 INFO  [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-8) HornetQ resource adaptor started

            22:55:17,574 INFO  [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-8) IJ020002: Deployed: file://RaActivatorhornetq-ra

            22:55:17,576 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-1) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]

            22:55:17,611 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015876: Starting deployment of "JMSServlet.war"

            22:55:18,075 INFO  [org.jboss.as.ejb3] (MSC service thread 1-2) JBAS014142: Started message driven bean 'JMSListner1' with 'hornetq-ra' resource adapter

            22:55:18,196 INFO  [org.jboss.web] (MSC service thread 1-3) JBAS018210: Registering web context: /JMSServlet

            22:55:18,203 INFO  [org.jboss.as] (MSC service thread 1-6) JBAS015951: Admin console listening on http://127.0.0.1:9990

            22:55:18,204 INFO  [org.jboss.as] (MSC service thread 1-6) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 3806ms - Started 223 of 304 services (80 services are passive or on-demand)

            22:55:18,374 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "JMSServlet.war"

             

            Regards

            Sachin

            • 3. Re: Issues facing while deploying MDB on JBOSS 7
              chandrasachin16

              Hi,

               

              I will also try the same with WildFly latest version.

               

              Regards

              Sachin

              • 4. Re: Issues facing while deploying MDB on JBOSS 7
                teacurran

                It seems like you are packaging it in a way that the annotation scanner isn't looking at your classes.

                In the second scenario, does it look like this:

                 

                app.war
                    |- WEB-INF
                        |- ejb-jar.xml
                        |- lib
                            |- beans.jar
                

                 

                or does it look like this?:

                app.war
                    |- WEB-INF
                        |- lib
                            |- beans.jar
                                |- ejb-jar.xml
                

                 

                If it is the first one, the scanner won't look in your beans.jar for annotations.

                • 5. Re: Issues facing while deploying MDB on JBOSS 7
                  chandrasachin16

                  Hi ,

                  It's exactly the same as you mentioned in the second scenario.My Packaging structure is as below-

                   

                  MyServlet.war

                            | - WEB-INF

                                     | -  lib

                                           | - MDB.jar

                                                       com.te.test.JMSListner.class

                                                       com.te.test.JMSListner1.class

                                                   | - META-INF

                                                             |- ejb-jar.xml

                   

                   

                  Regards

                  Sachin

                  • 6. Re: Issues facing while deploying MDB on JBOSS 7
                    jaikiran

                    Sachin Chandra wrote:

                     

                    Hi ,

                    It's exactly the same as you mentioned in the second scenario.My Packaging structure is as below-

                     

                    MyServlet.war

                              | - WEB-INF

                                       | -  lib

                                             | - MDB.jar

                                                         com.te.test.JMSListner.class

                                                         com.te.test.JMSListner1.class

                                                     | - META-INF

                                                               |- ejb-jar.xml

                     

                     

                    Regards

                    Sachin

                     

                     

                    EJB3.2 spec, section 15.4 says this:

                    A .war file may contain an ejb-jar.xml file. If present, the ejb-jar.xml is packaged as

                    WEB-INF/ejb-jar.xml. If an ejb-jar.xml is present, it applies to all enterprise beans defined

                    by the .war file, independently of whether they are packaged with the WEB-INF/classes direc-

                    tory or in a jar file within WEB-INF/lib directory. The packaging of an ejb-jar.xml file any-

                    where else within the .war file is not portable and may result in a deployment error.

                    So you should be placing that ejb-jar.xml in the WEB-INF folder of the .war

                    • 7. Re: Issues facing while deploying MDB on JBOSS 7
                      teacurran

                      I was curious so I tested it out.  It does indeed only work if the ejb-jar.xml is in WEB-INF/

                       

                      I checked in my code here: https://github.com/teacurran/java-experiments/tree/master/mdb-scanning if you want to try it out.

                      • 8. Re: Issues facing while deploying MDB on JBOSS 7
                        chandrasachin16

                        Hi ,

                         

                        Thanks a lot for the solution. It worked.

                         

                        Regards

                        Sachin

                        1 of 1 people found this helpful