Message Driven Bean example
Hi
I am looking for pointers in building a MDB Bean, pointers in this regard, will be of great help.
Thanks
sunder
http://www.oracle.com/technology/tech/java/oc4j/1013/how_to/index.html#JMS
Good Luck,
Avi.
Similar Messages
-
Message driven bean example is not working
Hi,
i tried message driven bean example on J2ee 6.20. I am able to make connection factory, but when i tried to deploy ear file a get an exception:
Error occurred
com.inqmy.services.deploy.container.DeploymentException: java.lang.NullPointerEx
ception
at com.inqmy.services.ejb20.EJBAdmin.commitDeploy(EJBAdmin.java:604)
at com.inqmy.services.deploy.server.DeployServiceImpl.commit(DeployServi
ceImpl.java:2897)
at com.inqmy.services.deploy.server.DeployServiceImpl.deploy1(DeployServ
iceImpl.java:524)
at com.inqmy.services.deploy.server.DeployServiceImpl.deploy(DeployServi
ceImpl.java:139)
at com.inqmy.services.deploy.command.DeployCommand.exec(DeployCommand.ja
va:142)
at com.inqmy.services.shell.processor.environment.CommandBase.exec(Comma
ndBase.java:124)
at com.inqmy.services.shell.processor.Interpreter.applyLineCommand(Inter
preter.java:391)
at com.inqmy.services.shell.processor.Interpreter.apply(Interpreter.java
:150)
at com.inqmy.services.shell.processor.Shell.work(Shell.java:150)
at com.inqmy.services.shell.processor.managers.ScriptProcessThread.run(S
criptProcessThread.java:128)
in visual administrator I can see the right queue and for few seconds this queue have one consumer.
thank
JJHi,
but this example was in guide to this version.
Ok, in case it is not possible to use MDB, how should i handle long time consumpting functions in EP enviroment?
(customer has only EP6SP2 and he need to send a lot of mails after user request and i dont want to leave user waiting till that function ends. - should i start new thread in portal?)
JJ -
Unable to download an Message Driven Bean Example
http://www.oracle.com/technology/sample_code/tech/java/oc4j/htdocs/oc4jsamplecode/oc4j-demo-ejb.html
In the link above try to download the example for Message Driven Bean. You can download it, but it is a "htm" file not a ear file that gets saved.
All other links open file (They all are jar files).
regards
-- Raghavan (Raag)Hello Pascal,
The following article will assist you with resetting your BlackBerry ID password: http://www.blackberry.com/btsc/KB26361
Please try logging in with the new password when prompted.
Let us know if this helps.
-FB
Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
Be sure to click Kudos! for those who have helped you.
Click "Accept as a Solution" for posts that have solved your issue(s)! -
Problem creating Physical Destination for Message Driven Bean example
I am trying to create a MDB application. in which i want to distribute the workload using messages.
I am using SUN j2ee application server8.2 and netbeans 6.5 on windows xp professional.
I referred the j2ee 1.4 tutorial to create the mdb's.
I am able to create queue's and connection factories.
the tutorial says
To create the physical destination, perform the following steps:
.In the tree component, expand the Resources node, then expand the JMS Resources node.
.Select the Physical Destinations node.
.On the Physical Destinations page, click New. The Create Physical Destination page appears.
.In the Physical Destination Name field, type PhysicalQueue.
.Choose queue from the Type combo box.
.Click OK.
but i am not able to find out this Physical Destination node in admin console. So when i execute my MDB project the messages are created but the onMessage() method is not invoked.
Please help!!!Hi,
but this example was in guide to this version.
Ok, in case it is not possible to use MDB, how should i handle long time consumpting functions in EP enviroment?
(customer has only EP6SP2 and he need to send a lot of mails after user request and i dont want to leave user waiting till that function ends. - should i start new thread in portal?)
JJ -
Assining Identity to Message Driven Bean
Dear All,
I have a problem on connecting MDB to JMS administered object in iPlanet server.
In the administered object I create an ACI to allows only a certain member of
group can access this ao. Disallowing anonymous user to connect to the ldap server
give me this error.
<Apr 15, 2003 1:41:09 PM SGT> <Warning> <EJB> <010096> <The Message-Driven EJB:
MessageEJB is unable to connect to the J
MS destination: cn=ocsQueue. Connection failed after 365 attempts. The MDB will
attempt to reconnect every 10 seconds, t
his log message will repeat every 600 seconds until the condition clears.>
<Apr 15, 2003 1:41:09 PM SGT> <Warning> <EJB> <010061> <The Message-Driven EJB:
MessageEJB is unable to connect to the J
MS destination: cn=ocsQueue. The EJB container will automatically attempt to re-establish
the connection with the JMS se
rver. This warning may occur during WebLogic Cluster start-up if the JMS destination
is located on another server. When
the JMS server connection is re-established, the Message-Driven EJB will again
receive JMS messages.
The Error was:
The Message-Driven EJB attempted to connect to the JMS destination with the JNDI
name: cn=ocsQueue. However, the object
with the JNDI name: cn=ocsQueue is not a JMS destination, or the destination found
was of the wrong type (Topic or Queue
).>
How can I configure the security descriptor so that my MDB can gen a connection
to ldap to read the administered object.
I am working on WebLogic 7.0 sp1 and iPlanet
Thanks,
WayanHi Yang,
The J2EE tutorial will give some more information.
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
See Ch. 28 A Message-Driven Bean example. It has some tips on using deploytool.
Hope this helps,
J -
Message-driven bean destination name not found error
Hi,
I am getting this error when I attempt to deploy the Warehouse message-driven bean example/tutorial. I followed the steps in the JMS Queue Simple Sample Application included with the server to set up the queue and queue factory, but I don't think the app. is even getting that far. I can not figure out why I'm get this error. I have looked at everything I can think of, but I'm obviously missing something. Here is the error from the server log.
INFO ( 2252): JMS5015: Install JMS resources ...
INFO ( 2252): JMS5002: Binding [< JMS Destination: jms/WarehouseQueue, javax.jms.Queue, [ imqDestinationName=WarehouseQueue ] >]
INFO ( 2252): JMS5002: Binding [< JMS Connection Factory: jms/WarehouseQueueConnectionFactory, javax.jms.QueueConnectionFactory, [ imqBrokerHostName=localhost , imqBrokerHostPort=7676 ] >]
INFO ( 2252): HTTP3072: HTTP listener http-listener-1 [http://ibankdev2:80] ready to accept requests
INFO ( 2252): CORE3274: successful server startup
INFO ( 2252): CORE5053: Application onReady complete.
INFO ( 2252): MDB00044: Deploying message-driven bean [MDBApp:Warehouse], consuming from [jms/Warehouse]
SEVERE ( 2252): MDB00015: [MDBApp:Warehouse]: Message-driven bean destination name [jms/Warehouse] not found
SEVERE ( 2252): javax.naming.NameNotFoundException
javax.naming.NameNotFoundException: Warehouse not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:185)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:157)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:161)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:78)
at org.omg.stub.com.sun.enterprise.naming._SerialContextProviderImpl_Tie._invoke(Unknown Source)
at com.sun.corba.ee.internal.corba.ServerDelegate.dispatch(ServerDelegate.java:375)
at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:275)
at com.sun.corba.ee.internal.iiop.LocalClientRequestImpl.invoke(LocalClientRequestImpl.java:96)
at com.sun.corba.ee.internal.corba.ClientDelegate.invoke(ClientDelegate.java:237)
at com.sun.corba.ee.internal.corba.ClientDelegate.invoke(ClientDelegate.java:279)
at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:457)
at org.omg.stub.com.sun.enterprise.naming._SerialContextProvider_Stub.lookup(Unknown Source)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:138)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at com.sun.ejb.containers.MessageBeanHelperBase.setup(MessageBeanHelperBase.java:317)
at com.sun.ejb.containers.MessageBeanContainer.<init>(MessageBeanContainer.java:206)
at com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:173)
at com.iplanet.ias.server.AbstractLoader.loadEjbs(AbstractLoader.java:345)
at com.iplanet.ias.server.ApplicationLoader.load(ApplicationLoader.java:81)
at com.iplanet.ias.server.ApplicationManager.applicationDeployed(ApplicationManager.java:134)
at com.iplanet.ias.server.ApplicationManager.applicationDeployed(ApplicationManager.java:110)
at com.iplanet.ias.server.ApplicationManager.applicationDeployed(ApplicationManager.java:294)
at com.iplanet.ias.admin.event.AdminEventMulticaster.invokeApplicationDeployEventListener(AdminEventMulticaster.java:424)
at com.iplanet.ias.admin.event.AdminEventMulticaster.handleApplicationDeployEvent(AdminEventMulticaster.java:408)
at com.iplanet.ias.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:291)
at com.iplanet.ias.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:99)
at com.iplanet.ias.admin.server.core.channel.AdminChannelServer.sendNotification(AdminChannelServer.java:84)
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:536)
SEVERE ( 2252): MDB00030: [MDBApp:Warehouse]: Exception in setting up message-driven bean container: [MDBApp:Warehouse: Message-driven bean destination jms/Warehouse not found]
SEVERE ( 2252): MDB00017: [Warehouse]: Exception in creating message-driven bean container: [javax.jms.JMSException: MDBApp:Warehouse: Message-driven bean destination jms/Warehouse not found]
SEVERE ( 2252): javax.jms.JMSException
javax.jms.JMSException: MDBApp:Warehouse: Message-driven bean destination jms/Warehouse not found
at com.sun.ejb.containers.MessageBeanHelperBase.setup(MessageBeanHelperBase.java:340)
at com.sun.ejb.containers.MessageBeanContainer.<init>(MessageBeanContainer.java:206)
at com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:173)
at com.iplanet.ias.server.AbstractLoader.loadEjbs(AbstractLoader.java:345)
at com.iplanet.ias.server.ApplicationLoader.load(ApplicationLoader.java:81)
at com.iplanet.ias.server.ApplicationManager.applicationDeployed(ApplicationManager.java:134)
at com.iplanet.ias.server.ApplicationManager.applicationDeployed(ApplicationManager.java:110)
at com.iplanet.ias.server.ApplicationManager.applicationDeployed(ApplicationManager.java:294)
at com.iplanet.ias.admin.event.AdminEventMulticaster.invokeApplicationDeployEventListener(AdminEventMulticaster.java:424)
at com.iplanet.ias.admin.event.AdminEventMulticaster.handleApplicationDeployEvent(AdminEventMulticaster.java:408)
at com.iplanet.ias.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:291)
at com.iplanet.ias.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:99)
at com.iplanet.ias.admin.server.core.channel.AdminChannelServer.sendNotification(AdminChannelServer.java:84)
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:536)
SEVERE ( 2252): EJB5090: Exception in creating EJB container [javax.jms.JMSException: MDBApp:Warehouse: Message-driven bean destination jms/Warehouse not found]
SEVERE ( 2252): appId=MDBApp moduleName=EJBModule_Warehouse_jar ejbName=Warehouse
SEVERE ( 2252): LDR5004: UnExpected error occured while creating ejb container
javax.jms.JMSException: MDBApp:Warehouse: Message-driven bean destination jms/Warehouse not found
at com.sun.ejb.containers.MessageBeanHelperBase.setup(MessageBeanHelperBase.java:340)
at com.sun.ejb.containers.MessageBeanContainer.<init>(MessageBeanContainer.java:206)
at com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:173)
at com.iplanet.ias.server.AbstractLoader.loadEjbs(AbstractLoader.java:345)
at com.iplanet.ias.server.ApplicationLoader.load(ApplicationLoader.java:81)
at com.iplanet.ias.server.ApplicationManager.applicationDeployed(ApplicationManager.java:134)
at com.iplanet.ias.server.ApplicationManager.applicationDeployed(ApplicationManager.java:110)
at com.iplanet.ias.server.ApplicationManager.applicationDeployed(ApplicationManager.java:294)
at com.iplanet.ias.admin.event.AdminEventMulticaster.invokeApplicationDeployEventListener(AdminEventMulticaster.java:424)
at com.iplanet.ias.admin.event.AdminEventMulticaster.handleApplicationDeployEvent(AdminEventMulticaster.java:408)
at com.iplanet.ias.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:291)
at com.iplanet.ias.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:99)
at com.iplanet.ias.admin.server.core.channel.AdminChannelServer.sendNotification(AdminChannelServer.java:84)
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:536)
WARNING ( 2252): CORE5021: Application NOT loaded: [MDBApp]
WARNING ( 2252): ADM5603:Event listener error [Error while deploying application [MDBApp]. Please refer to the server log for more details. ]
My bean name is Warehouse, jms/Warehouse is the JNDI and is mapped to MDBPack.WarehouseBean.class. MDBPack is in the classpath on the server. I guessed that the physical destination name was WarehouseQueue, but using Warehouse produced the same result. Please let me know if there is anything I could be missing. TIA
--MichelleHi,
You have not created the jms destination queue object
jms/Warehouse
Your server logs says it cannot find the destination queue object.It has got nothing to do with jndi name of your bean
Create jms destination queue object using
asadmin>create-jms-resource instance <instance_name> resourcetype javax.jms.Queue --property imqDestinationName=<NAme> jms/Warehouse
Then use list-jms-resources <instance_name> to
find if jms/Warehouse destionation queue object has been created.
Get back in case of any issues -
Message driven beans please help
Can anyone please provide me with a simple message driven bean example..
The examples i have found are not working..i dont know anything abt Message driven beans...i just need a sample working code because i need to deploy it on JBOSS using Ant.Here's a simple EJB 3.0 JMS MDB from our glassfish ejb site :
https://glassfish.dev.java.net/javaee5/ejb/EJB30.html
--ken -
Example for message-style with Message Driven Bean
hi,
Can i have some examples of webservices message-style with
MDB?....
thanksThe current version of the white-paper that Raffi
refers to covers through 7.0. For 8.1 see also
http://edocs.bea.com/wls/docs81/ConsoleHelp/jms_config.html#accessing_foreign_providers
and
http://edocs.bea.com/wls/docs81/jms/j2ee_components.html
these features can often make integration easier.
Tom
Raffi wrote:
> Doug,
>
> You can find very detailed information on this topic at the link below. All
> you need to do is specify the destination-jndi-name, initial-context-factory,
> provider-url, and connection-factory-jndi-name in weblogic-ejb-jar.xml for the
> non-BEA JMS provider for that specific MDB.
>
> ftp://edownload:[email protected]/pub/downloads/jmsproviders.pdf
>
> Hope that helps!
>
> Raffi
>
> Doug Chew <[email protected]> wrote:
>
>>Can someone give me an example on how to setup a message driven bean
>>with a foreign JMS provider using the foreign JMS provider's implementation
>>of a connection factory. i.e. binding the foreign JMS provider's connection
>>factory to the JNDI tree.
>>
>>Thanks
>
>
-
Error while deploying a message driven bean
I am deployeing a MDB which is done successfully but the message is not retrieved(No message in teh queue). The following description is given in the log file.
#1.5#0016E6197593004B0000000B000013040004288DE20D6CD8#1170489754872#com.sap.security.core.policy.PolicyInfoManagerImpl##com.sap.security.core.policy.PolicyInfoManagerImpl.copyApplicationConfiguration#Administrator#523####e5dbec01b35c11db90e70016e6197593#SAPEngine_Application_Thread[impl:3]_39##0#0#Error#1#/System/Security/WS/SecurityProtocol#Java###An error occured while copying configurations for application . Reason: #3#sap.com/MessageEAR#com.sap.engine.frame.core.configuration.NameNotFoundException#A configuration with the path "webservices/services/sap.com/MessageEAR" does not exist.#
Can you please tell where to look for it and what to do?the session bean is ::
public class SenderBean implements SessionBean {
public static final boolean DEBUG = false;
private SessionContext ctx;
private TopicConnectionFactory factory;
private TopicConnection connection;
private Topic topic;
public SenderBean() {
log("constructor");
public void ejbCreateSender() throws CreateException {
log("ejbCreate");
try {
InitialContext naming = new InitialContext();
factory = (TopicConnectionFactory)naming.lookup("jmsfactory/default/ExceptionTopicFactory");
topic = (Topic)naming.lookup("jmstopics/default/ExceptionTopic");
log("factory: " + factory);
allocateResources();
} catch (Exception exc) {
log("exception occured during ejbCreate().");
throw new CreateException("Unexpected exception in ejbCreate().");
public void ejbCreate() throws CreateException {
public void ejbActivate() {
log("ejbActivate");
try {
allocateResources();
} catch (Exception exc) {
exc.printStackTrace();
public void ejbPassivate() {
log("ejbPassivate");
try {
releaseResources();
} catch (Exception exc) {
exc.printStackTrace();
public void ejbRemove() {
log("ejbRemove");
public void setSessionContext(SessionContext _ctx) {
log("setSessionContext");
ctx = _ctx;
public void sendMessage(String text) throws MessageNotSentException {
log("sendMessage");
log("text = " + text);
TopicSession session = null;
try {
session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
log("topic = " + topic);
TopicPublisher publisher = session.createPublisher(topic);
TextMessage textMessage = session.createTextMessage();
textMessage.setText(text);
publisher.publish(textMessage);
System.out.println("Message Sent");
log("message sent");
} catch (JMSException jmse) {
jmse.printStackTrace();
throw new MessageNotSentException(jmse.toString());
} finally {
try {
if (session != null) {
session.close();
} catch (Exception exc) {
private void releaseResources() throws JMSException {
connection.close();
connection = null;
private void allocateResources() throws JMSException {
connection = factory.createTopicConnection();
log("connection = " + connection);
connection.start();
log("connection started");
private void log(String message) {
if (DEBUG) {
System.out.println("SenderBean: " + message);
the mdb is::
public class MessageDisplayBean implements MessageDrivenBean, MessageListener {
public static final boolean DEBUG = false;
private MessageDrivenContext ctx;
private QueueConnectionFactory factory;
private QueueConnection connection;
private Queue queue;
public MessageDisplayBean() {
System.out.println("In constructor");
log("constructor");
public void onMessage(Message message) {
TextMessage textMessage = (TextMessage)message;
try {
String text = textMessage.getText();
log("message received. Text follows:\n\n " + text + "\n\n");
connection = factory.createQueueConnection();
connection.start();
QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
TextMessage confirmation = session.createTextMessage();
confirmation.setText("Message \""+ textMessage.getText() + "\" received.");
//queue = session.createQueue("ConfirmationQueue");
QueueSender sender = session.createSender(queue);
sender.send(confirmation);
session.close();
connection.close();
System.out.println("Message received");
} catch (javax.jms.JMSException jmse) {
public void ejbRemove() {
log("ejbRemove()");
public void setMessageDrivenContext(MessageDrivenContext _ctx) {
log("setMessageDrivenContext()");
ctx = _ctx;
System.out.println("In context");
public void ejbCreate() {
try {
System.out.println("In ejbcreate");
InitialContext naming = new InitialContext();
factory = (QueueConnectionFactory)naming.lookup("jmsfactory/default/ExceptionQueueFactory");
queue = (Queue)naming.lookup("jmsqueues/default/ExceptionQueue");
log("factory: " + factory);
} catch (Exception exc) {
log("exception occured during ejbCreate().");
log("ejbCreate()");
private void log(String str) {
if (DEBUG) {
System.out.println("MessageDisplayBean: " + str);
th ejb-j2ee-engine.xml is::
<ejb-j2ee-engine>
<enterprise-beans>
<enterprise-bean>
<ejb-name>MessageDisplayBean</ejb-name>
<jndi-name>MessageDisplayBean</jndi-name>
<message-props>
<destination-name>ExceptionTopic</destination-name>
<connection-factory-name>ExceptionTopicFactory</connection-factory-name>
</message-props>
</enterprise-bean>
<enterprise-bean>
<ejb-name>MessageSender</ejb-name>
<jndi-name>MessageSender</jndi-name>
<session-props/>
</enterprise-bean>
</enterprise-beans>
</ejb-j2ee-engine>
the ejb-jar.xml is::
<ejb-jar>
<display-name> Message Driver Bean Example </display-name>
<enterprise-beans>
<session>
<display-name> MessageSender </display-name>
<ejb-name>MessageSender</ejb-name>
<home>com.sap.message.sender.SenderHome</home>
<remote>com.sap.message.sender.Sender</remote>
<local-home>com.sap.message.sender.SenderLocalHome</local-home>
<local>com.sap.message.sender.SenderLocal</local>
<ejb-class>com.sap.message.sender.SenderBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
<ejb-local-ref>
<ejb-ref-name>ejb/SenderBean</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.sap.message.sender.SenderLocalHome</local-home>
<local>com.sap.message.sender.SenderLocal</local>
<ejb-link>MyEJB.jar#MessageSender</ejb-link>
</ejb-local-ref>
<resource-ref>
<res-ref-name>ExceptionTopicFactory</res-ref-name>
<res-type>javax.jms.TopicConnectionFactory</res-type>
<res-auth> Container</res-auth>
</resource-ref>
<resource-env-ref>
<resource-env-ref-name>ExceptionTopic </resource-env-ref-name>
<resource-env-ref-type> javax.jms.Topic </resource-env-ref-type>
</resource-env-ref>
</session>
<message-driven>
<ejb-name>MessageDisplayBean</ejb-name>
<ejb-class>com.sap.message.mdb.MessageDisplayBean</ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Topic</destination-type>
</message-driven-destination>
<resource-ref>
<res-ref-name> ExceptionQueueFactory </res-ref-name>
<res-type> javax.jms.QueueConnectionFactory </res-type>
<res-auth> Container </res-auth>
</resource-ref>
<resource-env-ref>
<resource-env-ref-name> ExceptionQueue </resource-env-ref-name>
<resource-env-ref-type> javax.jms.Queue </resource-env-ref-type>
</resource-env-ref>
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>MessageDisplayBean</ejb-name>
<method-name>onMessage</method-name>
</method>
<trans-attribute> NotSupported </trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar> -
JBoss message driven bean calling a session bean
Hi guys, can you please help me? I want my mdb to call my session bean....can you provide me some examples of ejb-jar.xml and jboss.xml with regards to this configuration....thanks...im creating my deployment descriptors manually
Here is a little example, I hope it will help you.
ejb-jar.xml
=============================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar >
<enterprise-beans>
<!-- Session Beans -->
<session >
<display-name>TestSessionEJB</display-name>
<ejb-name>TestSession</ejb-name>
<home>mdbtest.interfaces.TestSessionHome</home>
<remote>mdbtest.interfaces.TestSession</remote>
<local-home>mdbtest.interfaces.TestSessionLocalHome</local-home>
<local>mdbtest.interfaces.TestSessionLocal</local>
<ejb-class>mdbtest.session.TestSessionEJB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
... </session>
<!-- Message Driven Beans -->
<message-driven >
<description><![CDATA[]]></description>
<display-name>TestMessageEJB</display-name>
<ejb-name>TestMessage</ejb-name>
<ejb-class>mdbtest.message.TestMessageEJB</ejb-class>
<transaction-type>Container</transaction-type>
<message-selector></message-selector>
<acknowledge-mode>Auto-acknowledge</acknowledge-mode>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
<subscription-durability>NonDurable</subscription-durability>
</message-driven-destination>
<ejb-local-ref >
<ejb-ref-name>ejb/TestEjb</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>mdbtest.interfaces.TestSessionLocalHome</local-home>
<local>mdbtest.interfaces.TestSessionLocal</local>
<ejb-link>TestSession</ejb-link>
</ejb-local-ref>
</message-driven>
</enterprise-beans>
</ejb-jar>
jboss.xml:
=============================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>TestSession</ejb-name>
<jndi-name>ejb/MdbTest/TestSession</jndi-name>
<local-jndi-name>TestSessionLocal</local-jndi-name>
<configuration-name>Standard Stateless SessionBean</configuration-name>
</session>
<message-driven>
<ejb-name>TestMessage</ejb-name>
<destination-jndi-name>queue/MyTestQueue</destination-jndi-name>
<configuration-name>Standard Message Driven Bean</configuration-name>
</message-driven>
</enterprise-beans>
<resource-managers>
</resource-managers>
</jboss> -
Create EJB 3.0 Message Driven Bean on a Oracle JMS (AQ)
Hi, I need to develop a EJB 3.0 Message Driven Bean. The MDB has to work on a Oracle AQ using Oracle JMS. Is there any how-to document giving an example about this issue. Can you give an example how to create the JMS destination in OC4J (how to configure the Oracle JMS AQ in OC4j), issue the JMS destination via annotions (resource injection) in the MDB. Please give me a working example of the MDB and a test client to produce a message. Regards, Arjan Jorritsma
Check your ejb-jar.xml and see if it has the version of "2.1" there...
If the application was depending upon EJB 3.0 annotations but it had a ejb-jar.xml that had version set to "2.1" and there was no oracle specific descriptor (orion-ejb-jar.xml) to designate it use the resource adapter; It would expect JMS destination and connection factory that is required for a JMS-MDB set in the ejb-jar.xml. So try to change the ejb-jar.xml to update the version to "3.0", OC4J would have parsed the annotation and combined the metadata with ejb-jar.xml and it would work.
-Frances -
Exception in setting up message-driven bean container
hello,
I'm trying to deploy a single mdb and I'm getting an exception. I've tried closely following the way things are done with the mdb example in the samples AppServer7 directory. Am I missing something in one of my deployment descriptior files?
Thanks,
Robert
[17/Apr/2003:12:18:24] SEVERE ( 1832): MDB00030: [mdb2-simpleEjb:MessageProcessorBean]: Exception in setting up message-driven bean container: [[C4060]: Login failed.]
[17/Apr/2003:12:18:24] FINE ( 1832): MDB00018: [mdb2-simpleEjb:MessageProcessorBean]: Closing message-driven bean container connection
[17/Apr/2003:12:18:24] SEVERE ( 1832): MDB00017: [MessageProcessorBean]: Exception in creating message-driven bean container: [javax.jms.JMSSecurityException: [C4060]: Login failed.]
[17/Apr/2003:12:18:24] SEVERE ( 1832): javax.jms.JMSSecurityException
javax.jms.JMSSecurityException: [C4060]: Login failed.
at com.sun.messaging.jmq.jmsclient.ProtocolHandler.authenticate(ProtocolHandler.java:682)
at com.sun.messaging.jmq.jmsclient.ProtocolHandler.hello(ProtocolHandler.java:615)
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.hello(ConnectionImpl.java:238)
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.openConnection(ConnectionImpl.java:1512)
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.init(ConnectionImpl.java:403)
at com.sun.messaging.jmq.jmsclient.ConnectionImpl.<init>(ConnectionImpl.java:234)Hi,
You have not created the jms destination queue object
jms/Warehouse
Your server logs says it cannot find the destination queue object.It has got nothing to do with jndi name of your bean
Create jms destination queue object using
asadmin>create-jms-resource instance <instance_name> resourcetype javax.jms.Queue --property imqDestinationName=<NAme> jms/Warehouse
Then use list-jms-resources <instance_name> to
find if jms/Warehouse destionation queue object has been created.
Get back in case of any issues -
Creating a Message-Driven Bean in 10.1.3
I have been trying to create a Message-Driven Bean using the wizard but when I tried to deploy it to the stand-alone OC4J, I always got the null pointer exception:
Caused by: java.lang.NullPointerException
at com.evermind.server.ApplicationContext.unprivileged_lookup(ApplicationContext.java:227)
at com.evermind.server.ApplicationContext.lookup(ApplicationContext.java:199)
at com.evermind.server.ejb.deployment.EJBPackage.parseOrionAssemblyDescriptor(EJBPackage.java:973)
I am using EJB 2.1, the default jms/QueueConnectionFactory and jms/demoQueue.
I have been trying to find some simple examples and tutorials to do it but have been unsuccessful. Could somebody please point me to the right direction?After spending many hours reading the documentation, I have finally created a MDB that works. The original problem was due to the wizard not updating the orion-ejb-jar.xml file. This I had to do manually.
I am now trying to use this MDB to process a JMS Web Service, created by using the Web Service wizard. I use the demoQueue for the send operation and demoTopic for the receive operation. I could only get this to work provided I generated a J2EE 1.3 (Oracle) Web Service. If I generated a J2EE 1.4 (JAX-RPC), I had two problems:
1. If I only filled in the send but not the receive details, an error saying cannot locate the JMS resource was returned when I called a send operation. I shouldn't need to fill in the receive details as I was only trying to issue a send call.
2. If I also filled in the receive details, then the send request hanged.
In both cases, I could not see my MDB being activated.
If I switched to J2EE 1.3 option, then both the send and receive operations would work.
Could anybody give me any advices? -
Message-Driven Bean using @Resource annotation
I am trying to run a Message-Driven Bean very simple example in https://glassfish.dev.java.net/javaee5/ejb/examples/MDB.html
I configured MDBQueueConnectionFactory and MDBQueue properly on glassfish admin console.
I cannot run the example using @Resource annotation. I don't understand why.
@Resource(mappedName="MDBQueueConnectionFactory")
private static QueueConnectionFactory queueCF;
@Resource(mappedName="MDBQueue")
private static Queue mdbQueue;But I can run this example modifying the source code using InitialContext instance and looking up for JMS Resources.
InitialContext ctx = new InitialContext();
QueueConnectionFactory queueCF=(QueueConnectionFactory)ctx.lookup("MDBQueueConnectionFactory");
QueueConnection queueCon = queueCF.createQueueConnection();
Queue mdbQueue=(Queue)ctx.lookup("MDB");
queueSender.send(mdbQueue, msg);
...I want to figure out why @Resource annotation do not work well. Any help?
Thanks in advanced any help.Thanks for your reply.
The error that I get is a simple NullPointerException. Nothing else.
Like you said, I develop a servlet and I can use @Resource annotation without static reference, and it works.
public class TestMDB extends HttpServlet {
private static final long serialVersionUID = 1L;
@Resource(mappedName="MDBQueueConnectionFactory")
private QueueConnectionFactory queueCF;
@Resource(mappedName="MDB")
private Queue mdbQueue;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("TEST MDB "+queueCF);
QueueConnection queueCon;
try {
queueCon = queueCF.createQueueConnection();
QueueSession queueSession = queueCon.createQueueSession
(false, Session.AUTO_ACKNOWLEDGE);
QueueSender queueSender = queueSession.createSender(null);
TextMessage msg = queueSession.createTextMessage("hello");
queueSender.send(mdbQueue, msg);
out.println("Sent message to MDB");
queueCon.close();
} catch (JMSException e) {
e.printStackTrace();
}But my question were about using @Resource annotation on a standalone client. I always get NullPointerException.
public class MDBClient {
@Resource(mappedName="MDBQueueConnectionFactory")
private static QueueConnectionFactory queueCF;
@Resource(mappedName="MDB")
private static Queue mdbQueue;
public static void main(String args[]) {
try {
QueueConnection queueCon = queueCF.createQueueConnection();
QueueSession queueSession = queueCon.createQueueSession
(false, Session.AUTO_ACKNOWLEDGE);
QueueSender queueSender = queueSession.createSender(null);
TextMessage msg = queueSession.createTextMessage("hello");
queueSender.send(mdbQueue, msg);
System.out.println("Sent message to MDB");
queueCon.close();
} catch(Exception e) {
e.printStackTrace();
} -
My problem in Weblogic and Message Driven Bean for Topic
Hello to all
I used this page (http://www.ecomputercoach.com/index.php/component/content/article/90-weblogic-jms-queue-setup.html?showall=1)
for setup JMS Server, Queue, Connection Factory on Weblogic Server
and I created a Message Driven Bean ,I used those Queue , and all things was OK
But I wanted to setup a Topic and use it in this manner
I created a Topic like previous steps for setup Queue
(http://www.ecomputercoach.com/index.php/component/content/article/90-weblogic-jms-queue-setup.html?showall=1)
Except in Step 3 ,I selected Topic instead of Queue
then I created a Message Driven Bean in JDeveloper , my Message Driven Bean is like this:
@MessageDriven(mappedName = "jndi.testTopic")
<p>
public class aliJMS1_MessageDrivenEJBBean implements MessageListener {
public void onMessage(Message message) {
if(message instanceof TextMessage ){
TextMessage txtM=(TextMessage) message;
try{
System.out.println(txtM.getText());
}catch(Exception ex){
ex.printStackTrace();
</p>
When I deploy the Application , Weblogic shows me this error:
+<Aug 30, 2011 11:32:28 AM PDT> <Warning> <EJB> <BEA-010061> <The Message-Driven EJB: aliJMS1_MessageDrivenEJBBean is unable to connect to th+
e JMS destination: jndi.testTopic. The Error was:
+[EJB:011011]The Message-Driven EJB attempted to connect to the JMS destination with the JNDI name: jndi.testTopic. However, the object with+
the JNDI name: jndi.testTopic is not a JMS destination, or the destination found was of the wrong type (Topic or Queue).>
And when I send message to the topic The Message Dirven Bean dosen't work
But when I create an ordinary Java application like this (it uses that Tpoic) :
import java.io.*;
import java.util.*;
import javax.transaction.*;
import javax.naming.*;
import javax.jms.*;
public class TopicReceive implements MessageListener
public final static String JNDI_FACTORY =
"weblogic.jndi.WLInitialContextFactory";
public final static String JMS_FACTORY =
"jndi.testConnectionFactory";
public final static String TOPIC = "jndi.testTopic";
private TopicConnectionFactory tconFactory;
private TopicConnection tcon;
private TopicSession tsession;
private TopicSubscriber tsubscriber;
private Topic topic;
private boolean quit = false;
public void onMessage(Message msg) {
try {
String msgText;
if (msg instanceof TextMessage) {
msgText = ((TextMessage)msg).getText();
} else {
msgText = msg.toString();
System.out.println("JMS Message Received: " + msgText);
if (msgText.equalsIgnoreCase("quit")) {
synchronized (this) {
quit = true;
this.notifyAll();
} catch (JMSException jmse) {
jmse.printStackTrace();
public void init(Context ctx, String topicName) throws NamingException,
JMSException {
tconFactory = (TopicConnectionFactory)ctx.lookup(JMS_FACTORY);
tcon = tconFactory.createTopicConnection();
tsession = tcon.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
topic = (Topic)ctx.lookup(topicName);
tsubscriber = tsession.createSubscriber(topic);
tsubscriber.setMessageListener(this);
tcon.start();
public void close() throws JMSException {
tsubscriber.close();
tsession.close();
tcon.close();
public static void main(String[] args) throws Exception {
InitialContext ic = getInitialContext("t3://127.0.0.1:7001");
TopicReceive tr = new TopicReceive();
tr.init(ic, TOPIC);
System.out.println("JMS Ready To Receive Messages (To quit, send a \"quit\" message).");
synchronized (tr) {
while (!tr.quit) {
try {
tr.wait();
} catch (InterruptedException ie) {
tr.close();
private static InitialContext getInitialContext(String url) throws NamingException {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL, url);
env.put("weblogic.jndi.createIntermediateContexts", "true");
return new InitialContext(env);
It's OK and shows messages When I send message to the Topic
Now I want know why the Message Driven Bean doesn't work for those Topic
I want create a Message Driven Bean for Topic in the same way I created for Queue
I don't know what is problem , please advice me
ThanksCould you try adding a activationconfig to the message-driven bean, for example,
@MessageDriven(mappedName = "jndi.testTopic", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationName", propertyValue = "jndi.testTopic"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic")
public class aliJMS1_MessageDrivenEJBBean implements MessageListener {
public void onMessage(Message message) {
if(message instanceof TextMessage ){
TextMessage txtM=(TextMessage) message;
try{
System.out.println(txtM.getText());
}catch(Exception ex){
ex.printStackTrace();
}
Maybe you are looking for
-
I have a 4th gen nano that is loaded with my music library via a prior addition of Windows. I now have Windows 7 and when I access I-tunes and plug in my Ipod I get a list of my music but cannot play it. Open to suggestions on how to solve this thi
-
How to download web template easily?
Hi. I just want to download web template. of cause I can download template one by one. but there is too many template are server. is it possible download template by role or by other unit? I don't mind the way download whole template in server. regar
-
Hilfe, wie wechsele ich Photoshop cs6 vom alten laptop auf mein Neues?
Ich habe mir ein neues Notebook gekauft und möchte gerne mein Photoshop cs6 Students and teacher jetzt auf meine neues Notebook tun...wie mache ich das? danke...
-
Question Installing Crystal Reports
I had installed my VS2010 and installed crystal report click once, but when i add new item crystal report" it directs open an HTML site to install crystal report. As the following Crystal Reports for Visual Studio 2010 is a free download for adding
-
Loop a short flv before the live stream begins
Hi, Using FMS 3.02 and FME 2.5 is it possible to run a looping flv that the clients can see, before the live stream begins, and when the live stream finishes, an exit flv video plays? cheers