8 Replies Latest reply on Sep 1, 2004 10:27 AM by Michael Kopp

    Using WSMQ ( yet another question )

    nusa Novice

      Hi,

      I'm using JBoss 4RC1 to create an MDB listening to WebsphereMQ.
      But encounter a weird problem.

      Here are steps I did :
      1. I add these in standardjboss.xml :

       <invoker-proxy-binding>
       <name>wsmq-message-driven-bean</name>
       <invoker-mbean>whatever</invoker-mbean>
       <proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-factory>
       <proxy-factory-config>
       <JMSProviderAdapterJNDI>WSMQProvider</JMSProviderAdapterJNDI>
       <ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI>
       <MaximumSize>15</MaximumSize>
       <MaxMessages>1</MaxMessages>
       <MDBConfig>
       <ReconnectIntervalSec>10</ReconnectIntervalSec>
       <!-- IGNORE DLQ for the time being -->
       <!--DLQConfig>
       <DestinationQueue>queue/WSMQDLQ</DestinationQueue>
       <MaxTimesRedelivered>10</MaxTimesRedelivered>
       <TimeToLive>0</TimeToLive>
       </DLQConfig-->
       </MDBConfig>
       </proxy-factory-config>
       </invoker-proxy-binding>
      
       <container-configuration>
       <container-name>WSMQ Message Driven Bean</container-name>
       <call-logging>false</call-logging>
       <invoker-proxy-binding-name>wsmq-message-driven-bean</invoker-proxy-binding-name>
       <container-interceptors>
       <interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
       <interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
       <interceptor>org.jboss.ejb.plugins.RunAsSecurityInterceptor</interceptor>
       <!-- CMT -->
       <interceptor transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
       <interceptor transaction="Container">org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>
       <interceptor transaction="Container" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
       <interceptor transaction="Container">org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor</interceptor>
       <!-- BMT -->
       <interceptor transaction="Bean">org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor</interceptor>
       <interceptor transaction="Bean">org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT</interceptor>
       <interceptor transaction="Bean">org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>
       <interceptor transaction="Bean" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
       <interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>
       </container-interceptors>
       <instance-pool>org.jboss.ejb.plugins.MessageDrivenInstancePool</instance-pool>
       <instance-cache></instance-cache>
       <persistence-manager></persistence-manager>
       <container-pool-conf>
       <MaximumSize>100</MaximumSize>
       </container-pool-conf>
       </container-configuration>
      


      2. I add these in jms-ds.xml :
       <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
       name="jboss.mq:service=JMSProviderLoader,name=WSMQProvider">
       <attribute name="ProviderName">WSMQProvider</attribute>
       <attribute name="ProviderAdapterClass">
       org.jboss.jms.jndi.JNDIProviderAdapter
       </attribute>
       <attribute name="QueueFactoryRef">QCFProducer</attribute>
       <attribute name="TopicFactoryRef">QCFProducer</attribute>
       <attribute name="Properties">
       java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory
       java.naming.provider.url=file:///home/nusa/JNDI-Directory
       </attribute>
       </mbean>
      


      3.my ejb-jar.xml :
      <ejb-jar>
       <enterprise-beans>
       <message-driven>
       <ejb-name>WSMQmdb</ejb-name>
       <ejb-class>example.mdb.WSMQmdb</ejb-class>
       <transaction-type>Container</transaction-type>
       <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
       <message-driven-destination>
       <destination-type>javax.jms.Queue</destination-type>
       </message-driven-destination>
       </message-driven>
       </enterprise-beans>
      </ejb-jar>
      


      3. my jboss.xml :
      <jboss>
       <enterprise-beans>
       <message-driven>
       <ejb-name>WSMQmdb</ejb-name>
       <configuration-name>WSMQ Message Driven Bean</configuration-name>
       <destination-jndi-name>queue/QProducer</destination-jndi-name>
       <invoker-bindings>
       <invoker>
       <invoker-proxy-binding-name>wsmq-message-driven-bean</invoker-proxy-binding-name>
       </invoker>
       </invoker-bindings>
       </message-driven>
       </enterprise-beans>
      </jboss>
      


      4. with the following JMSAdmin.config :
      INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
      PROVIDER_URL=file:/home/nusa/JNDI-Directory
      


      I run the following shell script, as 'mqm' user :
      cd /opt/mqm/java/bin
      
      echo "+ Calling JMSAdmin in batch mode to create objects"
      
      cat << EOT | java -DMQJMS_LOG_DIR=$MQ_JAVA_DATA_PATH/log -DMQJMS_TRACE_DIR=$MQ_JAVA_DATA_PATH/trace -DMQJMS_INSTALL_PATH=$MQ_JAVA_INSTALL_PATH com.ibm.mq.jms.admin.JMSAdmin
      del qcf(QCFProducer)
      def qcf(QCFProducer) +
       transport(client) +
       channel(CHANNEL1) +
       qmgr(QM1)
      def ctx(queue)
      chg ctx(queue)
      del q(QProducer)
      def q(QProducer) +
       qu(QUEUE1) +
       qmgr(QM1)
      del q(WSMQDLQ)
      def q(WSMQDLQ) +
       qu(QUEUE1) +
       qmgr(QM1)
      end
      EOT
      echo "+ Done!"
      


      I think it's all setup now,then I build an MDB, and deploy it.
      The error I got is :

      02:30:52,057 DEBUG [org.jboss.ejb.plugins.jms.JMSContainerInvoker] Starting jboss.j2ee:binding=wsmq-message-driven-bean,jndiName=local/WSMQmdb,plugin=invoker,service=EJB
      02:30:52,057 DEBUG [org.jboss.ejb.plugins.jms.JMSContainerInvoker] Initializing
      02:30:52,057 DEBUG [org.jboss.ejb.plugins.jms.JMSContainerInvoker] Looking up provider adapter: java:/WSMQProvider
      02:30:52,058 DEBUG [org.jboss.ejb.plugins.jms.JMSContainerInvoker] Provider adapter: org.jboss.jms.jndi.JNDIProviderAdapter@c4afc4
      02:30:52,058 ERROR [org.jboss.ejb.plugins.jms.JMSContainerInvoker] Starting failed jboss.j2ee:binding=wsmq-message-driven-bean,jndiName=local/WSMQmdb,plugin=invoker,service=EJB
      javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.fscontext.RefFSContextFactory [Root exception is java.lang.ClassNotFoundException: com/sun/jndi/fscontext/RefFSContextFactory ]
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
      at javax.naming.InitialContext.init(InitialContext.java:219)
      at javax.naming.InitialContext.(InitialContext.java:195)
      at org.jboss.jms.jndi.JNDIProviderAdapter.getInitialContext(JNDIProviderAdapter.java:40)
      at org.jboss.ejb.plugins.jms.JMSContainerInvoker.innerCreate(JMSContainerInvoker.java:575)
      at org.jboss.ejb.plugins.jms.JMSContainerInvoker.startService(JMSContainerInvoker.java:767)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
      at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)

      The class com.sun.jndi.fscontext.RefFSContextFactory is in /deploy/lib/fscontext.jar.

      Any idea where does it come from this error ?

      Thanks for your help/suggestion.

      nusa

        • 1. Re: Using WSMQ ( yet another question )
          Adrian Brock Master

          put the jar in server/default/lib

          • 2. Re: Using WSMQ ( yet another question )
            nusa Novice

            Adrian,

            It was a typo error, the jar was already in default/lib, not deploy/lib.
            Any idea ?

            Thanks.
            nusa.

            • 3. Re: Using WSMQ ( yet another question )
              Adrian Brock Master

              That can't be true, otherwise it would find the class.

              You know you need to restart jboss if you add a jar to server/default/lib?
              This directory is not hot-deployed, it is only referenced at startup.

              • 4. Re: Using WSMQ ( yet another question )
                nusa Novice

                Yes, as I said 'weird' ...
                Here is a snapshot of the boot.log :

                ...
                10:42:34,421 DEBUG [SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/com.ibm.mq.jar
                10:42:34,421 DEBUG [SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/com.ibm.mqjms.jar
                10:42:34,421 DEBUG [SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/ehcache-0.7.jar
                10:42:34,422 DEBUG [SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/cglib-full-2.0.1.jar
                10:42:34,422 DEBUG [SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/fscontext.jar
                10:42:34,422 DEBUG [SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/hibernate2.jar
                10:42:34,422 DEBUG [SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/odmg-3.0.jar
                10:42:34,422 DEBUG [SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/ojdbc14_g.jar
                10:42:34,422 DEBUG [SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/ojdbc14.jar
                10:42:34,422 DEBUG [SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/providerutil.jar
                10:42:34,422 DEBUG [SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/quartz.jar
                ...
                10:42:36,267 DEBUG [RepositoryClassLoader] Added url: file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/cglib-full-2.0.1.jar, to ucl: org.jboss.mx.loading.UnifiedClassLoader3@281d4b{ url=file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/tmp/deploy/tmp59085jboss-service.xml ,addedOrder=2}
                10:42:36,272 DEBUG [RepositoryClassLoader] Added url: file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/fscontext.jar, to ucl: org.jboss.mx.loading.UnifiedClassLoader3@281d4b{ url=file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/tmp/deploy/tmp59085jboss-service.xml ,addedOrder=2}
                10:42:36,419 DEBUG [RepositoryClassLoader] Added url: file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/hibernate2.jar, to ucl: org.jboss.mx.loading.UnifiedClassLoader3@281d4b{ url=file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/tmp/deploy/tmp59085jboss-service.xml ,addedOrder=2}
                10:42:36,447 DEBUG [RepositoryClassLoader] Added url: file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/odmg-3.0.jar, to ucl: org.jboss.mx.loading.UnifiedClassLoader3@281d4b{ url=file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/tmp/deploy/tmp59085jboss-service.xml ,addedOrder=2}
                10:42:36,637 DEBUG [RepositoryClassLoader] Added url: file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/ojdbc14_g.jar, to ucl: org.jboss.mx.loading.UnifiedClassLoader3@281d4b{ url=file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/tmp/deploy/tmp59085jboss-service.xml ,addedOrder=2}
                10:42:36,828 DEBUG [RepositoryClassLoader] Added url: file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/ojdbc14.jar, to ucl: org.jboss.mx.loading.UnifiedClassLoader3@281d4b{ url=file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/tmp/deploy/tmp59085jboss-service.xml ,addedOrder=2}
                10:42:36,847 DEBUG [RepositoryClassLoader] Added url: file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/providerutil.jar, to ucl: org.jboss.mx.loading.UnifiedClassLoader3@281d4b{ url=file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/tmp/deploy/tmp59085jboss-service.xml ,addedOrder=2}
                10:42:36,893 DEBUG [RepositoryClassLoader] Added url: file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/quartz.jar, to ucl: org.jboss.mx.loading.UnifiedClassLoader3@281d4b{ url=file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/tmp/deploy/tmp59085jboss-service.xml ,addedOrder=2}
                ...

                It looks for me that fscontext.jar is already loaded.

                And then from server.log :
                ...
                10:43:12,083 DEBUG [org.jboss.deployment.SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/com.ibm.mq.jar
                10:43:12,083 DEBUG [org.jboss.deployment.SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/com.ibm.mqjms.jar
                10:43:12,083 DEBUG [org.jboss.deployment.SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/ehcache-0.7.jar
                10:43:12,083 DEBUG [org.jboss.deployment.SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/cglib-full-2.0.1.jar
                10:43:12,083 DEBUG [org.jboss.deployment.SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/fscontext.jar
                10:43:12,083 DEBUG [org.jboss.deployment.SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/hibernate2.jar
                10:43:12,084 DEBUG [org.jboss.deployment.SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/odmg-3.0.jar
                10:43:12,084 DEBUG [org.jboss.deployment.SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/ojdbc14_g.jar
                10:43:12,084 DEBUG [org.jboss.deployment.SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/ojdbc14.jar
                10:43:12,084 DEBUG [org.jboss.deployment.SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/providerutil.jar
                10:43:12,084 DEBUG [org.jboss.deployment.SARDeployer] deployed classes for file:/home/nusa/Java/Software/jboss-4.0.0RC1/server/default/lib/quartz.jar
                ...


                Do you think that this is similar to this http://sourceforge.net/tracker/index.php?func=detail&aid=985962&group_id=22866&atid=376685

                nusa

                • 5. Re: Using WSMQ ( yet another question )
                  Adrian Brock Master

                  This link has information on debugging classloading:
                  http://www.jboss.org/wiki/Wiki.jsp?page=EnableClassloaderLogging

                  But most likely, you have broken the class visibility by adding by adding jars to the
                  classpath or jre/lib/ext

                  • 6. Re: Using WSMQ ( yet another question )
                    nusa Novice

                    No, I didn't broke anything !

                    Here is a snapshot of my boot.log :
                    ...
                    02:34:27,472 DEBUG [ServerInfo] java.library.path: /opt/Java/j2sdk1.4.2_04/jre/lib/i386/server:/opt/Java/j2sdk1.4.2_04/jre/lib/i386:/opt/Java/j2sdk1.4.2_04/jre/../lib/i386:/opt/mqm/lib:/opt/mqm/java/lib
                    ...
                    02:34:27,473 DEBUG [ServerInfo] java.class.path: /home/nusa/Java/Software/jboss-4.0.0RC1/bin/run.jar:/opt/Java/j2sdk1.4.2_04/lib/tools.jar
                    ...
                    02:34:27,474 DEBUG [ServerInfo] sun.boot.class.path: /home/nusa/Java/Software/jboss-4.0.0RC1/lib/endorsed/resolver.jar:/home/nusa/Java/Software/jboss-4.0.0RC1/lib/endorsed/xalan.jar:/home/nusa/Java/Software/jboss-4.0.0RC1/lib/endorsed/xml-apis.jar:/home/nusa/Java/Software/jboss-4.0.0RC1/lib/endorsed/xercesImpl.jar:/opt/Java/j2sdk1.4.2_04/jre/lib/rt.jar:/opt/Java/j2sdk1.4.2_04/jre/lib/i18n.jar:/opt/Java/j2sdk1.4.2_04/jre/lib/sunrsasign.jar:/opt/Java/j2sdk1.4.2_04/jre/lib/jsse.jar:/opt/Java/j2sdk1.4.2_04/jre/lib/jce.jar:/opt/Java/j2sdk1.4.2_04/jre/lib/charsets.jar:/opt/Java/j2sdk1.4.2_04/jre/classes
                    ...

                    and my jre/lib/ext :
                    [root@localhost ext]#
                    [root@localhost ext]# pwd
                    /opt/Java/j2sdk1.4.2_04/jre/lib/ext
                    [root@localhost ext]# ll
                    total 940
                    -rw-rw-r-- 1 root root 8896 Feb 24 2004 dnsns.jar
                    -rw-rw-r-- 1 root root 53247 Feb 24 2004 ldapsec.jar
                    -rw-r--r-- 1 root root 769335 Apr 25 21:59 localedata.jar
                    -r--r--r-- 1 root root 111374 Feb 24 2004 sunjce_provider.jar
                    [root@localhost ext]#

                    I've rechecked that the class com.sun.jndi.fscontext.RefFSContextFactory is only in fscontext.jar, and that jar is in default/lib.

                    From the boot.log and the server.log, it's clear that fscontext.jar is loaded, yet JBoss unable to find that class.

                    Thanks,
                    nusa

                    • 7. Re: Using WSMQ ( yet another question )
                      nusa Novice

                      Hi,

                      This problem really drive me nuts ...

                      First, I put fscontext.jar in default/lib.
                      Then I remove it from there and put it in jre/lib/ext, as JNDI doc says. And last, remove it from there and put it in $JAVA_HOME/lib.
                      I even specify it in $JBOSS_CLASSPATH.

                      I've searched through Sun's forum about the error. All the answer points to what I did above. But the error remains there.

                      Any suggestions, pointers to were to look or any solutions would be very appreciated.

                      Thanks,
                      nusa

                      • 8. Re: Using WSMQ ( yet another question )
                        Michael Kopp Newbie

                        Hi,

                        I actually used your config to get MQ running on my side. Where did you get that information?

                        anyway, I found your problem. check out the following lines:


                        java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory
                        java.naming.provider.url=file:///home/nusa/JNDI-Directory


                        the 'com.sun.jndi.fscontext.RefFSContextFactory' as a trailing space. remove it and your fine ;-)

                        Hey and if that works out, it would be really great to give me a tip about the configuration stuff itself.

                        cheers
                        Mike