10 Replies Latest reply on Apr 6, 2004 8:49 AM by kshiv2001

    JBOSS with OpenJMS

    rg

      Hello,

      I am trying to use OpenJMS as the JMS provider. Not sure whether what I am doing is correct as while trying to connect to the OpenJMS provider the JBOSS server hangs while creating a DLQHandler, looks like it is able to connect to the remote provider though:

      These are the messages:
      15:45:30,847 INFO [JMSProviderLoader] Bound adapter to java:/RemoteJMSProvider
      15:45:30,847 INFO [JMSProviderLoader] Started
      15:45:30,877 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/all/deploy/jms/openjms-service.xml
      15:45:34,591 INFO [DLQHandler] Destroying
      15:45:34,591 INFO [DLQHandler] Destroyed
      15:45:34,591 INFO [DLQHandler] Creating

      Here are my configurations:
      A file openjms_service.xml in all/deploy/jms:

      RemoteJMSProvider
      remote ip addr:1099
      org.jboss.jms.jndi.JBossMQProvider
      XAConnectionFactory
      XAConnectionFactory


      I have added following in standardjboss.xml in all\conf:
      <invoker-proxy-binding>
      remote-message-driven-bean
      <invoker-mbean>default</invoker-mbean>
      <proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-factory>
      <proxy-factory-config>
      RemoteJMSProvider
      StdJMSPool
      15
      1

      10

      queue2
      10
      0


      </proxy-factory-config>
      </invoker-proxy-binding>


      Would appreciate any help ...Thanks.

        • 1. Re: JBOSS with OpenJMS
          rg

          And I am using JBOSS 3.2.1

          • 2. Re: JBOSS with OpenJMS

            No, the problem is in your jndi.
            The first thing looked up is the DLQ queue.
            Is remote:1099 a valid jndi provider url for OpenJMS,
            looks like a jboss jnp url to me.

            Why do you want to use OpenJMS, it doesn't even support
            XA last time I checked.

            Regards,
            Adrian

            • 3. Re: JBOSS with OpenJMS
              rg

              Thanks for replying Adrian.

              I haven't given the actual ip address above in the post. I am able to test simple queue sender and receiver programs from a remote machine, I use rmi://remote ip adrress:1099 to access it from the simple programs.

              When I specify providerUrl as 'rmi://remote ip adrress:1099' or 'rmi:/remote ip address' to access in the openjms_service.xml that I have created it gives me an error not able to connect to "rmi:1099", and it takes only the 'ip address:1099' there. The reason I am saying that JBOSS is able to connect to the OpenJMS server because while the JBOSS server hangs at 'DLQ Handler' and I terminate the OpenJMS server on the remote machine, the JBOSS server starts giving messages that 'lost connection with JMS provider' and goes in a reconnect loop, if I bring up the OpenJMS server again it again hangs at DLQ handler.

              Eventually we will be using MQSeries (Websphere MQ 5.3 now) as that is our client/project requirement, but we were having some problem while installing the trial version of MQSeries on Linux Suse8.2 in our development environment. It will take some time to get a licensed copy of it and resolve the whole issue and we need to go ahead with application/services development, where we need to demonstrate that we can use third party JMS provider with our application services hosted on JBOSS, therefore OpenJMS is a stop gap arrangement for us.

              Thanks again for any help.

              • 4. Re: JBOSS with OpenJMS

                Create your own MBean that uses the correct jndi properties.
                Here is jboss's that you are using which connects to jnp://.

                Regards,
                Adrian

                /*
                * Copyright (c) 2000 Peter Antman DN <peter.antman@dn.se>
                *
                * This library is free software; you can redistribute it and/or
                * modify it under the terms of the GNU Lesser General Public
                * License as published by the Free Software Foundation; either
                * version 2 of the License, or (at your option) any later version
                *
                * This library is distributed in the hope that it will be useful,
                * but WITHOUT ANY WARRANTY; without even the implied warranty of
                * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
                * Lesser General Public License for more details.
                *
                * You should have received a copy of the GNU Lesser General Public
                * License along with this library; if not, write to the Free Software
                * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
                */
                package org.jboss.jms.jndi;

                import java.util.Hashtable;

                import javax.naming.Context;
                import javax.naming.InitialContext;
                import javax.naming.NamingException;

                import org.jboss.logging.Logger;

                /**
                * A JMS provider adapter for JBossMQ.
                *
                * Created: Fri Dec 22 09:34:04 2000
                * 6/22/01 - hchirino - The queue/topic jndi references are now configed via JMX
                *
                * @version $Revision: 1.9 $
                * @author Peter Antman
                * @author Hiram Chirino
                * @author Jason Dillon
                */
                public class JBossMQProvider
                extends AbstractJMSProviderAdapter
                {
                /** The initial context factory to use. */
                public static final String INITIAL_CONTEXT_FACTORY =
                "org.jnp.interfaces.NamingContextFactory";

                /** The url package prefixes. */
                public static final String URL_PKG_PREFIXES =
                "org.jboss.naming";

                /** The security manager to use. */
                private static final String SECURITY_MANAGER =
                "java.naming.rmi.security.manager";

                /** Instance logger. */
                private transient Logger log = Logger.getLogger(this.getClass());

                /** Flag to enable JNDI security manager. */
                private String hasJndiSecurityManager = "yes";

                /**
                * Default no-argument constructor.
                */
                public JBossMQProvider() {
                // empty
                log.debug("initializing");
                }

                /** Override of standard de-serialization to re-create logger. */
                private void readObject(java.io.ObjectInputStream in)
                throws java.io.IOException, ClassNotFoundException
                {
                in.defaultReadObject();
                this.log = Logger.getLogger(this.getClass());
                }

                /**
                * Create a new InitialContext suitable for this JMS provider.
                *
                * @return An InitialContext suitable for this JMS provider.
                *
                * @throws NamingException Failed to construct context.
                */
                public Context getInitialContext() throws NamingException {
                Context ctx = null;
                boolean debug = log.isDebugEnabled();
                if (providerURL == null) {
                // Use default
                if (debug)
                log.debug("no provider url; connecting to local JNDI");
                ctx = new InitialContext(); // Only for JBoss embedded now
                } else {
                // Try another location
                Hashtable props = new Hashtable();
                props.put(Context.INITIAL_CONTEXT_FACTORY,
                INITIAL_CONTEXT_FACTORY);
                props.put(Context.PROVIDER_URL, providerURL);
                props.put(SECURITY_MANAGER, hasJndiSecurityManager);
                props.put(Context.URL_PKG_PREFIXES, URL_PKG_PREFIXES);

                if (debug)
                log.debug("connecting to remote JNDI with props: " + props);
                ctx = new InitialContext(props);
                }

                if (debug) {
                log.debug("created context: " + ctx);
                }
                return ctx;
                }
                }

                • 5. Re: JBOSS with OpenJMS
                  rg

                  Adrian,

                  As per you advice, I wrote my own JMS provider class extending AbstractJMSProvider, please look at the attached file. Using that, the attached service file and the changes in the standardjboss.xml I am able to establish connectivity between JBOSS and OpenJMS.

                  But when I send a message a queue in OpenJMS I get a classcast exception while receiving the message in JBOSS even before it reaches to the MDB. From the messages I think what is happening is that the OpenJMS classes are trying to consume the message instead of JBOSS classes and one of the OepnJMS class tries to cast a session (I think from the standard session pool, StdJMSPool) to its own session class and there it throws an exception.

                  I am wondering why should OpenJMS class try to consume the messages. FYI, I had to put two OpenJMS jars in the all/lib as the initial context factory classes are contained in them and also the queue connection factory and topic connection factory classes that are specified in the attached service.xml.

                  Here are the messages while exception:
                  14:07:49,854 INFO [DLQHandler] Creating
                  14:07:53,068 INFO [DLQHandler] Created
                  14:07:55,350 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:07:56,101 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:07:56,792 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:07:57,402 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:07:57,963 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:07:58,544 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:07:59,194 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:07:59,775 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:08:00,676 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:08:01,277 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:08:02,198 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:08:02,798 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:08:03,359 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:08:03,949 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:08:04,580 WARN [StdServerSessionPool] Using a non-XA QueueConnection. It will not be able to participate in a Global UOW
                  14:08:05,491 INFO [DLQHandler] Starting
                  14:08:05,491 INFO [DLQHandler] Started
                  14:08:07,013 INFO [JMSContainerInvoker] Started
                  14:08:07,013 INFO [MessageDrivenInstancePool] Starting
                  14:08:07,013 INFO [MessageDrivenInstancePool] Started
                  14:08:07,013 INFO [MessageDrivenContainer] Started
                  14:08:07,013 INFO [EjbModule] Started
                  14:08:07,013 INFO [EJBDeployer] Deployed: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/all/deploy/OpenJMSEJBModule.jar
                  14:08:07,093 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/all/deploy/OpenJMSEJBModule.jar
                  14:08:07,093 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/all/deploy/jmx-console.war/
                  14:08:07,423 INFO [EmbeddedCatalinaService41] deploy, ctxPath=/jmx-console, warUrl=file:/C:/jboss-3.2.1_tomcat-4.1.24/server/all/deploy/jmx-console.war/
                  14:08:07,493 INFO [Engine] WebappLoader[/jmx-console]: Deploying class repositories to work directory C:\jboss-3.2.1_tomcat-4.1.24\server\all\tmp\deploy\server\all\deploy\work\MainEngine\localhost\jmx-console
                  14:08:07,503 INFO [Engine] WebappLoader[/jmx-console]: Deploy class files /WEB-INF/classes to C:\jboss-3.2.1_tomcat-4.1.24\server\all\deploy\jmx-console.war\WEB-INF\classes
                  14:08:07,513 INFO [Engine] WebappLoader[/jmx-console]: Deploy JAR /WEB-INF/lib/jboss-jmx.jar to C:\jboss-3.2.1_tomcat-4.1.24\server\all\deploy\jmx-console.war\WEB-INF\lib\jboss-jmx.jar
                  14:08:09,195 INFO [Engine] ContextConfig[/jmx-console]: Added certificates -> request attribute Valve
                  14:08:09,525 INFO [EmbeddedCatalinaService41] Using Java2 parent classloader delegation: true
                  14:08:09,525 INFO [Engine] StandardManager[/jmx-console]: Seeding random number generator class java.security.SecureRandom
                  14:08:09,525 INFO [Engine] StandardManager[/jmx-console]: Seeding of random number generator has been completed
                  14:08:09,535 INFO [Engine] StandardWrapper[/jmx-console:default]: Loading container servlet default
                  14:08:09,535 INFO [Engine] StandardWrapper[/jmx-console:invoker]: Loading container servlet invoker
                  14:08:09,585 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/all/deploy/jmx-console.war/
                  14:08:09,595 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/all/deploy/management/web-console.war
                  14:08:10,056 INFO [EmbeddedCatalinaService41] deploy, ctxPath=/web-console, warUrl=file:/C:/jboss-3.2.1_tomcat-4.1.24/server/all/tmp/deploy/server/all/deploy/management/web-console.war/55.web-console.war
                  14:08:10,136 INFO [Engine] WebappLoader[/web-console]: Deploying class repositories to work directory C:\jboss-3.2.1_tomcat-4.1.24\server\all\tmp\deploy\server\all\deploy\work\MainEngine\localhost\web-console
                  14:08:10,176 INFO [Engine] WebappLoader[/web-console]: Deploy class files /WEB-INF/classes to C:\jboss-3.2.1_tomcat-4.1.24\server\all\tmp\deploy\server\all\deploy\work\MainEngine\localhost\web-console\WEB-INF\classes
                  14:08:11,768 INFO [Engine] ContextConfig[/web-console]: Added certificates -> request attribute Valve
                  14:08:12,018 INFO [EmbeddedCatalinaService41] Using Java2 parent classloader delegation: true
                  14:08:12,018 INFO [Engine] StandardManager[/web-console]: Seeding random number generator class java.security.SecureRandom
                  14:08:12,018 INFO [Engine] StandardManager[/web-console]: Seeding of random number generator has been completed
                  14:08:16,493 INFO [Engine] StandardWrapper[/web-console:default]: Loading container servlet default
                  14:08:17,934 INFO [Engine] StandardWrapper[/web-console:invoker]: Loading container servlet invoker
                  14:08:18,074 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/all/deploy/management/web-console.war
                  14:08:18,074 INFO [URLDeploymentScanner] Started
                  14:08:18,225 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1_tomcat-4.1.24/server/all/conf/jboss-service.xml
                  14:08:18,235 INFO [Server] JBoss (MX MicroKernel) [3.2.1 (build: CVSTag=JBoss_3_2_1 date=200305041533)] Started in 1m:38s:125ms
                  14:08:53,633 ERROR [JmsConnectionConsumer] java.lang.ClassCastException
                  java.lang.ClassCastException
                  at org.exolab.jms.client.JmsConnectionConsumer.onMessage(JmsConnectionConsumer.java:155)
                  at org.exolab.jms.client.JmsMessageConsumer.onMessage(JmsMessageConsumer.java:297)
                  at org.exolab.jms.client.JmsSession.execute(JmsSession.java:625)
                  at org.exolab.jms.client.JmsSession.onMessage(JmsSession.java:573)
                  at org.exolab.jms.client.rmi.RmiJmsSessionStub.onMessage(RmiJmsSessionStub.java:539)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:324)
                  at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
                  at sun.rmi.transport.Transport$1.run(Transport.java:148)
                  at java.security.AccessController.doPrivileged(Native Method)
                  at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                  at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
                  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
                  at java.lang.Thread.run(Thread.java:534)


                  Here is the service.xml:

                  RemoteJMSProvider
                  rmi://172.16.6.75:1099/
                  org.jboss.jms.jndi.OpenJMSProvider
                  JmsQueueConnectionFactory
                  JmsTopicConnectionFactory




                  And here is my OpenJMSProvider.java:
                  public class OpenJMSProvider extends AbstractJMSProviderAdapter {
                  /**
                  * Field INITIAL_CONTEXT_FACTORY
                  */
                  public static final String INITIAL_CONTEXT_FACTORY =
                  "org.exolab.jms.jndi.InitialContextFactory";
                  /**
                  * Field SECURITY_MANAGER
                  */
                  private static final String SECURITY_MANAGER =
                  "java.naming.rmi.security.manager";
                  /**
                  * Field URL_PKG_PREFIXES
                  */
                  public static final String URL_PKG_PREFIXES = "org.jboss.naming";
                  /**
                  * Field hasJndiSecurityManager
                  */
                  private String hasJndiSecurityManager;
                  /**
                  * Field log
                  */
                  private transient Logger log;
                  /**
                  *
                  */
                  public OpenJMSProvider() {
                  log = Logger.getLogger(getClass());
                  hasJndiSecurityManager = "yes";
                  log.debug("initializing");
                  }
                  /**
                  * Method getInitialContext
                  * @return Context
                  * @throws NamingException
                  * @see org.jboss.jms.jndi.JMSProviderAdapter#getInitialContext()
                  */
                  public Context getInitialContext() throws NamingException {
                  Context ctx = null;
                  boolean debug = log.isDebugEnabled();
                  log.debug("provider URL is: " + providerURL);
                  if (providerURL == null) {
                  if (debug)
                  log.debug("no provider url; connecting to local JNDI");
                  ctx = new InitialContext();
                  }
                  else {
                  Hashtable props = new Hashtable();
                  props.put(
                  "java.naming.factory.initial",
                  INITIAL_CONTEXT_FACTORY);
                  props.put("java.naming.provider.url", providerURL);
                  //props.put("java.naming.rmi.security.manager", hasJndiSecurityManager);
                  //props.put("java.naming.factory.url.pkgs", "org.jboss.naming");
                  if (debug)
                  log.debug(
                  "connecting to remote JNDI with props: " + props);
                  ctx = new InitialContext(props);
                  }
                  if (debug)
                  log.debug("created context: " + ctx);
                  return ctx;
                  }
                  /**
                  * Method readObject
                  * @param in ObjectInputStream
                  * @throws IOException
                  * @throws ClassNotFoundException
                  */
                  private void readObject(ObjectInputStream in)
                  throws IOException, ClassNotFoundException {
                  log.debug("reading in object");
                  in.defaultReadObject();
                  log.debug("read the in object");
                  log = Logger.getLogger(getClass());
                  }
                  }


                  Do I need to change anything else?

                  Thanks a lot.

                  Cheers,
                  RG.

                  • 6. Re: JBOSS with OpenJMS

                    Does any of the jars you added contain
                    javax.jms classes that are competing with the classes
                    in jboss-j2ee.jar?

                    This error is in the openjms classes, you will have to findout
                    what class is causing the problem.

                    Regards,
                    Adrian

                    • 7. Re: JBOSS with OpenJMS
                      rg

                      No, there are no javax.jms.* classes in the OpenJMS jars, but somehow its implementation classes for Session, Queues, Topics etc. are taking precedence over javax.jms.* classes while consuming messages and looks like that is why the problem ...

                      Anyway, will try to figure out why it is happening.

                      Thanks.

                      • 8. Re: JBOSS with OpenJMS
                        rg

                        Adrian,

                        I wrote a ServerSessionPoolFactory which creates JmsServerSessionPool(OpenJMS class) for OpenJMS and added another entry in the jms-ds.xml with OpenJMSPool and used it instead of StdJMSPool in the standardjboss.xml and I am able to receive messages in my MDB in JBOSS. Only problem is that I receive 2 valid messages that I sent on the queue and another extra message !!!

                        Thanks a lot for all your help.

                        -RG.

                        • 9. Re: JBOSS with OpenJMS
                          rg

                          Frank,

                          Got your message. Here is the ServerSessionPoolFactory code. I was able to integrate OpenJMS with JBOSS, the only problem I had was that message selectors were not working. Another feature that we require is XA support which is not provided by OpenJMS. For the time being I am using JBOSS's provider JBOSSMQ, but eventually we will be using MQSeries

                          package org.jboss.jms.asf;
                          import java.io.Serializable;
                          import javax.jms.*;
                          import org.exolab.jms.client.JmsServerSessionPool;
                          import org.jboss.tm.XidFactoryMBean;

                          public class OpenJMSServerSessionPoolFactory implements ServerSessionPoolFactory, Serializable{
                          public OpenJMSServerSessionPoolFactory()
                          {
                          }

                          public void setName(String name)
                          {
                          this.name = name;
                          }

                          public String getName()
                          {
                          return name;
                          }

                          public void setXidFactory(XidFactoryMBean xidFactory)
                          {
                          this.xidFactory = xidFactory;
                          }

                          public XidFactoryMBean getXidFactory()
                          {
                          return xidFactory;
                          }

                          public ServerSessionPool getServerSessionPool(Connection con, int maxSession, boolean isTransacted, int ack, boolean useLocalTX, MessageListener listener)
                          throws JMSException
                          {
                          JmsServerSessionPool.init(15,listener);
                          ServerSessionPool pool = JmsServerSessionPool.instance();
                          return pool;
                          }

                          private String name;
                          private XidFactoryMBean xidFactory;
                          }

                          Regards,
                          -RG.

                          • 10. Re: JBOSS with OpenJMS
                            kshiv2001

                            Hi,
                            I tried with the classes you specified.(created the jar and placed in server/default/lib/ dir and placed the client jars needed for the openjms and changed the jms-ds.xml for the openjms provider) But didn't work.
                            could you please give a step by step procedure to enable openjms with Jboss?
                            Thanks a lot in advance.
                            -Siva