Message-driven bean "loses" MDB icon and status
Using JDev v11.1.1.5.0, when I create a MDB in my project using the wizard, it initially is displayed with the MDB icon next to it (a little envelope with a paperclip). However, about a second later, the icon changes to a normal 'Java' icon (coffee cup). I've also noticed that the MDB class does NOT appear in the Project Properties | EJB Module | Annotated EJB 3.0 Classes list box. The net result is that when the application is deployed, the MDB doesn't get registered to listen, so it never receives JMS messages.
I tried creating a new application from scratch, and created the exact same MDB. In this application, the icon 'sticks', and the class DOES show up in the "Annotated EJB 3.0 Classes" list box in the Project Properties dialog. (And, it will correctly register to receive JMS message on deployment.)
So, obviously something is different/wrong with my actual application that is preventing it from recognizing that the MDB class is an MDB. But, I don't know what. I've looked at all the settings in the Project Properties, looked at the actual project's .jpr file, etc., and can't see anything that would cause one application to not recognize MDBs.
Does anyone have any suggestions on how to figure out why my MDB classes aren't recognized as such in the one Application?
Here's the class I'm trying to use:
package com.acme;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;
@MessageDriven(mappedName = "acme.DefaultQueue")
public class MessageEJB implements MessageListener {
public void onMessage(Message message) {
// ... code here ...
Thanks,
Karl
For those that might have this problem down the road, here's what I found... It seems that there was a corrupt "cache" file or something in the project. Specifically, I had to delete the files in the <app_name>\<project_name>\classes\.data\00000000 folder. Once I deleted those files (mostly .jdb files), and restarted JDeveloper, the correct icon displayed next to my MDB classes, AND they also showed up correctly in the Project Properties | EJB Console pane.
I'm not sure what these files are, but I assume they are cache files and get re-created automatically by JDeveloper when needed. I hope this helps someone else that has the same problem!
Similar Messages
-
Message Driven Beans: how to receive and send in a single session?
Hello
How to receive and send JMS messages in a message driven bean using a single session?
Thanks.Are you referring to writing code within the onMessage method itself to receive JMS messages?
If so, that is not a pattern that is recommended, especially not in the case of a blocking JMS
receieve. If you must write an explicit JMS receive within an EJB component it's best to use
a "check the queue" approach where you give a very small timeout for the receive. That way
if the message is there it will be returned but if not the call will not block.
You'll also need to take the transactional settings of the onMessage method into account.
If your are sending a message and then waiting for a response, those two actions can
not be done within the same global transaction. For that, you'll need to either use
BMT and perform each in its own transaction or just not use global transactions at all,
in which case each send and receive operation will be atomic.
--ken -
Message Driven Beans with "Required" CMT and duplicate delivery of messages
Hi,
Let's pretend that an MDB is configured with CMT and the "Required" transaction attribute. Let's suppose that it has received a message and is busy processing it in a transaction that might take some time to complete.
Is a JEE container required to ensure that while a message is being handled by an MDB in a transaction that's neither completed nor rolled back, no dupes of the same message should be delivered to another instance of the same MDB?user572625 wrote:
Hi,
Let's pretend that an MDB is configured with CMT and the "Required" transaction attribute. Let's suppose that it has received a message and is busy processing it in a transaction that might take some time to complete.
Is a JEE container required to ensure that while a message is being handled by an MDB in a transaction that's neither completed nor rolled back, no dupes of the same message should be delivered to another instance of the same MDB?First, define "dupe".
Note that the main reason to use JEE technology over simpler frameworks is robustness, so if I understand your slightly vague question correctly, you can make the safe assumption that the answer is yes. -
WLS Cluster with Message Driven Beans and MQSeries on more than one Host
With the Examples of http://developer.bea.com/jmsproviders.jsp and http://developer.bea.com/jmsmdb.jsp
a MDB can be
configured to work with MQSeries with one WLS Server. This works only, if a Queuemanager
is started at the same Host that runs the WLS Server too.
And the QueueConnectionFactory (QCF) is configured to TRANSPORT(BIND).
In my configuration should be two WLS Servers and one JMS Queue (MQS) with the
Queuemanager.
A Message Driven Bean is deployed on both WLS Servers wich should get the Messages
of this Queue.
If one of the two WLS Servers fails the other WLS Server with the corresponding
MDB should get the Messages of the
MQSeries Queue.
If the QCF is configured to TRANSPORT(Client) the Message Driven Bean can't start
and the following Exception is thrown:
<Jul 18, 2001 3:52:49 PM CEST> <Error> <J2EE> <Error deploying EJB Component :
mdb_deployed
weblogic.ejb20.EJBDeploymentException: Error deploying Message-Driven EJB:; nested
exception is:
javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for
'btsun1a:TEST'
javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'btsun1a:TEST'
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:434)
I'm wondering, because their is a MQQueueManager on btsun1a; all Servers throws
the same Exception when the MDB is deployed.
The configuration of JMSadmin on both Hosts is the following:
dis qcf(myQCF2)
HOSTNAME(btsun1a)
CCSID(819)
TRANSPORT(CLIENT)
PORT(1414)
TEMPMODEL(SYSTEM.DEFAULT.MODEL.QUEUE)
QMANAGER(TEST)
CHANNEL(JAVA.CHANNEL)
VERSION(1)
dis q(myQueue)
CCSID(819)
PERSISTENCE(APP)
TARGCLIENT(JMS)
QUEUE(MYQUEUE)
EXPIRY(APP)
QMANAGER(TEST)
ENCODING(NATIVE)
VERSION(1)
PRIORITY(APP)
I think only TRANSPORT(CLIENT) can be used when i don't wan't to install a Queue
and a QueueManager on each WLS Server.
Does anybody know a problem of WLS 6.0 SP2 to cope with TRANSPORT(CLIENT)?
With the Examples of http://developer.bea.com/jmsproviders.jsp and http://developer.bea.com/jmsmdb.jsp
a MDB can be
configured to work with MQSeries with one WLS Server. This works only, if a Queuemanager
is started at the same Host that runs the WLS Server too.
And the QueueConnectionFactory (QCF) is configured to TRANSPORT(BIND).
In my configuration should be two WLS Servers and one JMS Queue (MQS) with the
Queuemanager.
A Message Driven Bean is deployed on both WLS Servers wich should get the Messages
of this Queue.
If one of the two WLS Servers fails the other WLS Server with the corresponding
MDB should get the Messages of the
MQSeries Queue.
If the QCF is configured to TRANSPORT(Client) the Message Driven Bean can't start
and the following Exception is thrown:
<Jul 18, 2001 3:52:49 PM CEST> <Error> <J2EE> <Error deploying EJB Component :
mdb_deployed
weblogic.ejb20.EJBDeploymentException: Error deploying Message-Driven EJB:; nested
exception is:
javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for
'btsun1a:TEST'
javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'btsun1a:TEST'
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:434)
I'm wondering, because their is a MQQueueManager on btsun1a; all Servers throws
the same Exception when the MDB is deployed.
The configuration of JMSadmin on both Hosts is the following:
dis qcf(myQCF2)
HOSTNAME(btsun1a)
CCSID(819)
TRANSPORT(CLIENT)
PORT(1414)
TEMPMODEL(SYSTEM.DEFAULT.MODEL.QUEUE)
QMANAGER(TEST)
CHANNEL(JAVA.CHANNEL)
VERSION(1)
dis q(myQueue)
CCSID(819)
PERSISTENCE(APP)
TARGCLIENT(JMS)
QUEUE(MYQUEUE)
EXPIRY(APP)
QMANAGER(TEST)
ENCODING(NATIVE)
VERSION(1)
PRIORITY(APP)
I think only TRANSPORT(CLIENT) can be used when i don't wan't to install a Queue
and a QueueManager on each WLS Server.
Does anybody know a problem of WLS 6.0 SP2 to cope with TRANSPORT(CLIENT)?
-
Problem deploying message driven bean using Log4j
Hello all.
Using JDeveloper 11.1.1.0.2, I'm having a problem with a message driven bean I've created and associated with a JMS queue.
I've created an EJB Module project in my application (in which some other projects exist), and created the bean. A simple test of the bean, sending a message through the jms queue and printing it on system.out in the mdb onMessage() worked just fine.
However, when I add apache commons logging to my mdb, things start to go wrong. Running the project on the integrated weblogic 10.3 server just fails during deployment, due to a NoClassDefFoundError on org/apache/log4j/Logger.
In project properties -> libraries and classpath, I've added a log4j library (Log4j-1.2.14.jar) next to Commons Logging 1.0.4 but it doesn't seem to matter anything.
The code of my message bean:
@MessageDriven(mappedName = "weblogic.wsee.DefaultQueue")
public class MyMessageBean implements MessageListener {
// logger
private static Log sLog = LogFactory.getLog(MyMessageBean.class);
public void ejbCreate() {
public void ejbRemove() {
public void onMessage(Message message) {
MapMessage mapmsg = null;
try {
if (message instanceof MapMessage) {
mapmsg = (MapMessage)message;
boolean msgRedelivered = mapmsg.getJMSRedelivered();
String msgId = mapmsg.getJMSMessageID();
if (!msgRedelivered) {
sLog.debug("****** Successfully received message " + msgId);
} else {
sLog.debug("****** Successfully received redelivered message " + msgId);
// Haal de inhoud op:
int testInt = mapmsg.getInt("TestInt");
sLog.debug("TestInt:" + testInt);
} else {
sLog.debug("Message of wrong type: " +
message.getClass().getName());
} catch (Exception e) {
sLog.error("Fout in verwerken",e);
}Does anybody have any clue as to what I might be doing wrong or missing out here?
The complete stacktrace:
5-aug-2009 12:54:44 oracle.adf.share.config.ADFConfigFactory cleanUpApplicationState
INFO: Cleaning up application state
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processWLSAnnotations(EjbAnnotationProcessor.java:1705)
at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.processWLSAnnotations(EjbDescriptorReaderImpl.java:346)
at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.createReadOnlyDescriptorFromJarFile(EjbDescriptorReaderImpl.java:192)
at weblogic.ejb.spi.EjbDescriptorFactory.createReadOnlyDescriptorFromJarFile(EjbDescriptorFactory.java:93)
at weblogic.ejb.container.deployer.EJBModule.loadEJBDescriptor(EJBModule.java:1198)
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:380)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:42)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:16)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:155)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:197)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:89)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:723)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1190)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:248)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:157)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:12)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:45)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@51b296 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Logger) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@51b296 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Logger))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at nl.justid.dolores.mdb.MyMessageBean.<clinit>(MyMessageBean.java:19)
... 32 more
Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@51b296 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Logger)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:413)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 36 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getConstructor0(Class.java:2699)
at java.lang.Class.getConstructor(Class.java:1657)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:410)
... 37 more
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 42 more
<5-aug-2009 12:54:44 uur CEST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1249469684085' for task '14'. Error is: 'weblogic.application.ModuleException: Exception preparing module: EJBModule(Dolores-MessageBeans-ejb)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
null.'
weblogic.application.ModuleException: Exception preparing module: EJBModule(Dolores-MessageBeans-ejb)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
null.
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:452)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
Truncated. see log file for complete stacktrace
java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
Truncated. see log file for complete stacktrace
>
5-aug-2009 12:54:44 oracle.adf.share.config.ADFConfigFactory cleanUpApplicationState
INFO: Cleaning up application state
<5-aug-2009 12:54:44 uur CEST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'Dolores'.>
<5-aug-2009 12:54:44 uur CEST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: Exception preparing module: EJBModule(Dolores-MessageBeans-ejb)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
null.
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:452)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
Truncated. see log file for complete stacktrace
java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
Truncated. see log file for complete stacktrace
>
[Deployer:149034]An exception occurred for task [Deployer:149026]deploy application Dolores on DefaultServer.: Exception preparing module: EJBModule(Dolores-MessageBeans-ejb)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
null..
weblogic.application.ModuleException: Exception preparing module: EJBModule(Dolores-MessageBeans-ejb)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
null.
#### Deployment incomplete. #### Aug 5, 2009 12:54:44 PM
oracle.jdeveloper.deploy.DeployException
at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.doDeploymentAction(Jsr88RemoteDeployer.java:247)
at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.deployImpl(Jsr88RemoteDeployer.java:157)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdeveloper.deploy.common.BatchDeployer.deployImpl(BatchDeployer.java:82)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:436)
at oracle.jdeveloper.deploy.DeploymentManager.deploy(DeploymentManager.java:209)
at oracle.jdevimpl.runner.adrs.AdrsStarter$5$1.run(AdrsStarter.java:1365)
Caused by: oracle.jdeveloper.deploy.DeployException
at oracle.jdevimpl.deploy.common.Jsr88DeploymentHelper.deployApplication(Jsr88DeploymentHelper.java:413)
at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.doDeploymentAction(Jsr88RemoteDeployer.java:238)
... 11 more
Caused by: oracle.jdeveloper.deploy.DeployException: Deployment Failed
at oracle.jdevimpl.deploy.common.Jsr88DeploymentHelper.deployApplication(Jsr88DeploymentHelper.java:395)
... 12 more
#### Cannot run application Dolores due to error deploying to DefaultServer.
[Application Dolores stopped and undeployed from Server Instance DefaultServer]Thanks in advance!
Greetings,
Eelse
Edited by: Eelse on Aug 5, 2009 1:57 PM
Edited by: Eelse on Aug 5, 2009 5:39 PMCreating a new deployment profile (EAR) and including the original deployment (JAR) and the needed libraries (in a lib-directory) solved the problem.
-
hi
i have some heavy calculating beans and i want that only one EJB is calculating at one time. can i do this by using Message Driven Beans? is it possible that the server creates only one Message Driven Bean at one time and gets the next one out of the queue when the old one finished calculating?
thanks, joIt is possible to set up that there should be only one mdb in the pool, but it's not quite what mdbs are intended for. Remember that this is an asynchronous message service, and you will not receive a reply after you put a message on the queue.
-
Message Driven Bean and transaction handling
We are using container managed transactions with MDB's running on OC4J version 10.1.2. We have two database serveres, both running Oracle 10g.
The MDB consume messages from the AQ-database through JMS (connected to a JDBC datasource registered as "jdbc/OracleAQDS").
The MDB onMessage() code update the second database, using a JDBC datasource registered as "jdbc/OracleDBDS".
We need atomic behaviour - if the MDB enforce a roll-back we want the updates aginst the second database to be rolled-back as well.
(1) Should we use XA-datasources since AQ and DB runs on two different servers or do the OC4J container "magically" provide two-phase-commit for us?
(2) If the MDB does a roll-back we would like to add an error record to a database table. Can we configure a third datasource and prevent if from beeing part of the container managed MDB roll-back?
(3) When the MDB force a roll-back, is there some way for us to override the retry-delay in our Java code? If we catch certain errors during processing in onMessage we know that it is not necessary to retry for at least one hour (while less severe errors should be retried in just seconds).{color:#008000}Hi Friends,
Thought of updating the answers for my questions in case somebody else would find it helpful.
{color}
{color:#999999}{color:#00ccff}I'm trying to make message driven bean and use the OnListener method.
But since I'm doing this for the first time I have very limited knowledge.
The following are my doubts :
1. Should I have a main function while using the MDB?{color}
{color:#008000} There is no need for any main function.{color}
{color:#00ccff}2. Is it mandatory to have JNDI setup done?
{color} {color}{color:#008000} There is no need for any JNDI setup done. But you need to configure the details on the
Websphere by creating valid entries inside Resources namely -
Queue Connection Factory, Queues and Listener Ports under the server.
Thanks,
Arun Prithviraj{color} -
WebLogic 10 and EJB 3.0 for Message Driven Bean
Hi,
I am trying to deploy Message Driven Bean using EJB3.0 on weblogic 10. I am using annotations and don't want to use deployment descriptors.
The Bean class:
CalculatorBean.java
import javax.ejb.*;
import javax.jms.*;
import java.sql.Timestamp;
import java.util.StringTokenizer;
@MessageDriven(activationConfig =
@ActivationConfigProperty(propertyName="destinationType",
propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination",
propertyValue="queue/mdb")
public class CalculatorBean implements MessageListener {
public void onMessage (Message msg) {
TextMessage tmsg=null;
try {
if (msg instanceof TextMessage) {
tmsg = (TextMessage) msg;
System.out.println
("MESSAGE BEAN1: Message received: "
+ tmsg.getText());
} else {
System.out.println
("Message of wrong type1: "
+ msg.getClass().getName());
catch (JMSException e) {
e.printStackTrace();
catch (Throwable te) {
te.printStackTrace();
My client:
import javax.naming.*;
import javax.naming.InitialContext;
import java.text.*;
import javax.jms.*;
public class MsgClient {
public static void main(String args[])
QueueConnection cnn=null;
QueueSender sender=null;
QueueSession sess=null;
Queue queue=null;
try {
java.util.Properties p = new java.util.Properties();
p.put("java.naming.factory.initial","weblogic.jndi.WLInitialContextFactory");
p.put("java.naming.provider.url","t3://10.6.74.79:7001");
Context ctx=new InitialContext(p);
//InitialContext ctx=new InitialContext(p);
queue = (Queue)ctx.lookup("queue/mdb");
QueueConnectionFactory factory = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
cnn = factory.createQueueConnection();
sess= cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
sender = sess.createSender(queue);
TextMessage message = sess.createTextMessage();
message.setText("This is message by Gurumurthy" );
System.out.println("Sending message: " +message.getText());
sender.send(message);
sess.close();
catch (Exception e)
e.printStackTrace();
I am compiling and creating jar file for this class. Then I am creating a .ear file for this.
The meta-inf/application.xml contains the following:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
<display-name>MDBWorking1</display-name>
<description>Application description</description>
<module>
<ejb>MDBWorking1.jar</ejb>
</module>
</application>
I don't want to use deployment descriptor (ejb-jar.xml or weblogic-ejb-jar-xml), because I want to utilize the annotation feature of EJB3.0
So, after creating the .ear file for this, and try to deploy on weblogic 10, I get the following error:
An error occurred during activation of changes, please see the log for details.
Exception preparing module: EJBModule(MDBWorking1.jar) Unable to deploy EJB: CalculatorBean from MDBWorking1.jar: [EJB:011113]Error: The Message Driven Bean 'CalculatorBean(Application: MDBWorking1, EJBComponent: MDBWorking1.jar)', does not have a message destination configured. The message destination must be set using a message-destination-link, destination-resource-link, destination-jndi-name or a resource-adapter-jndi-name.
Substituted for missing class [EJB - 11113]Error: The Message Driven Bean 'CalculatorBean(Application: MDBWorking1, EJBComponent: MDBWorking1.jar)', does not have a message destination configured. The message destination must be set using a message-destination-link, destination-resource-link, destination-jndi-name or a resource-adapter-jndi-name.
How to solve this?
Note:
I don't want to use Deployment Descriptor and all I want to use is EJB3.0's annotation feature.
Thanks,
GuruDear gurubbc,
I don't know if it still matters to you but you can use the javax.ejb.MessageDriven annotation to point your bean on your queue. I had the same issue like you but i could not solve it properly by switchihg to weblogic.ejb.MessageDriven.
Use the following annotation and it should work out:
@MessageDriven
(mappedName = "queue/mdb",
name = "CalculatorBean",
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
Here you can see that the mappedName is the JNDI name of the queue you are trying to connect to. The name is the name for your Bean, and the only property passed is the destination type.
Hope this helps.
Cheers,
Istvan -
Message Driven Bean and Distributed transaction
Hi ALL
I am developing an asynchronous application using MDB. My application flow is as follows:
1. From MDB onMessage i am calling a method MethodA that
a. calls a simple pojo1 where I am getting a Connection on XA enable datasource1 and executing Stored Procedure1 of DatabaseSchema1.
b. In that pojo without committing m closing the connection and coming back in MethodA.
c. Again from MethodA m calling a different pojo2 where I am getting a new Connection on XA enable datasource2 and executing Stored Procedure2 of
DatabaseSchema1. In this pojo also without committing m closing the connection and coming back in MethodA.
d. Again from MethodA m calling pojo1 where I am getting a new Connection on XA enable datasource1 and executing a different function of Stored Procedure1 of DatabaseSchema1.
Public class MDB{
Public void onMessage(��.)
Try{
Method1();
Catch(Exception x)
mdbcontext.setRollbackOnly();
Private void MethodA()
Call pojo1;
Call pojo2
Pojo1
Public void CallSP1()
Get connection from Datasource1 (shema1,user1, pwd1);
Call sp1();
//return without commit;
Pojo2
Public void CallSP2()
Get connection from Datasource2 (shema1,user2, pwd2);
Call sp2();
//return without commit;
SP1:
Insert table1
Savepoint 1
Insert into Table1
Rollback to 1
Insert a row
End SP1 (without commit)
SP2:
Insert table2
Savepoint 2
Update table2
Rollback to 2
Insert table2
End SP2 (without commit)
In ejb-jar.xml
Transaction type is Container
Transaction attribute is Required for all
Now problem is:
Case 1: success case when no exception is there at Java layer
SP1 works fine I mean there is only 2 inserts in Table 1
But In SP2 there are 3 inserts
Case 2: if an exception comes at Java layer
SP1 is fine
Rollback is not happening in SP2
In ejb-jar.xml transaction attributes is Required for all methods and transaction type is Container.
Backend is Oracle 10g and init.xa has already been run on that.
Will be very obliged if can have a single hint of the problem.
Both datasource are XA enable
Backend is Oracle 10g
Application server is WAS 6.0
Queue is WAS MQ 6.0
Thanks{color:#008000}Hi Friends,
Thought of updating the answers for my questions in case somebody else would find it helpful.
{color}
{color:#999999}{color:#00ccff}I'm trying to make message driven bean and use the OnListener method.
But since I'm doing this for the first time I have very limited knowledge.
The following are my doubts :
1. Should I have a main function while using the MDB?{color}
{color:#008000} There is no need for any main function.{color}
{color:#00ccff}2. Is it mandatory to have JNDI setup done?
{color} {color}{color:#008000} There is no need for any JNDI setup done. But you need to configure the details on the
Websphere by creating valid entries inside Resources namely -
Queue Connection Factory, Queues and Listener Ports under the server.
Thanks,
Arun Prithviraj{color} -
Message Driven Bean (MDB) for AQ Queue cannot start
I am working on the creating a message driven bean in Managed OC4J 10.1.3.0 to consume messages from AQ Queue. I am using a Oracle AS generic JMS connector and a resource adapter to create a message listener for the MDB.
I am able to make successful connections to the AQ and also consume messages, but if i try to start the MDB using the Oracle Application Server Web Admin console, the MDB fails to start, i have to restart the entire OC4J instance to restart the MDB.
The error on the Admin Console says "Failed to start MDB. Please see log for details." , but the problem is nothing is written to the log file.
I have tried setting the logging level in web admin console to FINER but still no new errors are written to the log file. I have checked the opmn logs, instance logs as well the home logs.
Please help, since this issue will further help us decide whether we need to go with the implementation or not.As far as I know XMLType JMS messages are not supported when using OJMS. They might be for OC4J 10.1.3, but I thought it's an AQ limitation rather than an OC4J one.. To be sure you might just log a TAR on Metalink.
hth,
Bastiaan -
Message driven beans and object binding
I want to write a message driven bean, and use javax.naming.Context's "bind(String,
Object)" method to bind the data to a key and eventually do a unbind(String) to
look up the data . Is binding/unbinding of object is allowed inside a message
driven bean or this violates the EJB2.0 spec? Also, does this have any negative
consequences if I use a Weblogic cluster as opposed to a single instance? Any
suggestions
Hi Austin,
- I don't know if it is "legal" in EJB 2.0
to call bind/unbind within an MDB. I
would assume so, but I'm not sure. You can try confirming with
the jndi and ejb newsgroups. Of course, if you don't
ask, then no one can tell you "no". ;-)
- Bind/unbind is a relatively expensive call performance-wise. I
suspect one might want to avoid doing too many of these per
second (the jndi newsgroup may be able to give pointers here.)
- Servers in a cluster do not instantly propagate bind/unbind info
to other servers in cluster, and JNDI may have trouble
efficiently supporting larger objects: both potential drawbacks
to using JNDI for data caching purposes.
Tom, BEA
Austin P wrote:
> I want to write a message driven bean, and use javax.naming.Context's "bind(String,
> Object)" method to bind the data to a key and eventually do a unbind(String) to
> look up the data . Is binding/unbinding of object is allowed inside a message
> driven bean or this violates the EJB2.0 spec? Also, does this have any negative
> consequences if I use a Weblogic cluster as opposed to a single instance? Any
> suggestions
-
Message driven bean and message style web service
Hi,
I'm trying to deploy a message style web service with a message driven EJB as
the receiver and am getting the following exception:
<Jan 22, 2002 10:51:06 AM PST> <Warning> <EJB> <MessageDrivenBean threw an Exception
in onMessage(). The exception was:
java.lang.ClassCastException: weblogic.jms.common.ObjectMessageImpl
java.lang.ClassCastException: weblogic.jms.common.ObjectMessageImpl
at credit.message.PostDefaultPayment.onMessage(PostDefaultPayment.java:24)
at weblogic.ejb20.internal.MDListener.execute(MDListener.java:254)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
public void onMessage(Message message) {
System.out.println("onMessage");
TextMessage textmessage = (TextMessage)message. // It is throwing
the exception on this line --looks pretty normal
Has anyone seen this before? Am I missing something?
Thanks,
TimHi Tim,
I think the problem is that you are assuming that the data type, of the message
argument to the onMessage(Message message) method in your MDB, is of type TextMessage.
I agree that this seems logical, especially since you passed "a string" to the
Message-style Web Service. However, this is not the case, because the WSDL uses
the "xsd:anyType" as the data type for any argument you pass to the send() method
;-) This maps to a java.lang.Object in the WebLogic Web Services implementation,
which is why you get the casting error. Try this instead:
public void onMessage(Message msg)
try
String msgText;
ObjectMessage objMessage = (ObjectMessage)msg;
msgText = (String)objMessage.getObject();
System.out.println("[PostDefaultPayment.onMessage(Message)] msgText=" + msgText);
System.out.println("[PostDefaultPayment.onMessage(Message)] msg.getJMSType()="
+ msg.getJMSType());
System.out.println("[PostDefaultPayment.onMessage(Message)] msg.getJMSCorrelationID()="
+ msg.getJMSCorrelationID());
System.out.println("[PostDefaultPayment.onMessage(Message)] msg.getJMSMessageID()="
+ msg.getJMSMessageID());
catch(Exception e)
e.printStackTrace();
Regards,
Mike Wooten
"Tim Uy" <[email protected]> wrote:
>
Hi,
I'm trying to deploy a message style web service with a message driven
EJB as
the receiver and am getting the following exception:
<Jan 22, 2002 10:51:06 AM PST> <Warning> <EJB> <MessageDrivenBean threw
an Exception
in onMessage(). The exception was:
java.lang.ClassCastException: weblogic.jms.common.ObjectMessageImpl
java.lang.ClassCastException: weblogic.jms.common.ObjectMessageImpl
at credit.message.PostDefaultPayment.onMessage(PostDefaultPayment.java:24)
at weblogic.ejb20.internal.MDListener.execute(MDListener.java:254)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
public void onMessage(Message message) {
System.out.println("onMessage");
TextMessage textmessage = (TextMessage)message. // It
is throwing
the exception on this line --looks pretty normal
Has anyone seen this before? Am I missing something?
Thanks,
Tim -
Message driven bean and JDBC Pool
I am working with weblogic 7.0
I have created a message driven bean the receives messages and store them in the
database.
for performance issue I have put the (SQL)Connection and a preparedStatement in
the ejbCreate() method ...and I close them in the ejbRemove() method...but I notice
that the ejbRemove dose not called ... even when I restart the weblogic7.0
I notice also that when I deploy the the Message driven bean ...it consume a number
of connections equals the number of instances created by weblogic.
if I redeploy the message driven bean ...the weblogic consume anthor connections
without free up the previous connections.
thank you for any help
Hi,
EjbRemove will never be called for a message driven bean as it follows the lifecycle
of a StatlessSession.
http://e-docs.bea.com/wls/docs61/ejb/EJB_environment.html#1039510
The container will call EJBRemove only when it gets a RemoteRuntimeException and
has to recycle the bean.
-Vimala Ranganathan
"eyad" <[email protected]> wrote:
>
>I am working with weblogic 7.0
>
>I have created a message driven bean the receives messages and store
>them in the
>database.
>for performance issue I have put the (SQL)Connection and a preparedStatement
>in
>the ejbCreate() method ...and I close them in the ejbRemove() method...but
>I notice
>that the ejbRemove dose not called ... even when I restart the weblogic7.0
>
>I notice also that when I deploy the the Message driven bean ...it consume
>a number
>of connections equals the number of instances created by weblogic.
>if I redeploy the message driven bean ...the weblogic consume anthor
>connections
>without free up the previous connections.
>thank you for any help
>
-
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();
} -
Message driven bean and security
Hi there!
I need to apply security capability during analyzing incoming messages.
Details:
I have an Entity bean with one method restricted by security to access. But
one of requirements is to provide this method call also in asynchronous way.
So I add Message Driven Bean that will call method of entity. But it's a
security violation.
So, can anybody advise how to provide security in conjunction with MDB?
Thank you in advance.Hi Max,
I think the problem is that you have no context with which to pass the security
credentials. You need someway to pass the credentials.
Kind Regards,
Richard Wallace
Senior Developer Relations Engineer
BEA Support.
"Max" <[email protected]> wrote:
Hi there!
I need to apply security capability during analyzing incoming messages.
Details:
I have an Entity bean with one method restricted by security to access.
But
one of requirements is to provide this method call also in asynchronous
way.
So I add Message Driven Bean that will call method of entity. But it's
a
security violation.
So, can anybody advise how to provide security in conjunction with MDB?
Thank you in advance.
Maybe you are looking for
-
I have a gif file which is animated when it's sent to me from a windows user. The gif is actually 10 images and when animated, it shows a coyote walking. I can't seem to get it to animate when I send it. Ideally, I'd like to add it to my signiture. A
-
Your photo library is either in use by another application or has become unreadable-- this is the message when I try to open iPhoto. What do I do?
-
IMPORT error : ORA-01631
Hi, I am impoting a dump file to a Oracle 8.1.7 database. Before the import, I have manually created all the tablespaces required. Now I'm getting an error while importing rows: ORA-01631: max # extents (100) reached in table <..> IMP-00018: partial
-
Can i access the context from out side of app server in jboss
Dear all, I am using jboss application server In jboss can i able do the following?. i instlled jboss appserver in C:/ drive, Shal i keep my context out side of the application server like D:/application/contenx1.war. Now. can i able to map this D:/a
-
I can't connect to iCloud or iTune account from my iPad.
I get verification request time out. Wi-Fi is on and I can sign in my account from my windows 7 PC. I synced iPad with my windows 7. It does not help. Basicly my iPad is dead. It doen't allow me to surf internet or receive latest emails. When syncing