Using WSMQ ( yet another question )
nusa Aug 28, 2004 5:37 AMHi,
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