1 Reply Latest reply on Oct 16, 2010 1:16 PM by Justin Bertram

    Does JBoss Messaging violate the JEE 5 Specification?

    Peer Bech Hansen Newbie

      Hi JBoss people

       

      For the project I’m currently working on, I’m trying to get JBoss Messaging to bridge messages from a JBoss queue to a IBM WebSphere MQ queue.

       

      I’m using IBM’s “WebSphere MQ resource adapter” and JCA administered objects to bind remote WMQ queues to my local JNDI.

       

      The guides I have followed, to configure the resource adaptor and to define my queues is found here:

      http://www.ibm.com/developerworks/websphere/library/techarticles/0710_ritchie/0710_ritchie.html

      http://community.jboss.org/wiki/UsingWebSphereMQSeriesWithJBossASPart4

       

      To Bridge the messages im using the org.jboss.jms.server.bridge.BridgeService MBean as shown below:

      <?xml version="1.0" encoding="UTF-8"?><server>
           <mbean code="org.jboss.jms.server.bridge.BridgeService"
                name="jboss.messaging:service=Bridge,name=WMQBridge"
                xmbean-dd="xmdesc/Bridge-xmbean.xml">
             
            <depends optional-attribute-name="SourceProviderLoader">jboss.messaging:service=JMSProviderLoader,name=JMSProvider</depends>  
            <depends optional-attribute-name="TargetProviderLoader">jboss.messaging:service=JMSProviderLoader,name=JMSWMQProvider</depends> 
            <attribute name="SourceDestinationLookup">queue/messagedistribution_contact_out</attribute>
            <attribute name="TargetDestinationLookup">queue/WMQTest_out</attribute>      
            <attribute name="QualityOfServiceMode">1</attribute>   
            <attribute name="MaxBatchSize">1</attribute>  
            <attribute name="MaxBatchTime">-1</attribute>   
            <attribute name="FailureRetryInterval">5000</attribute>         
            <attribute name="MaxRetries">-1</attribute>   
          </mbean>  
      </server>
      <?xml version="1.0" encoding="UTF-8"?>
      <server>
           <mbean code="org.jboss.jms.server.bridge.BridgeService"
                name="jboss.messaging:service=Bridge,name=WMQBridge"
                xmbean-dd="xmdesc/Bridge-xmbean.xml">
                
            <depends optional-attribute-name="SourceProviderLoader">jboss.messaging:service=JMSProviderLoader,name=JMSProvider</depends>     
            <depends optional-attribute-name="TargetProviderLoader">jboss.messaging:service=JMSProviderLoader,name=JMSWMQProvider</depends>    
            <attribute name="SourceDestinationLookup">queue/messagedistribution_contact_out</attribute> 
            <attribute name="TargetDestinationLookup">queue/WMQTest_out</attribute>         
            <attribute name="QualityOfServiceMode">1</attribute>      
            <attribute name="MaxBatchSize">1</attribute>     
            <attribute name="MaxBatchTime">-1</attribute>      
            <attribute name="FailureRetryInterval">5000</attribute>            
            <attribute name="MaxRetries">-1</attribute>      
          </mbean>          
      </server>
      

       

       

      When the bridging is performed i get the following error:

      10:15:06,820 WARN  [Bridge] jboss.messaging:name=WMQBridge,service=Bridge Failed to set up connections
      com.ibm.msg.client.jms.DetailedIllegalStateException: MQJCA1031: The method can only be called in the application client container. The application was not running in the application client container when this method was called.  Ensure that the application runs in the application client container, or modify the application to avoid this method call.
              at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:149)
              at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:86)
              at com.ibm.mq.connector.outbound.ConnectionWrapper.setExceptionListener(ConnectionWrapper.java:183)
              at org.jboss.jms.server.bridge.Bridge.setupJMSObjects(Bridge.java:1017)
              at org.jboss.jms.server.bridge.Bridge.setupJMSObjectsWithRetry(Bridge.java:1223)
              at org.jboss.jms.server.bridge.Bridge.access$1600(Bridge.java:68)
              at org.jboss.jms.server.bridge.Bridge$FailureHandler.run(Bridge.java:1569)
              at java.lang.Thread.run(Thread.java:619)
      

       

      The “WebSphere MQ resource adapter” fails; telling me that an illegal method has been called.

       

      On line 1017 and 1025 of the class org.jboss.jms.server.bridge.Bridge, the method setExceptionListener() is called on the JMS ConnectionFactory.

       

      On page 133 - 134 of the Java™ Platform, Enterprise Edition (Java EE) Specification, v5 (http://jcp.org/aboutJava/communityprocess/final/jsr244/index.html) it is clearly stated, that call to this method (and other methods), from web or EJB containers is prohibited.

       

      The “WebSphere MQ resource adapter” has implemented this restriction and throws an Exception if the method is call on their ConnectionFactory implementation.

       

      So the questions is:

      Isn’t JBoss Messaging violating the JEE5 specification, and how do I create a workaround for the problem?

       

      I have had the exact same error when using the JBoss ESB http://community.jboss.org/thread/156545

       

      Looking forward to hear your opinions.

       

      Kind regards

       

      Peer Bech Hansen

      Logica Denmark

       

       

       

      Environment used:

      Microsoft Windows XP SP3

      JBoss AS 5.1.0 GA

      JBoss Messaging 1.4.3 GA

        • 1. Re: Does JBoss Messaging violate the JEE 5 Specification?
          Justin Bertram Master

          JBoss AS can integrate with a foreign JMS provider in two different ways:

          1. Using a JMSProviderLoader MBean.  This method allows JBoss AS to integrate with any JMS provider that supports remote JMS clients via the standard JNDI pattern outlined in section 2.6.1 of the JMS 1.1 specification.  The JMSProviderLoader is a container-managed mechanism to configure the same parameters used by a remote, stand-alone client (e.g. InitialContext JNDI properties, connection factory name, etc.).
            • This method can be used by an MDB via the "providerAdapterJNDI" activation configuration property to consume messages, and it can be used in conjunction with a <tx-connection-factory> to send messages.
            • This method can also be used by a JMS bridge to move messages to/from the foreign JMS provider.
          1. Using the foreign provider's JCA resource adapter.

           

          These two methods are essentially mutually exclusive.  In other words, you can either use the JMSProviderLoader or you can use the provider's JCA RA, but you cannot use both.  It appears you have combined these two methods by configuring the bridge to use a JMSProviderLoader that is, in turn, configured to use a JCA JMS connection factory from the WebSphere MQ RA.  This is not valid.  The JMSProviderLoader cannot use a JCA JMS connection factory.  It must use a standard JMS connection factory just like any other remote client would.

          Isn’t JBoss Messaging violating the JEE5 specification...

           

          No.  The JBoss Messaging JMS bridge is not a Jave EE 5 component so it need not obey the Java EE specification.  It is free to set an ExceptionListener on its connection just like any other JMS client who is connecting to a remote provider would.  If you configure the bridge incorrectly to use a JCA JMS connection factory it will complain because the JCA connection factory is managed by the container and a client application is not allowed to set its own ExceptionListener on it.

           

           

          ...how do I create a workaround for the problem?

           

          Configure your integration correctly.