Sample Message Driven Bean using Oracle Advance Queuing

Hi,
Can someone please provide me with sample MDB using Oracle Advance Queuing to Enqueue & Dequeue messages?
Thanks

Write your email Id .....I have got a test case which basically enqueus and dequeues the messages using Oracle9i AQ..
--Venky                                                                                                                                                                                                                                                                   

Similar Messages

  • 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 PM

    Creating a new deployment profile (EAR) and including the original deployment (JAR) and the needed libraries (in a lib-directory) solved the problem.

  • 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 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();
    }

  • Re: Send/receive messages from WLS to Oracle Advanced Queue.

     

    I am trying to send a message to a Queu (AQ) in OC4J.
              Since it works by using the common JMS api from a stand-alone java client, I thougt it should work also from a stateless EJB, but it doesn't!
              anyone an idea?
              

  • Broken link  - Code Samples   Message Driven Beans

    Hi,
    there is a problem with download file messagelogger.ear from
    http://www.oracle.com/technology/sample_code/tech/java/oc4j/htdocs/oc4jsamplecode/oc4j-demo-ejb.html

    This should be fixed now; please re-try...
    Cheers, OTN

  • Messenger service using message driven beans

    I need to implement a implement a messenger service. (using Messaging server, Message Queue, Message Clients and Message Driven Beans)
    using netbeans 5.5
    it should develop using EJB 3.0 architeture.
    Can pls tell...how should i start this.(Basic steps of doing this)
    Where should we write the Messaging server.(in a EJB 3.0 application...Is it?)
    Any tutorial regrading this....!

    EJBs and Message Driven Part.
    what should i develop first. Messaging server OR Message Queue
    How can i develop the Messaging Server. Do i need to use Message driven beans there?
    Message was edited by:
    jugp

  • 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,
    Guru

    Dear 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

  • 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 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Propagation between queues in Oracle Advanced Queuing

    We would like to connect two queues that reside in different database schemas/instances.
    We try to use the propagation feature of Oracle to achieve this.
    The queue-type is the same for both queues.
    Enqueuing is done with a recipient list in order to set multiple local subscribers for the messages that are put onto the queue.
    We would like to propagate between queues without changing the applications that write to originating queue and the other applications that read from the target queue.
    During our research we only found ways where we need to change the application that writes onto the queue, which is not acceptable for us. Also the list of subscribers needs to be different based on the message.
    Therefore I have the following question:
    - is there a way to set up propagation between queues in a way where we don't need to modify the sending application?
    - if not, is there a different way to connect two queues via a subscriber/consumer?

    Oracle8i for Linux does have AQ, although I haven't evaluated it
    yet. If you're still having trouble with the install, make sure
    you get the patch. A quicker and easier way to get Oracle8i up
    cheaply for evaluation is to download the NT version. I'm
    evaluating Oracle8i for both Linux and NT and the NT version is
    more stable.
    I would really appreciate hearing about your experiences with AQ
    on Oracle8 (8.0.4.3). I have several projects that we have been
    considering using AQ with. Please send me an email and tell me
    what problems / work-arounds you found.
    Christian Schroeder (guest) wrote:
    : Hello,
    : I still haven't managed to install 8i completely
    : (files with zero-length, wrong permissions, wrong JVM, ...),
    : anyway... -))
    : We are using Oracle Advanced Queuing under 8.0.4.3 on AIX in
    : a project at my company and I wondered if AQ is in 8i for
    Linux?
    : I really would like to evaluate it at home, since the AIX
    : AQ version has some bugs and restrictions which I really need
    to
    : get around.
    : My idea is to get 8i for AIX, but I wouldn't buy it if the
    : queuing is still unstable.
    : The 8.0.4 documentation states that one will get AQ in the
    : Enterprise Edition with message-type 'RAW' and the Objects
    Option
    : will add full functionality if also purchased. I didn't find
    : any comments on AQ in the installation guide.
    : Regards,
    : Christian
    null

  • "Message Driven Bean" doesn't work with Sun App Server

    Hello all,
    i have a little bit problems, running a simple "Message Driven Bean" under the Sun App Server. The deployment of it works fine, but after starting the SUN App Server i get the following error message:
    An error occurred during the message-driven beancontainer initialization at runtime. The most common cause for this is that the physical resource(e.g. Queue) from which the message-driven bean is consuming either does not exist or has been configured incorrectly. Another common error is that the message-driven bean implementation class does not correctly implement the required javax.ejb.MessageBean or MessageListener interfaces.
    Has anybody a workaround for this problem?
    The queue seems to be correctly installed. A simple client programm from the Sun Tutorial (Consumer & Producer) works fine without any Errors or Exceptions.
    I am a little bit confused, because the queue seems to work with the client programms but not with a MDB running on the SUN App Server.
    Thanks for you help!
    Greetings
    Manuel

    Hello Mr Manuel!
    could you plz help me with the steps for creating a message driven bean using netbeans ver 5.0(with Sun Java� System Application Server Platform Edition 8.2 )
    I just know how to work with Session beans & Entity Bean, and am try to learn to work on Message Driven Beans too. there are no proper tutorials where i can find steps for creating these..
    I need the steps from the scratch.,like creating QueueConnection Factory & Destination etc..
    It will be gr8 if you can help me with this at the earliest .
    Thank you
    Bye

  • Javax.naming.NameNotFoundException while Message driven bean

    I am adding a message driven bean in to my EJB application and trying
    to deploy it in the WebLogic 6.0 server.
    Now please let me know is there any other step i am missing.
    1) This is what i have added in my ejb-jar.xml
    <enterprise-beans>
         <message-driven>
              <description>no description</description>
              <display-name>ActivatorBean</display-name>
              <ejb-name>ActivatorBean</ejb-name>
              <ejb-class>com.savvion.bizlogic.server.ActivatorBean</ejb-class>
              <transaction-type>Container</transaction-type>
              <message-driven-destination>
                   <jms-destination-type>javax.jms.Queue</jms-destination-type>
              </message-driven-destination>
              <security-identity>
                   <description/>
                   <run-as-specified-identity>
                   <description/>
                   <role-name/>
                   </run-as-specified-identity>
              </security-identity>
         </message-driven>
    2) I am adding this is in the weblogic-ejb.xml
    <weblogic-enterprise-bean>
         <ejb-name>ActivatorBean</ejb-name>
         <message-driven-descriptor>
                             <destination-jndi-name>MyMessageQueueFactory</destination-jndi-name>
         </message-driven-descriptor>
         <transaction-descriptor>
              <trans-timeout-seconds>1200</trans-timeout-seconds>
         </transaction-descriptor>
         <jndi-name>MessageQueue</jndi-name>
         </weblogic-enterprise-bean>
    anything else which needs to added in WebLogic-ejb.xml or in config.xml
    because as per the following error message there should be some
    entry in config.xml.
    onemore thing i am little bit confused in
    <destination-jndi-name>MyMessageQueueFactory</destination-jndi-name>
    and
    <jndi-name>MessageQueue</jndi-name>
    and when i deploed this in WebLogic got this error message on the
    prompt
    <Error> <J2EE> <Error deploying EJB Component : LEngine
    weblogic.ejb20.EJBDeploymentException: Error deploying Message-Driven
    Bean,
    couldn't find Queue 'MyMessageQueueFactory'. Make sure it was declared
    in your config.xml.
    ; nested exception is:
    javax.naming.NameNotFoundException: Unable to resolve MyMessageQueueFactory.
    Resolved: '' Unresolved:'MyMessageQueueFactory' ; remaining name
    javax.naming.NameNotFoundException: Unable to resolve MyMessageQueueFactory.
    Reso
    lved: '' Unresolved:'MyMessageQueueFactory' ; remaining name ''
    <<no stack trace available>>
    >
    <Error> <J2EE> <Error deploying application
    WFEngine: Could not deploy: 'xyz.jar'
    Possible reasons include:
    1. The bean or an interface class has been modified but
    the deployment descriptor has not been updated
    2. The database mappings in the deployment descriptor do not
    match the database definition
    3. The jar file is not a valid jar file
    4. The jar file does not contain a valid bean>
    Thanks
    Naresh

    I am adding a message driven bean in to my EJB application and trying
    to deploy it in the WebLogic 6.0 server.
    Now please let me know is there any other step i am missing.
    1) This is what i have added in my ejb-jar.xml
    <enterprise-beans>
         <message-driven>
              <description>no description</description>
              <display-name>ActivatorBean</display-name>
              <ejb-name>ActivatorBean</ejb-name>
              <ejb-class>com.savvion.bizlogic.server.ActivatorBean</ejb-class>
              <transaction-type>Container</transaction-type>
              <message-driven-destination>
                   <jms-destination-type>javax.jms.Queue</jms-destination-type>
              </message-driven-destination>
              <security-identity>
                   <description/>
                   <run-as-specified-identity>
                   <description/>
                   <role-name/>
                   </run-as-specified-identity>
              </security-identity>
         </message-driven>
    2) I am adding this is in the weblogic-ejb.xml
    <weblogic-enterprise-bean>
         <ejb-name>ActivatorBean</ejb-name>
         <message-driven-descriptor>
                             <destination-jndi-name>MyMessageQueueFactory</destination-jndi-name>
         </message-driven-descriptor>
         <transaction-descriptor>
              <trans-timeout-seconds>1200</trans-timeout-seconds>
         </transaction-descriptor>
         <jndi-name>MessageQueue</jndi-name>
         </weblogic-enterprise-bean>
    anything else which needs to added in WebLogic-ejb.xml or in config.xml
    because as per the following error message there should be some
    entry in config.xml.
    onemore thing i am little bit confused in
    <destination-jndi-name>MyMessageQueueFactory</destination-jndi-name>
    and
    <jndi-name>MessageQueue</jndi-name>
    and when i deploed this in WebLogic got this error message on the
    prompt
    <Error> <J2EE> <Error deploying EJB Component : LEngine
    weblogic.ejb20.EJBDeploymentException: Error deploying Message-Driven
    Bean,
    couldn't find Queue 'MyMessageQueueFactory'. Make sure it was declared
    in your config.xml.
    ; nested exception is:
    javax.naming.NameNotFoundException: Unable to resolve MyMessageQueueFactory.
    Resolved: '' Unresolved:'MyMessageQueueFactory' ; remaining name
    javax.naming.NameNotFoundException: Unable to resolve MyMessageQueueFactory.
    Reso
    lved: '' Unresolved:'MyMessageQueueFactory' ; remaining name ''
    <<no stack trace available>>
    >
    <Error> <J2EE> <Error deploying application
    WFEngine: Could not deploy: 'xyz.jar'
    Possible reasons include:
    1. The bean or an interface class has been modified but
    the deployment descriptor has not been updated
    2. The database mappings in the deployment descriptor do not
    match the database definition
    3. The jar file is not a valid jar file
    4. The jar file does not contain a valid bean>
    Thanks
    Naresh

  • Message Driven bean: message always removed from queue

    We use MDB to dequeue messages from database queue (AQ) and want to handle errors: if the transaction rolls back, message should have retry_count updated and after defined retries should move to exception queue.
    The problem is, that with all combinations of transactions settings, the message is removed from queue before onMessage is called. If I use Container managed transactions with Mandatory transaction attribute, call to setRollbackOnly fails with message "java.lang.IllegalStateException: Cannot call setRollbackOnly() current thread is NOT associated with a transaction."
    How can I write a MDB, which can commit or rollback message depending on whether exception is or is not thrown? I use JDev 10.1.3.
    Thanks,
    Viliam
    Here are my files:
    ejb-jar.xml:
    <?xml version = '1.0' encoding = 'windows-1250'?>
    <!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>
        <message-driven>
          <description>Message Driven Bean</description>
          <display-name>SendSMSBean</display-name>
          <ejb-name>SendSMSBean</ejb-name>
          <ejb-class>sk.transacty.cc.ejb.SendSMSBeanBean</ejb-class>
          <transaction-type>Container</transaction-type>
          <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
          <message-driven-destination>
            <destination-type>javax.jms.Queue</destination-type>
          </message-driven-destination>
          <resource-ref>
            <res-ref-name>jdbc/CCDataSource</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
          </resource-ref>
        </message-driven>
      </enterprise-beans>
      <assembly-descriptor>
        <container-transaction>
          <method>
            <ejb-name>SendSMSBean</ejb-name>
            <method-name>*</method-name>
          </method>
          <trans-attribute>Mandatory</trans-attribute>
        </container-transaction>
      </assembly-descriptor>
    </ejb-jar>orion-ejb-jar.xml:
    <?xml version = '1.0' encoding = 'windows-1250'?>
    <!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" "http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd">
    <orion-ejb-jar>
      <enterprise-beans>
        <message-driven-deployment max-instances="1" name="SendSMSBean" connection-factory-location="java:comp/resource/jmsAQ/QueueConnectionFactories/aqQue" destination-location="java:comp/resource/jmsAQ/Queues/msg_queue" listener-threads="1" min-instances="0"/>
      </enterprise-beans>
      <assembly-descriptor>
        <default-method-access>
          <security-role-mapping impliesAll="true" name="<default-ejb-caller-role>"/>
        </default-method-access>
      </assembly-descriptor>
    </orion-ejb-jar>

    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

  • 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

Maybe you are looking for