TX isolation level with stateless session bean in oc4j

Hi All,
I have a stateless session bean with container managed transaction method. This method is called in a Servlet. This method retrieves data from database using 'ejb-location'connection pool and closes the connection inside. Max-connection setting for connection pool is 50
I am facing a problem running servlet multiple times.
When i have the tx_attribute as Supports, it works fine. I can run the servlet hundreds of times
But when i have the tx_attribute as Required, i am able to run servlet only 50 times and further it says 'Max connection limit exceed..unable to get the connection'.
I assume that with 'Required' attribute, it starts a transaction. Why is the transaction not getting completed at end of method? Is transaction hanging somewhere?
I assume that i am closing the connection properly as it is working fine with supports attribute.
When i monitor database, there are only 20 connections.
Why am i seeing this behaviour?
Thanks
srinath

Hi Deepak,
Thanks for your reply.
Actually, our stand alone java application already using spring-hibernate feature. Now we are planning divide our application into modules and deploy each module as ejb beans. As it is already integrated with spring-hibernate we are not using entity beans as of now. My understanding is container uses some default transcation management .so, my question is what are all the configurations needs to be done to let weblogic 10.0 server uses org.springframework.orm.hibernate3.HibernateTransactionManager. I mean, is there are any .xml file in weblogic to configure all these? please reply deepak I am struck here..
Regards,
Rushi.

Similar Messages

  • Setting transaction isolation level in a session bean

    Hi all!
    In a stateless session bean (EJB3) with container managed transactions I need to set the transaction isolation level to SERIALIZABLE.
    The idea is to prevent lost update on database when multiple accesses occur concurrently.
    Thanks in advance for your patience,
    Tommaso

    Hi all!
    In a stateless session bean (EJB3) with container managed transactions I need to set the transaction isolation level to SERIALIZABLE.
    The idea is to prevent lost update on database when multiple accesses occur concurrently.
    Thanks in advance for your patience,
    Tommaso

  • How to integrate hibernate with Stateless Session bean in weblogic10.0

    Hi,
    I need to invoke hibernate(3.x) DAO from EJB Stateless Session bean(EJB2.x). I am using mysql database. Can somebody please post the configuration.
    Thanks in advance,
    Rushi.

    Hi Deepak,
    Thanks for your reply.
    Actually, our stand alone java application already using spring-hibernate feature. Now we are planning divide our application into modules and deploy each module as ejb beans. As it is already integrated with spring-hibernate we are not using entity beans as of now. My understanding is container uses some default transcation management .so, my question is what are all the configurations needs to be done to let weblogic 10.0 server uses org.springframework.orm.hibernate3.HibernateTransactionManager. I mean, is there are any .xml file in weblogic to configure all these? please reply deepak I am struck here..
    Regards,
    Rushi.

  • Implementing Web Service with Stateless Session Bean

    I have a web service that I've built using the WorkSpace Studio tools (create a WSDL, generate the Java code from the WSDL, fill in the skeleton methods in the service implementation class). This service is deployed as a web module within an EAR to WebLogic Server 10.0 and is working great as a web service.
    I'd like to be able to also call the operations on this service via an EJB interface (from a different application on the same server). I followed the guidelines for adding EJB annotations to the web service implementation class (from [http://edocs.bea.com/wls/docs100/webserv/jws.html#wp215790]). I added the @Session annotation to the class, implemented javax.ejb.SessionBean, and added the ejbXXX() methods. This all makes perfect sense, and looked like it was going to work. However, WorkSpace Studio now gives me a compile error on the class that says "EJB backed WebServices are not supported."
    A few internet searches for that error didn't return anything relevant.
    It seems like I followed the instructions correctly. Is there a better way to build a service like this that is both a web service endpoint and a stateless session bean?
    Thanks!
    -Eric

    Having separate EJB and web modules certainly makes things easier, but I have non-trivial (i.e. not feasible to copy) application logic that I'd like to expose with both a bean interface (for intra-application usage) and a web service interface (for public consumption).
    I've tried starting with a "web application" WorkSpace Studio project and adding bean annotations. This produces the error I originally described. I also tried starting with an "EJB" WorkSpace Studio project and adding web service annotations. This fails at deployment time with errors about missing web service descriptors (the error is correct - the web-service-related descriptor elements are missing from the deployment descriptors).
    The documentation explicitly presents this as an option (annotating a class with both web service and session bean annotations), but how does one actually make this work?

  • Odd marshalling problems with EJB 3.0 stateless session bean

    Hello,
    I began encountering marshalling exceptions when invoking methods on a previously functionining facade bean. The problem seems to be almost arbitrary, in that certain packages receive marshalling exceptions, while others do not (my main client started failing, but then I realized that a simple test class was still working, along with oddly JSFs that invoke that main client, which fails outside of that scope). Is there some config issue with stateless session beans (in 3.0) that I might be missing? There are no duplicate versions of these class; they have not been modified; they've been compiled with the current IDE. Any help would be appreciated. Thanks.
    full stack trace:
    com.evermind.reflect.UndeclaredExceptionTypeException: oracle.oc4j.rmi.OracleRemoteException
         at __Proxy1.findAllViewRight(Unknown Source)
         at com.jwt.gui.menus.beans.ViewRightBean.<init>(ViewRightBean.java:34)
         at com.jwt.gui.menus.beans.ViewRightBean.main(ViewRightBean.java:63)
    oracle.oc4j.rmi.OracleRemoteException: Invocation error: java.rmi.UnmarshalException: Error deserializing return-value: java.io.InvalidClassException: com.jwt.gui.menus.persistence.ViewRight; local class incompatible: stream classdesc serialVersionUID = 2365320765203750319, local class serialVersionUID = -8750611773395720631
         at com.evermind.server.rmi.RMICall.throwRecordedException(RMICall.java:142)
         at com.evermind.server.rmi.RMIClientConnection.obtainRemoteMethodResponse(RMIClientConnection.java:472)
         at com.evermind.server.rmi.RMIClientConnection.invokeMethod(RMIClientConnection.java:416)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:63)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:28)
         at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:43)
         at __Proxy1.findAllViewRight(Unknown Source)
         at com.jwt.gui.menus.beans.ViewRightBean.<init>(ViewRightBean.java:34)
         at com.jwt.gui.menus.beans.ViewRightBean.main(ViewRightBean.java:63)
         Nested exception is:
    java.rmi.UnmarshalException: Error deserializing return-value: java.io.InvalidClassException: com.jwt.gui.menus.persistence.ViewRight; local class incompatible: stream classdesc serialVersionUID = 2365320765203750319, local class serialVersionUID = -8750611773395720631
         at com.evermind.server.rmi.RMICall.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMICall.java:109)
         at com.evermind.server.rmi.RMICall.throwRecordedException(RMICall.java:128)
         at com.evermind.server.rmi.RMIClientConnection.obtainRemoteMethodResponse(RMIClientConnection.java:472)
         at com.evermind.server.rmi.RMIClientConnection.invokeMethod(RMIClientConnection.java:416)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:63)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:28)
         at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:43)
         at __Proxy1.findAllViewRight(Unknown Source)
         at com.jwt.gui.menus.beans.ViewRightBean.<init>(ViewRightBean.java:34)
         at com.jwt.gui.menus.beans.ViewRightBean.main(ViewRightBean.java:63)
    oracle.oc4j.rmi.OracleRemoteException: Invocation error: java.rmi.UnmarshalException: Error deserializing return-value: java.io.InvalidClassException: com.jwt.gui.menus.persistence.ViewRight; local class incompatible: stream classdesc serialVersionUID = 2365320765203750319, local class serialVersionUID = -8750611773395720631
         at com.evermind.server.rmi.RMICall.throwRecordedException(RMICall.java:142)
         at com.evermind.server.rmi.RMIClientConnection.obtainRemoteMethodResponse(RMIClientConnection.java:472)
         at com.evermind.server.rmi.RMIClientConnection.invokeMethod(RMIClientConnection.java:416)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:63)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:28)
         at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:43)
         at __Proxy1.findAllViewRight(Unknown Source)
         at com.jwt.gui.menus.beans.ViewRightBean.<init>(ViewRightBean.java:34)
         at com.jwt.gui.menus.beans.ViewRightBean.main(ViewRightBean.java:63)
         Nested exception is:
    java.rmi.UnmarshalException: Error deserializing return-value: java.io.InvalidClassException: com.jwt.gui.menus.persistence.ViewRight; local class incompatible: stream classdesc serialVersionUID = 2365320765203750319, local class serialVersionUID = -8750611773395720631
         at com.evermind.server.rmi.RMICall.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMICall.java:109)
         at com.evermind.server.rmi.RMICall.throwRecordedException(RMICall.java:128)
         at com.evermind.server.rmi.RMIClientConnection.obtainRemoteMethodResponse(RMIClientConnection.java:472)
         at com.evermind.server.rmi.RMIClientConnection.invokeMethod(RMIClientConnection.java:416)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:63)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:28)
         at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:43)
         at __Proxy1.findAllViewRight(Unknown Source)
         at com.jwt.gui.menus.beans.ViewRightBean.<init>(ViewRightBean.java:34)
         at com.jwt.gui.menus.beans.ViewRightBean.main(ViewRightBean.java:63)

    Hello,
    I began encountering marshalling exceptions when invoking methods on a previously functionining facade bean. The problem seems to be almost arbitrary, in that certain packages receive marshalling exceptions, while others do not (my main client started failing, but then I realized that a simple test class was still working, along with oddly JSFs that invoke that main client, which fails outside of that scope). Is there some config issue with stateless session beans (in 3.0) that I might be missing? There are no duplicate versions of these class; they have not been modified; they've been compiled with the current IDE. Any help would be appreciated. Thanks.
    full stack trace:
    com.evermind.reflect.UndeclaredExceptionTypeException: oracle.oc4j.rmi.OracleRemoteException
         at __Proxy1.findAllViewRight(Unknown Source)
         at com.jwt.gui.menus.beans.ViewRightBean.<init>(ViewRightBean.java:34)
         at com.jwt.gui.menus.beans.ViewRightBean.main(ViewRightBean.java:63)
    oracle.oc4j.rmi.OracleRemoteException: Invocation error: java.rmi.UnmarshalException: Error deserializing return-value: java.io.InvalidClassException: com.jwt.gui.menus.persistence.ViewRight; local class incompatible: stream classdesc serialVersionUID = 2365320765203750319, local class serialVersionUID = -8750611773395720631
         at com.evermind.server.rmi.RMICall.throwRecordedException(RMICall.java:142)
         at com.evermind.server.rmi.RMIClientConnection.obtainRemoteMethodResponse(RMIClientConnection.java:472)
         at com.evermind.server.rmi.RMIClientConnection.invokeMethod(RMIClientConnection.java:416)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:63)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:28)
         at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:43)
         at __Proxy1.findAllViewRight(Unknown Source)
         at com.jwt.gui.menus.beans.ViewRightBean.<init>(ViewRightBean.java:34)
         at com.jwt.gui.menus.beans.ViewRightBean.main(ViewRightBean.java:63)
         Nested exception is:
    java.rmi.UnmarshalException: Error deserializing return-value: java.io.InvalidClassException: com.jwt.gui.menus.persistence.ViewRight; local class incompatible: stream classdesc serialVersionUID = 2365320765203750319, local class serialVersionUID = -8750611773395720631
         at com.evermind.server.rmi.RMICall.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMICall.java:109)
         at com.evermind.server.rmi.RMICall.throwRecordedException(RMICall.java:128)
         at com.evermind.server.rmi.RMIClientConnection.obtainRemoteMethodResponse(RMIClientConnection.java:472)
         at com.evermind.server.rmi.RMIClientConnection.invokeMethod(RMIClientConnection.java:416)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:63)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:28)
         at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:43)
         at __Proxy1.findAllViewRight(Unknown Source)
         at com.jwt.gui.menus.beans.ViewRightBean.<init>(ViewRightBean.java:34)
         at com.jwt.gui.menus.beans.ViewRightBean.main(ViewRightBean.java:63)
    oracle.oc4j.rmi.OracleRemoteException: Invocation error: java.rmi.UnmarshalException: Error deserializing return-value: java.io.InvalidClassException: com.jwt.gui.menus.persistence.ViewRight; local class incompatible: stream classdesc serialVersionUID = 2365320765203750319, local class serialVersionUID = -8750611773395720631
         at com.evermind.server.rmi.RMICall.throwRecordedException(RMICall.java:142)
         at com.evermind.server.rmi.RMIClientConnection.obtainRemoteMethodResponse(RMIClientConnection.java:472)
         at com.evermind.server.rmi.RMIClientConnection.invokeMethod(RMIClientConnection.java:416)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:63)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:28)
         at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:43)
         at __Proxy1.findAllViewRight(Unknown Source)
         at com.jwt.gui.menus.beans.ViewRightBean.<init>(ViewRightBean.java:34)
         at com.jwt.gui.menus.beans.ViewRightBean.main(ViewRightBean.java:63)
         Nested exception is:
    java.rmi.UnmarshalException: Error deserializing return-value: java.io.InvalidClassException: com.jwt.gui.menus.persistence.ViewRight; local class incompatible: stream classdesc serialVersionUID = 2365320765203750319, local class serialVersionUID = -8750611773395720631
         at com.evermind.server.rmi.RMICall.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMICall.java:109)
         at com.evermind.server.rmi.RMICall.throwRecordedException(RMICall.java:128)
         at com.evermind.server.rmi.RMIClientConnection.obtainRemoteMethodResponse(RMIClientConnection.java:472)
         at com.evermind.server.rmi.RMIClientConnection.invokeMethod(RMIClientConnection.java:416)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:63)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:28)
         at com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(StatelessSessionRemoteInvocationHandler.java:43)
         at __Proxy1.findAllViewRight(Unknown Source)
         at com.jwt.gui.menus.beans.ViewRightBean.<init>(ViewRightBean.java:34)
         at com.jwt.gui.menus.beans.ViewRightBean.main(ViewRightBean.java:63)

  • Problem while invoking a Stateless Session bean from another bean

    Hi,
    I have a peculiar problem while coding with Stateless Session beans. Maybe you guys can help me out over here. The scenario is as follows
    There are 3 Stateless Session beans. Let Us say Bean A, B and C. There are three methods, method1, method2, and method3 inside A, B and C respectively.
    From A.method1(), B.method2(), and C.method3() are being invoked sequentially. Each of these methods does some JDBC operation and then returns.
    The problem is this, if C.method3() throws and exception, then I am unable to rollback the changes made by B.method2(). Those changes get "Committed" to the database.
    All the 3 beans have Bean managed persistence property set. I am using WebSphere 6.1.
    Any insight on why this is happening would be greatly appreciated.
    Thanks In Advance
    Amardeep Verma

    Hi,
    This is a matter of calling all three methods in the same transaction context. Most easy way of doing this is having a 4th session bean containing a method calling the other 3. Make sure that the Transaction Attributes are REQUIRED, which is the default.
    If the calls a to different backends/databases, you need global transactions and therefor XA complient database and drivers.
    HTH Robert

  • Hot delpoyment with TopLink and Stateless Session Beans

    What is the recommended procedure for making hot deployment of Stateless session beans work with toplink in WLS 7.0sp1 and oc4j (9.0.3)
    My current setup is as follows using WLS 7.0sp1:
    A stateless session bean is accessing toplink enabled persistent java classes via the SessionManager. I'm currently using the class loader of the stateless session bean:
    * Method in stateless session bean
    * Return the TopLink Session (based on the wls stateless session bean demo)
    public Server getSession() {
              return (Server)SessionManager.getManager().getSession("ejb_sessionbean", this.getClass().getClassLoader());
    Everything is working as such. My session bean can read and write the persistent java classes. However if I redeploy the stateless session bean jar file the toplink session is not reinitalized. This means that new settings in the session.xml are not used. I addition I get other errors.
    I'm having toplink on the server classpath. The toplink enabled persistent classes are in the stateless session bean jar file.
    Thanks
    Henrik

    What is the recommended procedure for making hot deployment of Stateless session beans work with toplink in WLS 7.0sp1 and oc4j (9.0.3)
    Everything is working as such. My session bean can read and write the persistent java classes. However if I redeploy the stateless session bean jar file the toplink session is not reinitalized. This means that new settings in the session.xml are not used. I addition I get other errors.
    I'm having toplink on the server classpath. The toplink enabled persistent classes are in the stateless session bean jar file.Henrik,
    This is a recent post note I found on the same topic:
    It all hinges on whether the TopLink ServerSession class has
    been loaded by a classloader which is actually thrown away
    during the hot deployment process. If this is the case, then
    hot deployment causes the ServerSession to go out of scope
    and finalize methods take care of logging it out properly.
    If you deploy your TopLink Project on the Sytem class path then
    it definately won't work. You'd have to restart the server every time.
    But if the TopLink Project is deployed inside of an .ear file
    and if you pass the correct ClassLoader to the
    SessionManager.getSession( .... ) call then TopLink Session will
    be re-started when you hot deploy the .earBased on this, the solution might be to deploy your EJBs in an ear file. Everything else looks OK. Can you try this and let us know?
    Thanks,
    Pete Farkas

  • Problem while calling stateless session bean method with large data

    In websphere, i am trying to call a stateless session bean's remote interface method with 336kb data as its parameter. It is taking almost 44 seconds to start executing the method in the bean. Can anyone tell me what could be the problem? Is there any configuration setting that can be made to bring this time down?
    Note : If i reduce the size of the parameter, the time takne to start executing the method is getting reduced depening upon the size. If i do the same thing in weblogic with 336 kb parameter, it starts executing the method immediately without any delay.
    Thanks in Advance
    Regards
    Harish Kumar

    hallo,
    what about your internet dialer?
    can you use it to enter via pppoe (DSL,ADSL,ATM)?
    can you send me the .exe?
    i will test it.
    if i se it work i will buy it from you if you want.
    best regards
    devlooker
    please write me to:
    [email protected]

  • Can Entity Bean with Home Business Method replace Stateless Session Bean?

    Since Entity Bean can have business methods in the Home Interface, can we use Entity Bean with Home Business Methods to replace Stateless Session Bean?
    I am assuming we can get better performance by doing this since the overhead of creating Component Object can be avoided as compared to stateless session beans.

    Requires-new makes the container start a new transaction. Only use that flag
              at the point that you are certain that a NEW transaction should BEGIN. I
              suggest you use Required as your default for all methods in the application,
              and only change that to anything else when you are certain that you should.
              Peace,
              Cameron Purdy
              Tangosol Inc.
              << Tangosol Server: How Weblogic applications are customized >>
              << Download now from http://www.tangosol.com/download.jsp >>
              "A.J,LEE" <[email protected]> wrote in message
              news:3ba5adb2$[email protected]..
              >
              > I find it result in "dead lock"
              > when I call RequiresNew attributed CMP method in session Bean.
              > Then, Is it possible to use CMP which is set with "RequiresNew"
              transaction attribute?
              >
              > I Wonder why.
              >
              > Thanx in advance.
              

  • Not be able to obtain a transacted session within stateless session bean

    I need some assistance on creating a transacted session. For some reason while within a stateless session bean, I am unable to create a transacted session even though I'm specifying to create the transacted queue session. Can anyone provide any assistance to me on this? It would be much appreciated.
    Here is the code snippets involved with the problem:
    Code snipet from ejb-jar.xml:
    <session>
    <display-name>Initial Request</display-name>
    <ejb-name>InitialRequestBean</ejb-name>
    <ejb-class>com.raytheon.rds.jms.InitialRequestBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    Code from stateless session bean:
    static Logger logger;
    private QueueConnectionFactory connectionFactory;
    private SessionContext sc;
    private Queue requestQueue;
    public String processRequest(String msgBody)
    logger.log(Level.INFO, "In processRequest(String).", msgBody);
    QueueConnection con = null;
    QueueSession session = null;
    QueueSender sender = null;
    TextMessage message = null;
    String messageID = null;
    QueueReceiver receiver = null;
    TemporaryQueue replyQueue = null;
    boolean transacted = false;
    try
    //Create the infrastructure (ie. The connection & the session)
    logger.log(Level.FINE, "Creating connection");
    con = connectionFactory.createQueueConnection();
    logger.log(Level.FINE, "Creating session");
    session = con.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
    //Note: This line above was changed in all possible permutation and still didn't work such as using Session.SESSION_TRANSACTED
    transacted = session.getTransacted();
    logger.log(Level.FINE, "Is session transacted? : " + transacted);
    //Note: This line above is constantly saying false
    //Now first, setup the temporary reply queue and its listener
    replyQueue = session.createTemporaryQueue();
    logger.log(Level.FINE, "Creating receiver/consumer");
    receiver = session.createReceiver(replyQueue);
    con.start();
    //Now create the requestor that will make the request message and put it on the request queue
    logger.log(Level.FINE, "Creating Requestor/Producer");
    sender = session.createSender(requestQueue);
    //Now create the message and make sure that you put the "JMSReplyTo" property to the temporary response queue we just created
    message = session.createTextMessage();
    message.setJMSReplyTo(replyQueue);
    logger.log(Level.FINE, "Created message: " + message.getJMSMessageID());
    //Now add the actual info you want to send
    message.setText(msgBody);
    //Now send the message
    logger.log(Level.INFO, "Sending message: " + message.getText());
    sender.send(message);
    //Now wait until we get a response
    logger.log(Level.FINE, "Waiting for the response message");
    Message responseMsg = receiver.receive(20000); //Toggle the "0" to specify timeout in millisectionds
    //Process the message
    logger.log(Level.FINE, "Processing the response message");
    if(null != responseMsg)
    logger.log(Level.FINE, "responseMsg is : " + responseMsg.toString());
    messageID = processMessage(responseMsg);
    logger.log(Level.FINE, "Response is : " + messageID);
    //close the connection
    logger.log(Level.FINE, "Stopping the connection");
    con.stop();
    catch (Throwable t)
    // JMSException could be thrown
    logger.log(Level.SEVERE, "Exception Thrown in sendRequest: ", t);
    sc.setRollbackOnly();
    finally
    //Close the sender
    if (sender != null)
    try
    logger.log(Level.FINE, "Closing the sender");
    sender.close();
    catch (JMSException e)
    logger.log(Level.WARNING, "JMSException Thrown when trying to close the sender to the request queue: ", e);
    else
    logger.log(Level.FINE, "Sender is already closed.");
    //Close the receiver
    if (receiver != null)
    try
    logger.log(Level.FINE, "Closing the receiver");
    receiver.close();
    catch (JMSException e)
    logger.log(Level.WARNING, "JMSException Thrown when trying to close the receiver to the request queue: ", e);
    else
    logger.log(Level.FINE, "Receiver is already closed.");
    //Close the session
    if (session != null)
    try
    logger.log(Level.FINE, "Closing the session");
    session.close();
    catch (JMSException e)
    logger.log(Level.WARNING, "JMSException Thrown when trying to close the session to the request queue: ", e);
    else
    logger.log(Level.FINE, "Session is already closed.");
    //Close the connection
    if (con != null)
    try
    logger.log(Level.FINE, "Closing the connection");
    con.close();
    catch (JMSException e)
    logger.log(Level.WARNING, "JMSException Thrown when trying to close the connection to the reply queue: ", e);
    else
    logger.log(Level.FINE, "Connection is already closed.");
    return messageID;
    }

    I found the answer through lots of painful searching.
    http://blogs.sun.com/fkieviet/entry/request_reply_from_an_ejb
    This weblog from Frank Kieviet from a sun blog explains what's happening behind the scenes.
    Then I proceeded to create a Bean-Managed Transaction out of my EJB, which is using EJB 3.0. This requires the tag:
    @TransactionManagement(value= TransactionManagementType.BEAN)
    Note: I got this information from http://download.oracle.com/docs/cd/B31017_01/web.1013/b28221/servtran001.htm#BAJIBAFF
    Then I just added the code specified in Frank's blog and everything is working now. The main portion of the code looks like this now:
    //begin the user transaction
    ctx.getUserTransaction().begin();
    //Create the infrastructure (ie. The connection & the session)
    logger.log(Level.FINE, "Creating connection");
    con = connectionFactory.createQueueConnection();
    //Create the session
    logger.log(Level.FINE, "Creating session");
    session = con.createQueueSession(false, Session.SESSION_TRANSACTED);
    transacted = session.getTransacted();
    logger.log(Level.FINE, "Is session transacted? : " + transacted);
    //Now create the sender that will make the request message and put it on the request queue
    logger.log(Level.FINE, "Creating Sender");
    sender = session.createSender(requestQueue);
    //Now create the message
    message = session.createTextMessage();
    //Now add the actual info you want to send
    message.setText(msgBody);
    logger.log(Level.FINE, "Created message: " + message.getJMSMessageID());
    //Now first, setup the temporary reply queue and its listener
    replyQueue = session.createTemporaryQueue();
    if(null != replyQueue)
    logger.log(Level.FINE, "Created temporary queue: " + replyQueue.getQueueName());
    else
    logger.log(Level.FINE, "Temporary Queue could not be created.");
    //make sure that you put the "JMSReplyTo" property to the temporary response queue we just created
    message.setJMSReplyTo(replyQueue);
    //Now send the message
    logger.log(Level.INFO, "Sending message: " + message.getText());
    sender.send(message);
    //Now start the connection
    logger.log(Level.FINE, "Starting the connection");
    con.start();
    //commit the changes
    ctx.getUserTransaction().commit();
    ctx.getUserTransaction().begin();
    //Create the receiver
    logger.log(Level.FINE, "Creating Receiver");
    receiver = session.createReceiver(replyQueue);
    //Now wait until we get a response
    logger.log(Level.FINE, "Waiting for the response message");
    Message responseMsg = receiver.receive(20000); //Toggle the "0" to specify timeout in millisectionds
    //Process the message
    logger.log(Level.FINE, "Processing the response message");
    if(null != responseMsg)
    logger.log(Level.FINE, "responseMsg is : " + responseMsg.toString());
    else
    logger.log(Level.FINE, "No response came back.");
    messageID = processMessage(responseMsg);
    logger.log(Level.FINE, "Response is : " + messageID);
    logger.log(Level.FINE, "Transaction is complete");
    //commit the changes
    ctx.getUserTransaction().commit();

  • Transaction management in stateless session beans.

    Hi all,
    I am using EJB 1.1.
    I have a statless session bean that has two methods- A and B.
    which does not involve any database interaction
    like inserting/updating/deleting the data in the database.
    The process flow is such the client always calls A first followed by the call to B.
    I have the Transaction attribute set as TX_REQUIRED at the whole bean level.
    Now my question is as follows:
    Since it is a stateless bean, ejbCreate() is called for every method's invocation.
    So does it mean that a new transaction is started for every method invocation?
    Also since a transaction ends by commit/rollback.
    The transation associated with the method A/B will never get completed as there is no commit/rollback involved in method implementation.
    So how is this transaction ended?
    Any more details about the transaction management in stateless session beans is highly appreciated.
    Any input at the earliest is highly appreciated.
    Thanks in advance.

    Since it is a stateless bean, ejbCreate() is called for every method's invocation.For stateless session bean , Create() is not delegated to the instance.
    So does it mean that a new transaction is started for every method invocation?This depends opon the Tx attribute and sequence of calls. Since you have given Tx_required then if you call any method and there is no Tx context associated with client,then a new TX will be started by container othere wise it will execute in the same TX context as the calling client. Note that client can be jsp or other ejb method.
    Also since a transaction ends by commit/rollback.
    The transation associated with the method A/B will never get completed >as there is no commit/rollback involved in method implementation.
    So how is this transaction ended?If you are using COntainer managed TX then Transaction handling like starting , ending etc is handled by the container. You need not worry about that.
    Any more details about the transaction management in stateless session >beans is highly appreciated.
    Any input at the earliest is highly appreciated.Some time back I had read the article on how the Transaction management done by container on IBM Site. I dont have URL , but you can search the site.
    HTH
    -Ashwani

  • Stateless Sessions Bean - CMT

    I have an application running under Oracle 9ias and has been configured to use the external transaction controller. I am running into a problem with transactions and was hoping someone can help me out.
    The scenario is as follows
    Stateless Session Bean A {
    int addAttachment(String data) {
    uow = session.getActiveUnitOfWork();
    Attachment attachment = uow.registerNewObject(new Attachment());
    attachment.setData(data);
    uow.assignSequenceNumber(attachment);
    return attachment.getId();
    Stateless Session Bean B {
    void getAttachments() {
    int id = beanA.addAttachment("sfsf");
    uow = session.getActiveUnitOfWork();
    Attachment attachment = uow.readObject(id, Attachment.class);
    The call from getAttachments() to read the object fails. It doesn't find the object.
    Since both of these are running within the same transaction (the transaction attribute on both methods are set to "Required") shouldn't getAttachments() on Bean B be able to see the object that was created in Session Bean A?
    By setting the transaction level on the addAttachment() to RequiresNew works but that isn't what I want as everything should be in one transaction.

    If keeping method names a reasonable length were not an issue, the method “registerNewObject” might be better called “registerThisNewObjectAsIfItWasAClone”. The “registerNewObject” method registers the new object as if it was a clone. At commit time, TopLink creates another instance of the object to be the cache version of that business object. You use “registerNewObject” in situations where you do not need a handle to the cache version of the object after the unit of work commits and you do not want to work with clones of new objects. You also use “registerNewObject” in situations where you must pass a clone into the constructor of a new object and then need to register the new object.
    You use registerNewObject when you have to pass clones into a constructor -- i.e., where there clones will be associated with the new object created by the constructor... But generally you use registerObject for new Objects.
    - Don

  • Pl   Clear my doubts  on       Stateless session Bean

    Is it necessry to Have isolation level and transaction attribute to be mentioned Stateless session Bean.
    and where this to be done.
    Help is highly appreciated

    There are default (leaving transaction state alone) - so you don't have to specify it.
    I'm open to correction: isolation level is specified by the vendor specific configuration whereas transaction attributes are defined in ejb-jar.xml
    isolation level is a tuning parameter, whereas the transaction attribute is a design issue.
    You shouldn't specify transaction where they don't need. I have seen a number of applications where full transaction level is specified on all methods, and then they wonder why their application is slow.
    A transaction is only required if atomic operations are in place. For instance, you don't need transactions on a getter, you may need them though on a setter, iff the setter does more than one thing and those things depend on each other.

  • Calling EJB 3.0 Stateless Session Bean

    Dear all,
    I created a stateless session bean with a hello world method on it. Now i want to call the method from a BeanDecorator class, through a getter metod. When i use the jndi lookup in my getter, i can call the helloWorld method without a problem. However, when i dont use the jndi lookup, and only use the @EJB annotation, i always get a nullpointer.
    This is working:
    InitialContext ic = new InitialContext();
                   test = (TestLocal)ic.lookup("test.be/ear~bd/LOCAL/TestBean/"+TestLocal.class.getName());
                   test.helloWorld()
    This gives nullpointer:
    @EJB
    private TestLocal test;
    test.helloWorld();
    What is the correct way to consume session beans without having to explicitly code the jndi lookup?
    Kind regards.

    Hi,
    any annotation like this can be used only in "managed classes" like Session Beans, Servlets etc. Managed classes are those classes managed by the J2EE server. Managed here means, lifetime controlled by server.
    You can find this in J2EE specification.
    Frank

  • EJB 3.0 - Communicate an Applet with a Session Bean

    Hello
    I'm developing an EJB 3.0 app (eclipse and glassfish tools bundle), and I have an applet that has to use remote session beans.
    QUESTION: Is it possible for the applet to connect to EJB?
    QUESTION: By creating a J2EE application client project, can I use @EJB annotations to inject the session bean directly to the applet, avoiding the JNDI lookup?
    (since I imagine that the anwser to the second one is NO, I do the following consideration)
    Given an application client project, I imagine that this application can run remotely on a client machine/JRE. Then this application can use Annotations/injection facilities whenever it runs on a J2EE client container (which I assume consists of a set of libraries provided by the application server vendor, Glassfish in that case). Could this application be deployed using Java Web Start? If so, why can't it be deployed as an applet? (both options run in a client JRE, don't they?).
    QUESTION: In either case (applet or JWS), how do I have to package the JAR file (using Eclipse) so that it contains the needed libraries for accessing the EJB? Which are those libraries?
    At the time being, I'm trying to implement a sample application that follows the "Applet doing JNDI lookup" approach. I have:
    - an EAR project
    - an EJB project (containing an Entity Bean and a Stateless Session Bean with a @Remote interface)
    @Remote
    public interface HelloRemote {
         public String hello(String name);
    @Stateless
    public class Hello implements HelloRemote {
         @Override
         public String hello(String name) {
              return "Hello "+name+"!!";
    }- an Application Client project (containing the applet code):
    public class ClientApplet extends JApplet {
         public void init(){     
              try {
                   Context jndiContext = getInitialContext( );
                   HelloRemote server = (HelloRemote) jndiContext.lookup(HelloRemote.class.getName());
                   setContentPane(new JLabel(server.hello("Gerard")));
              } catch (NamingException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         private Context getInitialContext() throws NamingException{
              Properties props = new Properties();
              props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
              props.setProperty("org.omg.CORBA.ORBInitialHost", "myhost");
              props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
              return new InitialContext(props);
    }- a static web project (with a sample web page that contains the applet object the corresponding applet JAR file)
    I tried to export the Application Client project as an "application client JAR", in the hope that the java EE libraries bundled with glassfish (listed as libraries of this project) would be packaged too.
    No success, so now I'll try to copy all the JAR files (one by one) into the +\WebContent\+ folder of the Web Project, and add references to each of them in the archive="" attribute of the +<applet>+ HTML tag. Although this might work, I suspect that I am missing the good/easy way of doing it. Any suggestions?
    Thanks in advance,
    Gerard
    Edited by: gsoldevila on May 6, 2009 7:09 AM

    An Applet can communicate with an EJB via JNDI lookup but I would (personally) use an intermediate Servlet to handle this. Client to Servlet communication is http whereas to ejb is iiop - which might be blocked.
    Injection only works in managed classes (EJB, Servlet, Listeners..) and an Application Client main class. So yes you could use an app client for handling resource injection.
    m

Maybe you are looking for

  • How to use globally defined variable in SQ01

    Hi, I have created one InfoSet using SQ02. In that I have declared some Additional Fields. These Additional Fields are of type String , so I have declared thses fields in DATA Section of Code of Infoset as it is not possible to define a custom field

  • Word docs don't open full screen on iBook

    My brother, up in Maine, I'm in NY, has an iBook with Word X on it. (I don't know the version of OSX he has but he probably hasn't updated it since he bought it... I am not sure of the model of his iBook either. I can find out.) His main complaint is

  • Firefox 5 for Mac doesn't fully load many secure sites: from Schwab to Ally

    FF5 for the Mac is buggy when it comes to https and other secure sites. I've had trouble getting full functionality with everything from Schwab to AllyBank to Barclay to Gmail as part of a gadget on iGoogle. No problems at all with Safari accessing t

  • Help with QT Reference Movie

    Because I moved from using Sony Vegas to FCP, I didn't keep the SD card structure intact. I only kept the .mts files. Because of this, I used ClipWrap to convert to Apple ProRes 422 LT. I imported this footage into FCP and put it on the timeline and

  • How to make automatic backups of NW Portal systems?

    Hi All, We have SAP CRM, ECC and NW Portal using MaxDB databases. For DB Backups and monitoring, we are using Database Studio. But in this DatabaseStudio, we have no calendar and no automatic backups is possible. In SAP ECC and CRM, we can access the