Message transform bean

Need assistance for this structure :
header
        node
                string (repeats numerous times)
need a content conversion using MTB for this for receiver file adapter
Thanks

Hi Kiran,
Try this
Transform.Class          ---          com.sap.aii.messaging.adapter.Conversion
Transform.ContentType      -
          text/plain;charset=utf-8
xml.Detail.endSeparator     -
          'nl'
xml.Detail.fieldFixedLengths     -
     <String lenghts>
xml.conversionType     ---     StructXML2Plain
xml.recordsetStructure     ---          node

Similar Messages

  • Seeburger SFTP - Message Transformation Bean Issue

    Using Seeburger SFTP adapter to read a tab delimited file. File is being successfully read; however, content conversion need to be performed to convert the file content to XML.  Thus, using Message Transformation Bean with the following module parameters.  
    Issue: It is reading the file as is u2013 there is not content conversion is being performed. 
    Processing Sequence:
    1      localejbs/Seeburger/solution/sftp                Local Enterprise Bean     solutionid
    2     localejbs/AF_Modules/MessageTransformBean          Local Enterprise Bean     mtb
    3     localejbs/CallSapAdapter                    Local Enterprise Bean     exit
    Module Configuration:
    mtb          Transform.Class                          com.sap.aii.messaging.adapter.Conversion
    mtb           Transform.ContentType               text/xml;charset=utf-8
    mtb          xml.conversionType               SimplePlain2XML
    mtb          xml.documentName               XXX_EXPENSES_mt
    mtb          xml.fieldContentFormatting     trim    
    mtb          xml.fieldNames                    FIELD1,FIELD2,FIELD3,FIELD4
    mtb          xml.fieldSeparator               '0x09'
    mtb          xml.processFieldNames               fromConfiguration
    mtb          xml.structureTitle               RECORD
    The following the noticeable details on CC:
    Error type: TASK_ERROR >> Error date: 12/5/10 12:42 PM >> Description: Polling finished with errors. 1 file initiated. 1 file not polled due to errors.
    Message initiated succesfully
    Error type: TASK_ERROR >> Error date:  >> Description: File <amex.dat> could not be polled  from directory </usr/sap/interfaces/FTP1/send> on host <sapdv1ci>; Reason: removeFile: File xxx.dat could not be removed. SftpStatusCode: SSH_FX_NO_SUCH_FILE; Reason: No such file
    Any help is greatly appreciated.
    Thanks

    Check the following...
    1. Make sure you don't have any scripts running at your target folder.
    Example: If you are reading your file from TEST folder make sure you don't have any scripts running here.
    2. In File Setting section make sure you uncheck Delete file checkbok.
    Regards
    Srikanth Baki

  • Error using Message Transform Bean in SimplePlain2XML in file sender

    Hi guys.
    Im using  Message Transform Bean to convert from file to xml in file sender.
    My structure look like this:
    ROW (1..n)
    >TRANSPORTES (1)
    >ENTREGAS (1..n)
    And I have configured the module like this:
    AF_Modules/MessageTransformBean - transform
    transform - Transform.Class - com.sap.aii.messaging.adapter.Conversion
    transform - xml.ENTREGAS.endSeparator - 'nl'
    transform - xml.ENTREGAS.fieldFixedLengths - 1,30
    transform - xml.ENTREGAS.fieldNames - TIPO,NUM_ENTREGA
    transform - xml.ENTREGAS.keyFieldValue - E
    transform - xml.TRANSPORTES.endSeparator - 'nl'
    transform - xml.TRANSPORTES.fieldFixedLengths - 1,30
    transform - xml.TRANSPORTES.fieldNames - TIPO,NUM_TRANSPORTE
    transform - xml.TRANSPORTES.keyFieldValue - T
    transform - xml.conversionType - SimplePlain2XML
    transform - xml.documentName - MPrueba_Zip
    transform - xml.documentNamespace - http:/XXXXXX.es/XXXX/sap/prueba
    transform - xml.keyFieldName - TIPO
    transform - xml.processFieldNames - fromConfiguration
    transform - xml.recordsetName - row
    transform - xml.recordsetStructure - TRANSPORTES,1,ENTREGAS,*
    Im getting this error and I don´t know why:
    Error: com.sap.aii.messaging.adapter.trans.TransformException: Transformer Conversion3.0.5227 Error initializing Class: java.lang.Exception: java.lang.Exception: java.lang.Exception: Error(s) in XML conversion parameters found: (4408) Parameter 'xml.fieldFixedLengths' or 'xml.fieldSeparator' is missing (4409) Parameter 'xml.fieldNames' is missing (4403) ; nested exception caused by: java.lang.Exception: java.lang.Exception: java.lang.Exception: Error(s) in XML conversion parameters found: (4408) Parameter 'xml.fieldFixedLengths' or 'xml.fieldSeparator' is missing (4409) Parameter 'xml.fieldNames' is missing (4403)
    Why am i doing wrong?????
    Thanks a lot!!!

    Hi
    For Complex conversion you have to use xml.conversionType as "StructPlain2XML"
    http://help.sap.com/saphelp_nw04/helpdata/en/24/4cad3baabd4737bab64d0201bc0c6c/content.htm
    Regards
    Ramg

  • Standard Adapter Module "Message Transform Bean" in Seeburger AS2 Adapter

    Hi,
        I am calling standard adapter module "Message Transform Bean" in seeburger AS2 Sender adapter where I am getting the following error :
    ClassNotFoundException:com.sap.aii.messaging.adapter.Conversion . Can anybody help me on this. Appreciate for your respoinse.
    Thank you,
    Mallikarjuna Rao M

    Hi,
    Thank you for your replies I manage to get NWA dump for this issue.. Here is the log
    Could not call backend system: Error in ???-module:Transform: failed to set up the transformer for channel 6857fd15f84d3e23a7b0f51ca1851b20; modkey TXT2XML; caused by java.lang.ClassNotFoundException: com.sap.aii.messaging.adapter.Conversion
    Loader Info -
    ClassLoader name: [sap.com/com.sap.aii.af.mod.trans.app]
    Living status: alive
    Direct parent loaders:
       [system:Frame]
       [service:servlet_jsp]
       [service:ejb]
       [library:engine.j2ee14.facade]
       [library:com.sap.base.technology.facade]
       [library:com.sap.aii.af.lib]
       [library:com.sap.aii.af.sdk.lib]
       [service:com.sap.aii.af.cpa.svc]
       [service:com.sap.aii.af.svc]
       [service:com.sap.aii.adapter.xi.svc]
       [library:com.sap.aii.adapter.lib]
    Resources:
       D:\usr\sap\BWD\DVEBMGS00\j2ee\cluster\apps\sap.com\com.sap.aii.af.mod.trans.app\EJBContainer\applicationjars\com.sap.aii.af.mod.trans.ejb.jar
    [LOC: com.seeburger.as2.impl.SHCInitiatorProcessor.initiateToBackend] Caused by: Error in ???-module:Transform: failed to set up the transformer for channel 6857fd15f84d3e23a7b0f51ca1851b20; modkey TXT2XML; caused by java.lang.ClassNotFoundException: com.sap.aii.messaging.adapter.Conversion
    Loader Info -
    ClassLoader name: [sap.com/com.sap.aii.af.mod.trans.app]
    Living status: alive
    Direct parent loaders:
       [system:Frame]
       [service:servlet_jsp]
       [service:ejb]
       [library:engine.j2ee14.facade]
       [library:com.sap.base.technology.facade]
       [library:com.sap.aii.af.lib]
       [library:com.sap.aii.af.sdk.lib]
       [service:com.sap.aii.af.cpa.svc]
       [service:com.sap.aii.af.svc]
       [service:com.sap.aii.adapter.xi.svc]
       [library:com.sap.aii.adapter.lib]
    Resources:
       D:\usr\sap\BWD\DVEBMGS00\j2ee\cluster\apps\sap.com\com.sap.aii.af.mod.trans.app\EJBContainer\applicationjars\com.sap.aii.af.mod.trans.ejb.jar
    at com.seeburger.xi.api.module.impl.nw71.SeeModuleProcessorLocal71.process(SeeModuleProcessorLocal71.java:55)
    at com.seeburger.xi.connector.fw.InitiationThread.run(InitiationThread.java:101)
    at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:152)
    at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:247)
    Caused by: java.lang.ClassNotFoundException: com.sap.aii.messaging.adapter.Conversion
    Loader Info -
    ClassLoader name: [sap.com/com.sap.aii.af.mod.trans.app]
    Living status: alive
    Direct parent loaders:
       [system:Frame]
       [service:servlet_jsp]
       [service:ejb]
       [library:engine.j2ee14.facade]
       [library:com.sap.base.technology.facade]
       [library:com.sap.aii.af.lib]
       [library:com.sap.aii.af.sdk.lib]
       [service:com.sap.aii.af.cpa.svc]
       [service:com.sap.aii.af.svc]
       [service:com.sap.aii.adapter.xi.svc]
       [library:com.sap.aii.adapter.lib]
    Resources:
       D:\usr\sap\BWD\DVEBMGS00\j2ee\cluster\apps\sap.com\com.sap.aii.af.mod.trans.app\EJBContainer\applicationjars\com.sap.aii.af.mod.trans.ejb.jar
    at com.sap.engine.boot.loader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:259)
    at com.sap.engine.boot.loader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:228)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:353)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at com.sap.aii.af.modules.trans.MessageTransformBean.loadClass(MessageTransformBean.java:121)
    at com.sap.aii.af.modules.trans.MessageTransformBean.setup(MessageTransformBean.java:178)
    at com.sap.aii.af.modules.trans.MessageTransformBean.process(MessageTransformBean.java:346)
    at sun.reflect.GeneratedMethodAccessor484_10002.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.sap.engine.services.ejb3.runtime.impl.RequestInvocationContext.proceedFinal(RequestInvocationContext.java:43)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:166)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatesTransition.invoke(Interceptors_StatesTransition.java:19)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Resource.invoke(Interceptors_Resource.java:71)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.doWorkWithAttribute(Interceptors_Transaction.java:38)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.invoke(Interceptors_Transaction.java:22)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:189)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatelessInstanceGetter.invoke(Interceptors_StatelessInstanceGetter.java:16)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_SecurityCheck.invoke(Interceptors_SecurityCheck.java:21)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_ExceptionTracer.invoke(Interceptors_ExceptionTracer.java:16)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177)
    at com.sap.engine.services.ejb3.runtime.impl.DefaultInvocationChainsManager.startChain(DefaultInvocationChainsManager.java:133)
    at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke(DefaultEJBProxyInvocationHandler.java:164)
    at $Proxy2674_10002.process(Unknown Source)
    at com.sap.aii.af.app.mp.ejb.ModuleProcessorBean.process(ModuleProcessorBean.java:249)
    at sun.reflect.GeneratedMethodAccessor311_10002.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at com.sap.engine.services.ejb3.runtime.impl.RequestInvocationContext.proceedFinal(RequestInvocationContext.java:43)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:166)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatesTransition.invoke(Interceptors_StatesTransition.java:19)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Resource.invoke(Interceptors_Resource.java:71)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.doWorkWithAttribute(Interceptors_Transaction.java:38)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.invoke(Interceptors_Transaction.java:22)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:189)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatelessInstanceGetter.invoke(Interceptors_StatelessInstanceGetter.java:16)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_SecurityCheck.invoke(Interceptors_SecurityCheck.java:21)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177)
    at com.sap.engine.services.ejb3.runtime.impl.Interceptors_ExceptionTracer.invoke(Interceptors_ExceptionTracer.java:16)
    at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:177)
    at com.sap.engine.services.ejb3.runtime.impl.DefaultInvocationChainsManager.startChain(DefaultInvocationChainsManager.java:133)
    at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke(DefaultEJBProxyInvocationHandler.java:164)
    at $Proxy102_10002.process(Unknown Source)
    at com.seeburger.xi.api.module.impl.nw71.SeeModuleProcessorLocal71.process(SeeModuleProcessorLocal71.java:43)
    Waiting for your valuable inputs on this.
    Thank you,
    Mallikarjuna Rao M

  • Error while using Message transform Bean

    Hi All,
    I am using message transform bean in the receiver channel. The structure I have used is as follows.
    Transform.Class    com.sap.aii.messaging.adapter.Conversion
    Transform.ContentType    text/xml;charset=utf-8
    xml.conversionType   SimplePlain2XML
    xml.documentName      MT_DataExtract
    xml.documentNamespace    http://ce.corp.com/xi/ACA/HR_INT_XXX/EmployerReporting
    xml.endSeperator   'nl'
    xml.fieldNames     pernr,l_name,f_name,m_name,perid,p_subarea,e_group,e_subgroup,status,c_code,pa_text,str_add,h_city,h_state,h_zcode,z1_org,z2_org,rep_hours
    xml.fieldSeperator   ,
    xml.singleRecordType      Employee_Details
    XML structure would be as
    <Employee_Details> 
    <pernr></pernr>
    - <l_name></l_name>  <f_name></f_name>
    <m_name />
    <perid></perid>
    <p_subarea></p_subarea>
    <e_group></e_group>
    <e_subgrp></e_subgrp>
    <status></status>
    <c_code></c_code>
    <pa_text></pa_text>
    <str_add></str_add>
    <h_city></h_city>
    <h_state></h_state>
    <h_zcode></h_zcode>
    <z1_org></z1_org>
    <z2_org></z2_org>
    <rep_hours></rep_hours>
    </Employee_Details>
    I am getting error as Delivering the message to the application using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.aii.af.lib.util.configuration.ConfigurationExceptionSet: The following configuration errors were detected: - Either recordTypes or singleRecordType needs to be set .
    Please help me to resolve this error.
    Thanks,
    Shankul

    It's not just that parameter, Please change your configuration as explained in the blog i shared.
    There is a example which has expected structure and the conversion parameters.
    Your target xml should be like below.
    The XML structure of the source file should follow the same structure as the result of the SimplePlain2XML conversion.
    <resultset>
    <row>
    <column-name1>ABC</column-name1>
    <column-name2>12345</column-name2>
    <column-name3>Text1</column-name3>
    </row>
    <row>
    <column-name1>XYZ</column-name1>
    <column-name2>67890</column-name2>
    <column-name3>Text2 Text3</column-name3>
    </row>
    </resultset>
    Examples of Content Conversion Using MessageTransformBean (SAP Library - SAP Exchange Infrastructure)

  • Message Transformation Bean - Usage of external classes

    Hi SDNers,
    I am planning to write an external Java class to be loaded from AF_Modules/MessageTransformBean . The idea is simple, I want my class to handle an extra level of hierarchy in FCC process. I know writing the Java class which is as generic as the one provided by SAP is too complex. But I just want it for some specific requirements, so I dont intend to make it as a generic class.
    Should the external class that I write implement the interface Transform? If so, what is the jar file that contains this interface and where can I find this jar file in my XI installation?
    Also, what is the jar file that contains the standard class com.sap.aii.messaging.adapter.Conversion that gets loaded by default while using the MessageTransformBean?
    If you have already tried with similar requirements, please share your experience on the same.
    Thanks
    Jaishankar

    You can use the same module in J2SE and J2EE adapter without change.
    I recommend to install a J2SE adapter engine on a local PC for testing.
    I have found a sample code from previous tests:
    package sample;
    import com.sap.aii.messaging.adapter.Parameter;
    import com.sap.aii.messaging.adapter.trans.Transform;
    import com.sap.aii.messaging.adapter.trans.*;
    import java.io.*;
    public class MyModule extends Transform {
    Parameter parameter;
    String filename;
         public void init(TransformConfig config) throws TransformException{
                   super.init(config);
                   parameter = (Parameter) config.getParameters("Parameter");
                   filename = (String) parameter.get("filename");
         // obligatory method service
         public void service(TransformRequest request, TransformResponse response) throws TransformException {
              // Get the input stream for request message
              InputStream in = (InputStream) request.getMessage();
              // Get output stream for response message
              OutputStream out = (OutputStream) response.getMessage(Transform.MT_OutputStream);
              try{
                   execute(in,out);
              } catch (Exception e) {
                   throw new TransformException("TransformException: Error converting Message " + e.getMessage(), e);
         public void execute(InputStream in, OutputStream out) throws Exception{
              String filename = (String) transformConfig.getParameters("FileName");
              if (filename == null){
                   filename = "notfound.txt";
              // open file stream
              OutputStream fileOut = new FileOutputStream(new File(filename));
              // copy input stream to output stream and to file
              int c;
              while ((c = in.read()) != -1) {
                        fileOut.write(c);
                        out.write(c);
    //     main Methode, for local testing. A local XML file is expected.
          public static void main (String[] args) {
               try {
                    // Define Input stream and output stream from file
                    InputStream in = new FileInputStream(new File("source.xml"));
                    OutputStream out = new FileOutputStream(new File("target.xml"));
                    // call Mapping
                    MyModule map = new MyModule();
                    map.execute(in,out);
               } catch (Throwable t) {
                    t.printStackTrace();
               System.exit(0);

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

  • How to transaction in the message driven bean?

              hello
              i write a message driven bean,that monitor the weblogic message queue,when a "Order"
              object is witten to the queue,the mdb get it and write it to a entity bean "Orderinfo".all
              of above logic is within the "onMessage" method of the mdb.
              i want to encapsulate the flow in a transaction,see my code snippet of the onMessage
              method:
              ObjectMessage objMsg = (ObjectMessage) msg;
              OrderVO orderVO = (OrderVO) objMsg.getObject();
              System.out.println(orderVO.booklist);
              OrderinfoHome orderinfoHome = (OrderinfoHome) ctx.lookup(
              "java:/comp/env/orderinfo");
              Orderinfo orderinfo = orderinfoHome.create(orderVO.orderID);
              orderinfo.setAddress(orderVO.address);
              orderinfo.setCustname(orderVO.custName);
              orderinfo.setEmail(orderVO.email);
              orderinfo.setBooklist(orderVO.booklist);
              orderinfo.setPrice(new BigDecimal(orderVO.price));
              and deploy descriptor snippet(ejb-jar.xml):
              <assembly-descriptor>
              <container-transaction>
              <method>
              <ejb-name>orderMDB</ejb-name>
              <method-name>*</method-name>
              </method>
              <trans-attribute>Required</trans-attribute>
              </container-transaction>
              </assembly-descriptor>
              i think during this transaction,there are two action:geting the object from the
              queue and saving it to entity bean.in order to test the transaction,i modify the
              jndi name of entity bean in the code to a WRONG one.redeploy my program,and send
              a message to the queue,the mdb is activated,then the exception is thrown because
              of the wrong jndi name.after that,i check the message queue,find that it is empty.why?i
              think if the second action of the transaction is fail,the transaction should roll
              back,the message should be send BACK to the queue.
              i also ty to use the "javax.transaction.UserTransaction" in the onMessage method,but
              the follwing exception is thrown:
              javax.transaction.NotSupportedException: Another transaction is associated with
              this thread.................................
              who can help me,if any wrong with me,and how to use the transaction with the message
              driven bean?
              thank you.
              

    The transaction should rollback if the MDB throws an
              exception. Try changing your MDB code to
              call "setRollbackOnly()" on the EJB
              context (instead of throwing an exception) to see
              if that works. If calling "setRollbackOnly()" fixes
              the problem - then please contact customer support
              and report a bug.
              zbcong wrote:
              > hello
              >
              > i write a message driven bean,that monitor the weblogic message queue,when a "Order"
              > object is witten to the queue,the mdb get it and write it to a entity bean "Orderinfo".all
              > of above logic is within the "onMessage" method of the mdb.
              > i want to encapsulate the flow in a transaction,see my code snippet of the onMessage
              > method:
              >
              >
              > ObjectMessage objMsg = (ObjectMessage) msg;
              > OrderVO orderVO = (OrderVO) objMsg.getObject();
              > System.out.println(orderVO.booklist);
              > OrderinfoHome orderinfoHome = (OrderinfoHome) ctx.lookup(
              > "java:/comp/env/orderinfo");
              > Orderinfo orderinfo = orderinfoHome.create(orderVO.orderID);
              > orderinfo.setAddress(orderVO.address);
              > orderinfo.setCustname(orderVO.custName);
              > orderinfo.setEmail(orderVO.email);
              > orderinfo.setBooklist(orderVO.booklist);
              > orderinfo.setPrice(new BigDecimal(orderVO.price));
              >
              >
              > and deploy descriptor snippet(ejb-jar.xml):
              >
              >
              > <assembly-descriptor>
              > ............
              > ...........
              >
              > <container-transaction>
              > <method>
              > <ejb-name>orderMDB</ejb-name>
              > <method-name>*</method-name>
              > </method>
              > <trans-attribute>Required</trans-attribute>
              > </container-transaction>
              > </assembly-descriptor>
              >
              >
              > i think during this transaction,there are two action:geting the object from the
              > queue and saving it to entity bean.in order to test the transaction,i modify the
              > jndi name of entity bean in the code to a WRONG one.redeploy my program,and send
              > a message to the queue,the mdb is activated,then the exception is thrown because
              > of the wrong jndi name.after that,i check the message queue,find that it is empty.why?i
              > think if the second action of the transaction is fail,the transaction should roll
              > back,the message should be send BACK to the queue.
              >
              > i also ty to use the "javax.transaction.UserTransaction" in the onMessage method,but
              > the follwing exception is thrown:
              >
              > javax.transaction.NotSupportedException: Another transaction is associated with
              > this thread.................................
              >
              > who can help me,if any wrong with me,and how to use the transaction with the message
              > driven bean?
              >
              > thank you.
              >
              >
              

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

  • Can you set isolation levels of message-driven bean transactions?

    The problem: I have 3 different message-driven beans which each get a different type of message, except for a field that is common to all. That field is used as the primary key of an entity object. The message-driven beans configured to use a container managed transaction. Each message-driven bean, in processing the message, first does a lookup by primary key to see if the object associated with the key exists, and if it does not, it requests the entity's home object to create it. After that, they do further processing. The problem is that sometimes all the beans simultaneously get a message, resulting in each bean checking for the entity object at about the same time, and if they fail to find it (because none of them has created it yet), each creates an object, all with the same primary key. This is not caught until the beans start to complete their onMessage method, which I believe results in the container committing the transaction. One of the transactions will be committed successfully, while the other two will fail, get rolled back, and then be retried with the same message. The second time through, the other beans will find the entity object (since it has been created and committed) and they will complete correctly. In the end, they right thing occurs, except that there is a troubling exception or 2 in the log telling about the constraint violation (with the primary key) and the rollback. If it was just me, that would be fine, but our customer does not like to see exceptions in the log; that indicates to him that something is wrong.
    So, I am looking for someway to make sure that the actions of the message-driven beans are serialized. One suggestion from a colleague was to set the isolation level of the transactions being used by the container in processing the message-driven beans' onMessage method. However, the documentation does not mention any way to do this for a message-driven bean. Suggestions?
    Is the use of a UserTransaction a better way to do this? If I acquire a UserTransaction within the onMessage method of a message-driven bean, can I set its isolation level? How would this work? When I get a UserTransaction, does each client get a different transaction, or do they all get the same one?

    (1) The WebLogic JMS "unit-of-order" feature is a heavily adopted feature that was specifically designed to handle similar use cases - see the JMS developer guide for extensive documentation. In your use case, if "key" is used to define UOO, then there's no limit on the number of keys that can be processed concurrently, but messages for any particular key will be processed single-threaded in the order in which they were first submitted.
    Note that if you're using distributed destinations, the UOO feature is still fully supported - but the developer and/or administrator needs to decide whether to configure the destination to use "hash" or "path service" based routing (the JMS UOO edoc outlines the trade-offs).
    (2) Another alternative is to use a single MDB with max-beans-free-pool that processes all three types (as the other poster suggested). I think this assumes all MDBs run on the same JVM.
    (3) Another alternative is to use multiple queues, with a single MDB on each Q. Where some sort of hash algorithm is used to determine which Q is for the key. This approach is a "hand-coded" variant of the approach in (1) with "hash" based routing enabled...
    (4) If all MDBs actually do run in the same JVM, a third alternative is to use code the application to use a common lock to protect each key, eg, something like:
    // assume MyLock is simply a class with a "reference counter"
    // assume some global "staticHM" hash map that is all MDBs can access
    onMessage() {
    MyLock lock = null;
    key= msg.getKey();
    synchronized(staticHM) {
    lock = staticHM.get();
    if (lock = null) {
    lock = new lock();
    staticHM.put(key, new lock());
    lock.incRefCount();
    try {
    synchronized(lock) {
    // only one onMessage will be able to lock a particular key at a time
    do your work;
    } finally {
    synchronized(staticHT) {
    if (lock.defRefCount() == 0) staticHM.remove(lock);
    if (lock = null) staticHM.put(key);
    If multiple threads get a message with the same key, then only one thread at a time will work on the key.
    Hope this helps,
    Tom

  • 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

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

  • Message Driven Bean: problem with @RunAs annotation

    I am having a problem using the @RunAs annotation in a message driven bean.
    I would like the code in my onMessage() method to be executed with a specific role/user, so I want to use the @RunAs annotation to achieve this.
    I am running weblogic 10.0.
    I have created the following in weblogic console:
    - Group "TestGroup"
    - User "TestUser", member of "TestGroup"
    - Global Role "TestRole", role condition: "Group : TestGroup"
    The MDB:
    package be.cegeka.test.mdb;
    import javax.annotation.Resource;
    import javax.annotation.security.RunAs;
    import javax.ejb.ActivationConfigProperty;
    import javax.ejb.MessageDriven;
    import javax.ejb.MessageDrivenContext;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    @MessageDriven(
              mappedName = "testQueue",
              name = "TestMDB",
              activationConfig = {
                        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
    @RunAs("TestRole")
    public class TestMDB implements MessageListener {
         @Resource
         private MessageDrivenContext mdContext;
          * {@inheritDoc}}
         public void onMessage(Message msg) {
              System.out.println("Handling message for user "
                        + mdContext.getCallerPrincipal().getName());
    }[u]The ejb-jar.xml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
    version="3.0">
         <assembly-descriptor>
              <security-role>
                   <description>
                        Test Role.
                   </description>
                   <role-name>TestRole</role-name>
              </security-role>
         </assembly-descriptor>
    </ejb-jar>
    The weblogic-ejb-jar.xml file:
    <weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/10.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.bea.com/ns/weblogic/10.0 http://www.bea.com/ns/weblogic/10.0/weblogic-ejb-jar.xsd">
         <security-role-assignment>
              <role-name>TestRole</role-name>
              <principal-name>TestUser</principal-name>
         </security-role-assignment>
    </weblogic-ejb-jar>I would have thought that the onMessage of the MDB would print "Handling message for user TestUser", but instead it prints "Handling message for user <anonymous>".
    It seems as though the @RunAs annotation has no effect. Although I specified the role TestRole (mapped to the user TestUser), the code still seems to be executed by user anonymous.
    Am I missing something?
    Any help would be much appreciated! I've been looking at this poblem for quite a while now.

    Both beans (the MDB on WLS 10 and the session bean on WLS 8.1) use container managed transactions.
    For the MDB I do not explicitly set the transaction attributes, so it should default to container managed transactions.
    For the stateless session bean I have specified the following in the ejb-jar.xml file:
    <ejb-jar>
      <display-name>Weblogic8Service</display-name>
      <enterprise-beans>
        <session>
          <ejb-name>Weblogic8Service</ejb-name>
          <home>be.cegeka.rszv.test.session.Weblogic8ServiceRemoteHome</home>
          <remote>be.cegeka.rszv.test.session.Weblogic8ServiceRemote</remote>
          <ejb-class>be.cegeka.rszv.test.session.Weblogic8ServiceBean</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>
        </session>
      </enterprise-beans>
      <assembly-descriptor>
        <container-transaction>
          <method>
            <ejb-name>Weblogic8Service</ejb-name>
            <method-name>*</method-name>
          </method>
          <trans-attribute>Required</trans-attribute>
        </container-transaction>
      </assembly-descriptor>
    </ejb-jar>So as far as I understand it the transaction starts at the MDB (upon receival of a message). The transaction for the remote call to the stateless session bean (in the onMessage() of the MDB) is included in the transaction of the MDB and gets committed when the onMessage() method finishes and the transaction of the MDB itself gets committed.
    Correct me if I'm wrong here.

  • Error during deployment of Message Driven Bean

    Environment: WLS 6.1SP3 on Win2K SP2, non-clustered.
              I am getting some error (or perhaps warning) during deployment of Message
              Driven Bean. Any one seen this before?
              This error only comes on a machine with Dual Network card.
              Thanks.
              ####<Dec 11, 2002 1:23:04 AM GMT> <Info> <EJB> <QAAPP01> <Makalu> <main>
              <system> <> <010008> <EJB Deploying file: AppRuntime.jar>
              ####<Dec 11, 2002 1:23:04 AM GMT> <Warning> <J2EE> <QAAPP01> <Makalu> <main>
              <system> <> <160007> <You are running WebLogic Server with J2EE 1.3 features
              enabled. The implementation of specific J2EE 1.3 features (EJB 2.0, JSP 1.2,
              Servlet 2.3, and J2EE Connector Architecture 1.0) in BEA WebLogic Server 6.1
              is of a non-final version of the appropriate specification. It is subject to
              change in future releases once the specification becomes finalized. This may
              cause application code developed for BEA WebLogic Server 6.1 that uses the
              new features of J2EE 1.3 to be incompatible with the J2EE 1.3 platform
              supported in future releases of BEA WebLogic Server.>
              ####<Dec 11, 2002 1:23:07 AM GMT> <Warning> <EJB> <QAAPP01> <Makalu> <main>
              <system> <> <010061> <The Message-Driven EJB: ASYNCMessageDrivenBean is
              unable to connect to the JMS destination: CQM_MessageQueue. The EJB
              container will automatically attempt to re-establish the connection with the
              JMS server. 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:
              Unable to create a JNDI InitialContext to lookup the JMS destination. The
              error was:
              javax.naming.CommunicationException. Root exception is
              java.net.ConnectException: t3://127.0.0.1:7001: Destination unreachable;
              nested exception is:
              java.net.ConnectException: Connection refused: connect; No available router
              to destination
              at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:155)
              at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:207)
              at
              weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialCon
              textFactoryDelegate.java:307)
              at
              weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialCon
              textFactoryDelegate.java:211)
              at
              weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFact
              ory.java:149)
              at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:660)
              at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:241)
              at javax.naming.InitialContext.init(InitialContext.java:217)
              at javax.naming.InitialContext.<init>(InitialContext.java:193)
              at
              weblogic.ejb20.deployer.MessageDrivenBeanInfoImpl.getInitialContext(MessageD
              rivenBeanInfoImpl.java:641)
              at
              weblogic.ejb20.internal.JMSConnectionPoller.createJMSConnection(JMSConnectio
              nPoller.java:474)
              at
              weblogic.ejb20.internal.JMSConnectionPoller.connectToJMS(JMSConnectionPoller
              .java:418)
              at
              weblogic.ejb20.internal.JMSConnectionPoller.startJMSConnectionPolling(JMSCon
              nectionPoller.java:286)
              at
              weblogic.ejb20.deployer.MessageDrivenBeanInfoImpl.deploy(MessageDrivenBeanIn
              foImpl.java:511)
              at weblogic.ejb20.deployer.Deployer.deployDescriptor(Deployer.java:1294)
              at weblogic.ejb20.deployer.Deployer.deploy(Deployer.java:996)
              at weblogic.j2ee.EJBComponent.deploy(EJBComponent.java:31)
              at weblogic.j2ee.Application.addComponent(Application.java:170)
              at weblogic.j2ee.J2EEService.addDeployment(J2EEService.java:117)
              at
              weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(DeploymentT
              arget.java:360)
              at
              weblogic.management.mbeans.custom.DeploymentTarget.addDeployments(Deployment
              Target.java:285)
              at
              weblogic.management.mbeans.custom.DeploymentTarget.updateServerDeployments(D
              eploymentTarget.java:239)
              at
              weblogic.management.mbeans.custom.DeploymentTarget.updateDeployments(Deploym
              entTarget.java:199)
              at java.lang.reflect.Method.invoke(Native Method)
              at
              weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl
              .java:636)
              at
              weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:6
              21)
              at
              weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBea
              nImpl.java:360)
              at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1557)
              at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1525)
              at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:468)
              at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:209)
              at $Proxy34.updateDeployments(Unknown Source)
              at
              weblogic.management.configuration.ServerMBean_CachingStub.updateDeployments(
              ServerMBean_CachingStub.java:2977)
              at
              weblogic.management.mbeans.custom.ApplicationManager.startConfigManager(Appl
              icationManager.java:372)
              at
              weblogic.management.mbeans.custom.ApplicationManager.start(ApplicationManage
              r.java:160)
              at java.lang.reflect.Method.invoke(Native Method)
              at
              weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl
              .java:636)
              at
              weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:6
              21)
              at
              weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBea
              nImpl.java:360)
              at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1557)
              at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1525)
              at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:468)
              at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:209)
              at $Proxy49.start(Unknown Source)
              at
              weblogic.management.configuration.ApplicationManagerMBean_CachingStub.start(
              ApplicationManagerMBean_CachingStub.java:480)
              at weblogic.management.Admin.startApplicationManager(Admin.java:1234)
              at weblogic.management.Admin.finish(Admin.java:644)
              at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:524)
              at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:207)
              at weblogic.Server.main(Server.java:35)
              >
              ####<Dec 11, 2002 1:23:07 AM GMT> <Info> <EJB> <QAAPP01> <Makalu> <main>
              <system> <> <010009> <EJB Deployed EJB with JNDI name
              ASYNCMessageDrivenBean.>
              

    Hi Tom
              Yes we do have an URL provided in the descriptor. It's
              t3://jms.server.net:7001.
              and the jms.server.net is resolved via a hosts file in Win2K
              eg,
              192.168.100.200 jms.server.net
              You are right in saying that the loopback in a dual-net card is a problem.
              But our solution
              above solves the issue as long as your host file does not use 127.0.0.1 as
              the IP.
              We need the URL b/c depending on our client's deployment , the JMS Server
              may be remote or may be local.
              "Tom Barnes" <[email protected]> wrote in message
              news:[email protected]...
              > Hi x,
              >
              > Something to do with the loopback and dual-network cards is
              > messin' with WLS' mind. I do not know what the problem is,
              > but I can guess:
              >
              > You have specified an URL in the MDB descriptor when there
              > is no need for one. If t3://127.0.0.1:7001 is in the same
              > cluster the MDB is running in (I suspect this URL is
              > actually the same WL server), then don't specify the URL.
              > This URL is only useful for connecting an MDB to a JMS
              > server that is outside local server and outside the cluster.
              > The URL may be working on single-network card systems
              > as perhaps then WL has enough info to guess that you
              > actually mean the local WL server, and simply converts
              > the context to a local context.
              >
              > Note that the URL option in the MDB descriptor is actually
              > a WebLogic extension of J2EE.
              >
              > Tom
              >
              >
              >
              > x wrote:
              > > Environment: WLS 6.1SP3 on Win2K SP2, non-clustered.
              > >
              > > I am getting some error (or perhaps warning) during deployment of
              Message
              > > Driven Bean. Any one seen this before?
              > > This error only comes on a machine with Dual Network card.
              > >
              > > Thanks.
              > >
              > >
              > >
              > > ####<Dec 11, 2002 1:23:04 AM GMT> <Info> <EJB> <QAAPP01> <Makalu> <main>
              > > <system> <> <010008> <EJB Deploying file: AppRuntime.jar>
              > > ####<Dec 11, 2002 1:23:04 AM GMT> <Warning> <J2EE> <QAAPP01> <Makalu>
              <main>
              > > <system> <> <160007> <You are running WebLogic Server with J2EE 1.3
              features
              > > enabled. The implementation of specific J2EE 1.3 features (EJB 2.0, JSP
              1.2,
              > > Servlet 2.3, and J2EE Connector Architecture 1.0) in BEA WebLogic Server
              6.1
              > > is of a non-final version of the appropriate specification. It is
              subject to
              > > change in future releases once the specification becomes finalized. This
              may
              > > cause application code developed for BEA WebLogic Server 6.1 that uses
              the
              > > new features of J2EE 1.3 to be incompatible with the J2EE 1.3 platform
              > > supported in future releases of BEA WebLogic Server.>
              > > ####<Dec 11, 2002 1:23:07 AM GMT> <Warning> <EJB> <QAAPP01> <Makalu>
              <main>
              > > <system> <> <010061> <The Message-Driven EJB: ASYNCMessageDrivenBean is
              > > unable to connect to the JMS destination: CQM_MessageQueue. The EJB
              > > container will automatically attempt to re-establish the connection with
              the
              > > JMS server. 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:
              > > Unable to create a JNDI InitialContext to lookup the JMS destination.
              The
              > > error was:
              > > javax.naming.CommunicationException. Root exception is
              > > java.net.ConnectException: t3://127.0.0.1:7001: Destination unreachable;
              > > nested exception is:
              > > java.net.ConnectException: Connection refused: connect; No available
              router
              > > to destination
              > > at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:155)
              > > at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:207)
              > > at
              > >
              weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialCon
              > > textFactoryDelegate.java:307)
              > > at
              > >
              weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialCon
              > > textFactoryDelegate.java:211)
              > > at
              > >
              weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFact
              > > ory.java:149)
              > > at
              javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:660)
              > > at
              javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:241)
              > > at javax.naming.InitialContext.init(InitialContext.java:217)
              > > at javax.naming.InitialContext.<init>(InitialContext.java:193)
              > > at
              > >
              weblogic.ejb20.deployer.MessageDrivenBeanInfoImpl.getInitialContext(MessageD
              > > rivenBeanInfoImpl.java:641)
              > > at
              > >
              weblogic.ejb20.internal.JMSConnectionPoller.createJMSConnection(JMSConnectio
              > > nPoller.java:474)
              > > at
              > >
              weblogic.ejb20.internal.JMSConnectionPoller.connectToJMS(JMSConnectionPoller
              > > .java:418)
              > > at
              > >
              weblogic.ejb20.internal.JMSConnectionPoller.startJMSConnectionPolling(JMSCon
              > > nectionPoller.java:286)
              > > at
              > >
              weblogic.ejb20.deployer.MessageDrivenBeanInfoImpl.deploy(MessageDrivenBeanIn
              > > foImpl.java:511)
              > > at
              weblogic.ejb20.deployer.Deployer.deployDescriptor(Deployer.java:1294)
              > > at weblogic.ejb20.deployer.Deployer.deploy(Deployer.java:996)
              > > at weblogic.j2ee.EJBComponent.deploy(EJBComponent.java:31)
              > > at weblogic.j2ee.Application.addComponent(Application.java:170)
              > > at weblogic.j2ee.J2EEService.addDeployment(J2EEService.java:117)
              > > at
              > >
              weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(DeploymentT
              > > arget.java:360)
              > > at
              > >
              weblogic.management.mbeans.custom.DeploymentTarget.addDeployments(Deployment
              > > Target.java:285)
              > > at
              > >
              weblogic.management.mbeans.custom.DeploymentTarget.updateServerDeployments(D
              > > eploymentTarget.java:239)
              > > at
              > >
              weblogic.management.mbeans.custom.DeploymentTarget.updateDeployments(Deploym
              > > entTarget.java:199)
              > > at java.lang.reflect.Method.invoke(Native Method)
              > > at
              > >
              weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl
              > > .java:636)
              > > at
              > >
              weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:6
              > > 21)
              > > at
              > >
              weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBea
              > > nImpl.java:360)
              > > at
              com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1557)
              > > at
              com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1525)
              > > at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:468)
              > > at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:209)
              > > at $Proxy34.updateDeployments(Unknown Source)
              > > at
              > >
              weblogic.management.configuration.ServerMBean_CachingStub.updateDeployments(
              > > ServerMBean_CachingStub.java:2977)
              > > at
              > >
              weblogic.management.mbeans.custom.ApplicationManager.startConfigManager(Appl
              > > icationManager.java:372)
              > > at
              > >
              weblogic.management.mbeans.custom.ApplicationManager.start(ApplicationManage
              > > r.java:160)
              > > at java.lang.reflect.Method.invoke(Native Method)
              > > at
              > >
              weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl
              > > .java:636)
              > > at
              > >
              weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:6
              > > 21)
              > > at
              > >
              weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBea
              > > nImpl.java:360)
              > > at
              com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1557)
              > > at
              com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1525)
              > > at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:468)
              > > at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:209)
              > > at $Proxy49.start(Unknown Source)
              > > at
              > >
              weblogic.management.configuration.ApplicationManagerMBean_CachingStub.start(
              > > ApplicationManagerMBean_CachingStub.java:480)
              > > at weblogic.management.Admin.startApplicationManager(Admin.java:1234)
              > > at weblogic.management.Admin.finish(Admin.java:644)
              > > at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:524)
              > > at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:207)
              > > at weblogic.Server.main(Server.java:35)
              > >
              > > ####<Dec 11, 2002 1:23:07 AM GMT> <Info> <EJB> <QAAPP01> <Makalu> <main>
              > > <system> <> <010009> <EJB Deployed EJB with JNDI name
              > > ASYNCMessageDrivenBean.>
              > >
              > >
              >
              

  • Message Acknowledgement in a Message Driven Bean

    Does the message acknowledgement in a Message driven bean take place after the transaction commits? Will the message be available to be consumed by another instance of the MDB in case the transaction was rolled back? I am using WLS 7.0 as my app server and SonicMQ as JMS provider.
              Thx.
              Ajanta.
              

    Yes, ack's are delayed until the transaction commits.
              Yes, the message will be available if the transaction is rolled back.
              "Ajanta Dey" <[email protected]> wrote in message
              news:3ea616e0$[email protected]..
              > Does the message acknowledgement in a Message driven bean take place after
              the transaction commits? Will the message be available to be consumed by
              another instance of the MDB in case the transaction was rolled back? I am
              using WLS 7.0 as my app server and SonicMQ as JMS provider.
              >
              > Thx.
              > Ajanta.
              

Maybe you are looking for

  • The dreaded 3F0, "hard disk not exist" problem

    Okay, I have a degree in EE with a minor in comp sci.  I understand how bios' work, etc.  This is why the "answers" HP "tech support" gave me make absolutely no sense.   Could someone please shed some light on this bizarre problem?   I am trying to i

  • Don't know how to fix this - status says no internet connection, yet I'm on the internet.

    So this is a weird one. I got this new MacBook Air and the WiFi started up without a hitch.  I had finished migrating from my old computer to my new one and all of a sudden the status bar signal went from full bars to an exclamation point.  The info

  • How shall i add new tab in cgab transaction under property tree.

    hi, how shall i add new class tab under phrase-set-to-attribute assignment under industrial hygine & safety data in transaction cgab. thanks and regards, manish.

  • Upgrade hard drive on DV9925NR

    I have an HP laptop (model DV9925nr), with a Western Digital factory hard drive (model WD2500BEVS). I'm running low on storage space, and would like to upgrade to a bigger drive. Before I drop the bucks on a new drive, can anyone tell me whether the

  • Won't boot up, it says "Waiting for local disks"

    The other day I got a warning that I was running out of disk space and that I should delete some files off my computer. I was going to do that, but I didn't for some reason and then shut down the computer. Now when I try to start up the computer it w