Hi *,
I want to send some messages from a session bean to a message driven bean. Therefore I'll use the default Queue (sapDemoQueue) and QueueConnectionFactory.
In the ServiceLocator of my SessionBean I do the lookup with following methods:
public QueueConnectionFactory getQueueConnectionFactory() throws NamingException {
if (queueConnectionFactory == null) {
Object obj = ctx.lookup("jmsfactory/default/QueueConnectionFactory");
queueConnectionFactory = (QueueConnectionFactory) obj;
}
return queueConnectionFactory;
}
public Queue getQueue() throws NamingException {
if (queue == null) {
Object obj = ctx.lookup("jmsqueues/default/sapDemoQueue");
queue = (Queue) obj;
}
return queue;
}
My Message Driven Bean is configure as followed:
ejb-jar.xml:
<message-driven>
<ejb-name>ExportBean</ejb-name>
<ejb-class>de.test.ejb.abschluss.ExportBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
</message-driven>
ejb-j2ee-engine.xml:
<enterprise-bean>
<ejb-name>ExportBean</ejb-name>
<message-props>
<destination-name>jmsqueues/default/sapDemoQueue</destination-name>
<connection-factory-name>jmsfactory/default/QueueConnectionFactory</connection-factory-name>
</message-props>
</enterprise-bean>
I also create a jms-factories.xml and a jms-destination.xml.
EAR-Project/META-INF/jms-factories.xml:
<jms-factories>
<connection-factory>
<factory-name>jmsfactory/default/QueueConnectionFactory</factory-name>
<context-factory-type>
<link-factory-name>jmsfactory/default/QueueConnectionFactory</link-factory-name>
<initial-context-factory>com.sap.engine.services.jndi.InitialContextFactoryImpl</initial-context-factory>
<provider-url>localhost</provider-url>
<security-principal>Administrator</security-principal>
</context-factory-type>
<client-id></client-id>
</connection-factory>
</jms-factories>
EAR-Project/META-INF/jms-destination.xml:
<jms-destinations>
<destination>
<connection-factory>jmsfactory/default/QueueConnectionFactory</connection-factory>
<destination-name>jmsqueues/default/sapDemoQueue</destination-name>
</destination>
</jms-destinations>
How to configure correctly?
Does anybody an example how to configure?
Where may I download the example of the SAP documentation at http://help.sap.com/saphelp_nw04/helpdata/en/3d/41bee546e94ad48537f2cf06a29818/frameset.htm
Thank a lot,
Juergen
Hi Juergen,
You can deploy and test the MDB example from the documentation, as well as download the source code on the start page of the SAP Web AS Java - just type http://<host>:<http_port> in your browser and then go to J2EE Engine Examples -> Message-Driven Bean Example.
In the jms-factories.xml you can specify whatever for <factory-name>. For example, you could enter the following:
<jms-factories>
<connection-factory>
<factory-name>MyTestFactory</factory-name>
<context-factory-type>
<link-factory-name>jmsfactory/default/QueueConnectionFactory</link-factory-name>
Then in the jms-destinations.xml you should enter the lookup name of the factory. The destination name is arbitrary as well. For example:
<connection-factory>MyTestFactory</connection-factory>
<destination-name>MyTestQueue</destination-name>
In addition, you must set references to these resources in the ejb-jar.xml of your beans. The MDB example from the documentation provides a sample of the beans' deployment descriptors. For example:
<resource-ref>
<res-ref-name>MyTestFactory</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-env-ref>
<resource-env-ref-name>MyTestQueue</resource-env-ref-name>
<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
</resource-env-ref>
To look up the resources in the enterprise beans, use the strings "java:comp/env/MyTestFactory" and "java:comp/env/MyTestQueue" for the factory and the destination respectively.
For more information about JMS development in SAP Web AS Java, please have a look at the documentation: http://help.sap.com/saphelp_nw04/helpdata/en/a3/63af1bbf09469fa1615c05f0daff6f/frameset.htm.
I hope this info is helpful and not too confusing:)
Zornitsa
Hello,
now I find an error:
#1.5#00028A35478900440000002C0000033C0003E5E9B30AD977#1097216853157#com.sap.engine.services.jmsconnector##com.sap.engine.services.jmsconnector#Administrator#132####0e38e6f118f311d9a7d300028a354789#SAPEngine_Application_Thread[impl:3]_22##0#0#Error#1#/System/Server#Plain###JMS Connector Container Application: sap.com/LeistungserfassungEar factory name: FdlbQueueConnectionFactory loader does not exist: . Using default class loader!!!#
#1.5#00028A35478900440000002D0000033C0003E5E9B30C13E9#1097216853238#com.sap.engine.services.jmsconnector##com.sap.engine.services.jmsconnector#Administrator#132####0e38e6f118f311d9a7d300028a354789#SAPEngine_Application_Thread[impl:3]_22##0#0#Error##Plain###Factory: FdlbQueueConnectionFactory loader does not exist: . Using default class loader!!!#
#1.5#00028A3547890036000000010000033C0003E5E9B4B6C830#1097216885804#defiliadata.leistungserfassung.ejb.abschluss.MonatsabschlussBean#sap.com/LeistungserfassungEar#defiliadata.leistungserfassung.ejb.abschluss.MonatsabschlussBean#Guest#2####369d536018f311d9ae2600028a354789#SAPEngine_Application_Thread[impl:3]_39##0#0#Debug#1#/System/Database#Plain###exportMonatsabschlussToSap#
Hi *,
to solve my problem I created another application. Now I got following exceptions:
#1.5#00028A354789003D0000003300000E880003E5EE897F3126#1097237668632#com.sap.engine.services.jmsconnector##com.sap.engine.services.jmsconnector#Administrator#546####9a3a92e0192311d998e200028a354789#SAPEngine_Application_Thread[impl:3]_1##0#0#Error##Plain###Factory: myMdbQueueConnectionFactory loader does not exist: . Using default class loader!!!#
#1.5#00028A35478900530000000100000E880003E5EE89815945#1097237668772#com.sap.jms##com.sap.jms.server.sessioncontainer.InboundBus instance=default#Administrator#546####9a517640192311d98d5200028a354789#SAPEngine_Application_Thread[impl:3]_14##0#0#Error##Plain###com.sap.jms.server.exception.JMSServerException: The requested destination myMdbQueue is not a queue.
at com.sap.jms.server.service.impl.RegistryServiceImpl.createDestinationContext(RegistryServiceImpl.java:231)
at com.sap.jms.server.sessioncontainer.handler.DestinationHandler.onCreateRequest(DestinationHandler.java:134)
at com.sap.jms.server.sessioncontainer.handler.DestinationHandler.process(DestinationHandler.java:71)
at com.sap.jms.server.sessioncontainer.InboundBus.process(InboundBus.java:143)
at com.sap.jms.server.sessioncontainer.InboundBus.enqueue(InboundBus.java:116)
at com.sap.jms.server.sessioncontainer.SessionContainer.receiveFromDispatcher(SessionContainer.java:63)
at com.sap.jms.server.routingcontainer.RoutingContainer.receiveFromDispatcher(RoutingContainer.java:332)
at com.sap.jms.server.JMSServerContainer.dispatchRequest(JMSServerContainer.java:462)
at com.sap.jms.server.ServerClientAdapter.run(ServerClientAdapter.java:287)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
#
#1.5#00028A354789003D0000003500000E880003E5EE89816993#1097237668772#com.sap.engine.services.jmsconnector##com.sap.engine.services.jmsconnector#Administrator#546####9a3a92e0192311d998e200028a354789#SAPEngine_Application_Thread[impl:3]_1##0#0#Error#1#/System/Server#Java###JMS Connector Container Application: sap.com/MyMdbEar destination name: myMdbQueue jms provider error:
[EXCEPTION]
#1#javax.jms.JMSException: The requested destination myMdbQueue is not a queue.
at com.sap.jms.protocol.notification.ServerExceptionResponse.getException(ServerExceptionResponse.java:271)
at com.sap.jms.client.session.Session.checkReceivedPacket(Session.java:1767)
at com.sap.jms.client.session.Session.createQueue(Session.java:1644)
at com.sap.engine.services.jmsconnector.deploy.ContainerImpl.loadDestination(ContainerImpl.java:1833)
at com.sap.engine.services.jmsconnector.deploy.ContainerImpl.prepareStart(ContainerImpl.java:721)
at com.sap.engine.services.deploy.server.application.StartTransaction.prepare(StartTransaction.java:357)
at com.sap.engine.services.deploy.server.application.ApplicationTransaction.makeAllPhasesOnOneServer(ApplicationTransaction.java:299)
at com.sap.engine.services.deploy.server.application.ParallelAdapter.makeAllPhasesImpl(ParallelAdapter.java:303)
at com.sap.engine.services.deploy.server.application.ParallelAdapter.runInTheSameThread(ParallelAdapter.java:112)
at com.sap.engine.services.deploy.server.application.ParallelAdapter.makeAllPhasesAndWait(ParallelAdapter.java:214)
at com.sap.engine.services.deploy.server.DeployServiceImpl.startApplicationAndWait(DeployServiceImpl.java:4601)
at com.sap.engine.services.deploy.server.DeployServiceImpl.startApplicationAndWait(DeployServiceImpl.java:4508)
at com.sap.engine.services.deploy.server.DeployServiceImpl.startApplicationAndWait(DeployServiceImpl.java:4481)
at com.sap.engine.services.deploy.server.DeployServiceImplp4_Skel.dispatch(DeployServiceImplp4_Skel.java:1163)
at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:292)
at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:183)
at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:118)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
#
Do you now, why SAP Web AS couldn't create the queue?
When I use a predefined queue (sapDemoQueue) it works!
Thanks,
Juergen
Add a comment