Help me in Stateless & Stateful Bean

hi,
I'm trying to understand to difference between the stateless and stateful bean. I had created an simple application to test it. But both the beans seems to work in the same way. Could some one explain me with an example the difference between the stateful and stateless bean ...
I'm using J2EE Reference Implementation and Deploytool .
Please help me .. Urgent ....
Cheers !!!
Prabs

Thanks!!
The State Session Bean tries to hold data , even after the client has finished execution. Moreover, the ejbCreate() get fired only once and not for different client.
Is there anything that I should do to make it stateless.
this is my code
Session Bean
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import java.util.*;
public class cartEJB implements SessionBean {
     private Map m;
     public cartEJB() { }
     public void ejbCreate() {
     m = new HashMap();
     System.out.println("ejbCreate()");
     public void ejbActivate() { }
     public void ejbPassivate() { }
     public void ejbRemove() { }     
     public void setSessionContext(SessionContext sc) { }
     public void addCart(String product, String price) {
     System.out.println("Its here Man 1");
     m.put(product, price);
     public void showCart() {
          System.out.println("Its here Man 2");
          Set s = m.entrySet();
          Iterator it = s.iterator();
          while(it.hasNext()) {
               System.out.println(it.next());
REMOTE
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface cart extends EJBObject {
     public void addCart(String product , String price) throws RemoteException;
     public void showCart() throws RemoteException;
HOME
import javax.ejb.EJBHome;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
public interface cartHome extends EJBHome {
     public cart create() throws CreateException, RemoteException;
client application is an web based application ..
Client code. ... (jsp:useBean)
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.servlet.http.*;
public class cartJSP implements HttpSessionBindingListener{
     String Product = new String();
     String Price = new String();
     HttpSession session;
     public cartJSP() {
     public void setProduct(String p){
          this.Product = p;
     public void setPrice(String price) {
          this.Price=price;
     public String getPrice() {
          return Price;
     public String getProduct() {
          return Product;
     public void addIt(String product , String price ) {
     try {
          System.out.println("Comes here");
          Context ic = new InitialContext();
          Object objref = (Object)ic.lookup("ejb/cartJNDI");
          cartHome home = (cartHome)PortableRemoteObject.narrow(objref, cartHome.class);
          cart remote = home.create();          
          remote.addCart(product, price);
          System.out.println("Comes here");
          remote.showCart();     
     catch(Exception e) {
          e.printStackTrace();
     public void showIt() {
     try {
          Context ic = new InitialContext();
          Object objref = (Object)ic.lookup("ejb/cartJNDI");
          cartHome home = (cartHome)PortableRemoteObject.narrow(objref, cartHome.class);
          cart remote = home.create();
          remote.showCart();          
          System.out.println("Comes here 1");
     catch(Exception e) {
          e.printStackTrace();
     public void valueBound(HttpSessionBindingEvent e) {
          session = e.getSession();
          session.setMaxInactiveInterval(60);
          System.out.println("Value Bound");
     public void valueUnbound(HttpSessionBindingEvent e) {
          System.out.println("Value UnBound");
I'm using J2EE RI 1.3 and I'm deploying components using deploytool.
Please help me,
Check the code is wrong or is it a bug in the EJB container.
regards
prabu.

Similar Messages

  • Help Connecting A Stateless Session Bean To MySQL Database

    Hi, I'm trying to connect a simple stateless session bean that has been
    deployed using the admin console to a MySQL database that has been
    set up and pinged using the JDBC Resources/Connection Pools part of the
    admin console.
    When I attempt to connect to the database using the session bean I get the
    following error message:
    Exception in thread "main" java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
         java.rmi.RemoteException: ; nested exception is:
         java.sql.SQLException: No database selected
         at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:161)
         at javax.rmi.CORBA.Util.mapSystemException(Unknown Source)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:142)
         at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
         at DBDynamicStub.testDatabase(_DB_DynamicStub.java)
         at DBClient.main(DBClient.java:9)
    Caused by: java.rmi.RemoteException: ; nested exception is:
         java.sql.SQLException: No database selected
         at com.sun.ejb.containers.InvocationHandlerUtil.throwRemoteException(InvocationHandlerUtil.java:96)
         at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:141)
         at $Proxy26.testDatabase(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:123)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:648)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:192)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1709)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1569)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:951)
         at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:181)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:721)
         at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:469)
         at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1258)
         at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:409)
    Caused by: java.sql.SQLException: No database selected
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:2379)
         at com.mysql.jdbc.Connection.execSQL(Connection.java:2306)
         at com.mysql.jdbc.Statement.executeQuery(Statement.java:1192)
         at DBBean.testDatabase(DBBean.java:45)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:153)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivileged(EJBSecurityManager.java:950)
         at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:158)
    Obviously this means that the bean can't connect to the database but I am
    unsure why this is. When I set up the database using the admin console
    I set the the jndi name to jdbc/test and I've tried using the following look up
    code to find the database that is referenced by the JNDI name:
    Context context = new javax.naming.InitialContext();
              DataSource ds = (DataSource) context.lookup("jdbc/test");
    and also
    Context context = new javax.naming.InitialContext();
    DataSource ds = (DataSource)context.lookup("java:comp/env/jdbc/test");
    Neither of these methods work.
    When I look at the JNDI Tree Browsing window which is available from the
    admin console there is no mention of the database at all, there are four
    items in the three, they are:
    UserTransaction
    ->jdbc
    ->ejb
    DBBean
    Do I need to add a JNDI reference somewhere in order for the bean to locate
    the database? I thought that when I created the database in the admin
    console and specified a JNDI name this would be all that's required in order
    for beans to locate the database, obviously not.
    If anyone can offer any advice at all I would be very very grateful.
    Ian

    stmt.execute("use YOUR_DATABASE_NAME");
    // then your db queries.This approach works for me.
    It also works to specify the database in the query like this:
    InitialContext initCtx = new InitialContext();
    Context envCtx = (Context) initCtx.lookup("java:comp/env");
    DataSource ds = (DataSource) envCtx.lookup("jdbc/myDB");
    Connection conn = ds.getConnection();
    try {
           Statement statement  = conn.createStatement();
           ResultSet rs = statement.executeQuery("select * from myDB.news");
           ...As you can see I added myDB. to the query.
    But why is this necessary?
    If I use DriverManager instead, this is NOT necessary. Like this:
    Connection connection = null;
    try {
           Class.forName("com.mysql.jdbc.Driver");
           connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/myDB", "username", "password");
           Statement statement = connection.createStatement();
           ResultSet rs = statement.executeQuery("select * from news");
           ...Why do I not have to run the query statement.execute("use YOUR_DATABASE_NAME"); or specify the database name in the query statement.executeQuery("select * from myDB.news"); when I use DriverManager to obtain a Connection when I have to do that when using a DataSource?
    It don't seem very efficient to have to run the extra query ( use db-name ) before I run any other query in my application.

  • Stateful vs. stateless session bean

    Hi,
    I am following the pattern of accessing entity beans with a session bean wrapper. I am just wondering if it's more efficient to make it a stateful session bean by keeping references to the home interfaces or make it stateless and do a lookup every time the session bean is created/activated?
    I suppose the number of entity beans I want to access might make a difference. If so, is there a rough number when one way becomes better than the other?
    Thanks for any help in advance.
    Jeff

    - It is far better to use a stateless session bean when implementing the session-facade pattern.
    - Keeping a home interface on the object won't make him stateful.
    - with the stateless beans, you do not decide when they're created. The container does.
    - The number of entity beans is not so important. The only thing important is to have a remote methode in your stateless(es) for each atomic transaction ("atomic" meaning here "you cannot cut").
    /Stephane

  • EJB 3.0 Stateful bean not saving state while Stateless bean is !!!

    My Stateless bean is as follow:
    package test;
    import javax.ejb.Stateless;
    @Stateless(mappedName = "StatelessBean")
    public class StatelessBean implements StatelessBeanRemote {
         int counter;
         public void increment(){
              System.out.println("Stateless counter value:"+counter);
              counter++;
    My Stateful bean is as follow:
    package test;
    import javax.ejb.Stateful;
    @Stateful(mappedName = "StateFulBean")
    public class StateFulBean implements StateFulBeanRemote {
         int counter;
         public void increment(){
              System.out.println("Stateful counter value:"+counter);
    Client is as follows:
    package test;
    import java.util.Hashtable;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    public class TestClient {
         public static void main(String[] args) {
              Hashtable hashtable = new Hashtable();
              hashtable.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
              hashtable.put(Context.PROVIDER_URL, "t3://localhost:7001");
              InitialContext ic;
              try {
                   ic = new InitialContext(hashtable);
                   StateFulBeanRemote stateFulBeanRemote = (StateFulBeanRemote)ic.lookup("StateFulBean#test.StateFulBeanRemote");
                   stateFulBeanRemote.increment();
                   StatelessBeanRemote statelessBeanRemote = (StatelessBeanRemote)ic.lookup("StatelessBean#test.StatelessBeanRemote");
                   statelessBeanRemote.increment();
              } catch (Exception e) {
                   e.printStackTrace();
    The output i am getting after running the client twice is as follows:
    //first time
    Stateful counter value:0
    Stateless counter value:0
    //second time
    Stateful counter value:0
    Stateless counter value:1
    Shouldn't the counter values be incremented in case of Stateful bean and remain the same for Stateless bean. But the output that I am getting is the complete opposite !!!
    Can anyone please explain this confusing behavior of stateless and stateful ejb 3.0 beans.

    868664 wrote:
    Can anyone please explain this confusing behavior of stateless and stateful ejb 3.0 beans.It is very simple: a stateless bean is ASSUMED to be stateless; you cannot keep state in a stateless bean as a contractual rule. That doesn't mean that you will fail to keep state in them at least for a little while, they are still only Java objects. Generally stateless EJBs are pooled, so you may get the same instance each time you use such an EJB, but you may just get another one. It is not dependable and the rules say don't do it - so don't do it.
    A stateful bean is tied to a single client, and so can be used by a client to keep state in it. Since You are running the client application twice you are operating with two different clients and so you will get a new stateful bean each time and your code will keep printing 0. However there is also a bug in your code:
    public void increment(){
    System.out.println("Stateful counter value:"+counter);
    }You are not incrementing anything.

  • How to get stateful and stateless session bean in second jsp

    I create stateful session bean in the first jsp, then how can I get the stateful session bean in the second jsp? I find that somebody store the bean in HttpSession.
    If I store the stateful session bean in HttpSession, then I can get it in the second jsp. My problem is that I can store the stateless session bean in HttpSession, and get it in the second jsp. Then, both stateful and stateless can maintain the state in the second jsp. What is the difference between stateful and stateless session bean in this case ?
    I understand the definition of stateful and stateless session bean, but I'm confuse how to use session bean. Can anyone provide sample jsp to show difference of stateful and stateless? How the stateful session bean can maintain the state for the client?

    Greetings,
    I create stateful session bean in the first jsp, then how can I get the stateful session bean in the
    second jsp? I find that somebody store the bean in HttpSession.Which is the correct scope for sharing client-specific data when 'request' scope is insufficient.
    If I store the stateful session bean in HttpSession, then I can get it in the second jsp. My problem is
    that I can store the stateless session bean in HttpSession, and get it in the second jsp. Then, bothWhy is that a "problem"? Does your application not require the stateless bean to be shared? If so, then don't store the EJBObject reference in the session...
    stateful and stateless can maintain the state in the second jsp. What is the difference betweenWhat do you mean by this exactly?..
    stateful and stateless session bean in this case ?Statefulness of session beans is in regard to maintaining client state (er, in all cases). If your "stateless" bean is receiving information from the client (i.e. its caller) - either through a create method or a business method - and that information is available (retrievable from the bean) on subsequent method calls, then that bean is, in fact, stateful - regardless of how it is deployed.
    I understand the definition of stateful and stateless session bean, but I'm confuse how to use
    session bean.The correct question, it here seems, is "when" to use which type... Use a "stateful" bean when information about (from) the client (i.e. the caller) must be maintained across method calls of the bean. Use a "stateless" bean for general business methods that do not depend on "prior knowledge" of the client (i.e. the caller).
    Can anyone provide sample jsp to show difference of stateful and stateless? How the statefulA "sample JSP" would yield nothing additional... The semantics of calling, using, and "persisting", bean references are always the same - regardless of type or class. However, the reason(s) for using one over the other depends entirely on the needs of your application.
    session bean can maintain the state for the client?I recommend that you spend more time learning about EJBs generally. In particular, it seems you require more fundamental understanding of their scope and lifecycle. Refer to sections 4, 6, and 7 of the EJB 2.0 Specification.
    Regards,
    Tony "Vee Schade" Cook

  • Help!!! Stateful session bean clustering

              I posted this message on interest.clustering.in-memory-replication. But there is
              no answer at all. Could anyone give me
              some hints? Thanks a lot. I am a student and this work is part of my course project.
              It is due soon.
              =================================================================
              I have a big problem to get stateful session bean in-memory replication run on
              clustering. I have three server instances on three nodes and there is always errors
              from the server instance like this when I run the client to invoke the bean methods:
              <Jan 4, 2002 6:47:31 PM EST> <Error> <EJB> <Failed to update the secondary copy
              of a stateful session bean from home:stateful.ejb.AgentSTF>
              Besides, the load balancing can not work probably too. Below is what I get.
              Statistics for different servers:
              "myserver" processed 160 (12%) of 1311 invocations "ejbperf-3" processed 1151
              (88%) of 1311 invocations
              End Client...
              Load balancing works fine with stateless and entity bean.
              Any comments are greatly appreciated.
              Jenny
              

    Hi Jenny,
              Please could you open a case to the customer support ([email protected]) There is a Cr
              on this issue CR059046
              Description of the CR
              WLS 6.1SP1 - Accessing Stateful Session Bean from Stateless Session Bean in a
              cluster fails with errors
              <Oct 5, 2001 5:08:25 PM GMT+00:00> <Error> <EJB> <Failed to update the
              secondary copy of a stateful session bean from home:UserState>
              Regards
              Stephane
              Jenny Liu wrote:
              > I posted this message on interest.clustering.in-memory-replication. But there is
              > no answer at all. Could anyone give me
              > some hints? Thanks a lot. I am a student and this work is part of my course project.
              > It is due soon.
              >
              > =================================================================
              >
              > I have a big problem to get stateful session bean in-memory replication run on
              > clustering. I have three server instances on three nodes and there is always errors
              > from the server instance like this when I run the client to invoke the bean methods:
              >
              > <Jan 4, 2002 6:47:31 PM EST> <Error> <EJB> <Failed to update the secondary copy
              > of a stateful session bean from home:stateful.ejb.AgentSTF>
              >
              > Besides, the load balancing can not work probably too. Below is what I get.
              >
              > Statistics for different servers:
              > "myserver" processed 160 (12%) of 1311 invocations "ejbperf-3" processed 1151
              > (88%) of 1311 invocations
              > End Client...
              >
              > Load balancing works fine with stateless and entity bean.
              >
              > Any comments are greatly appreciated.
              >
              > Jenny
              >
              Regards,
              Stephane Kergozien
              BEA Support
              

  • Stateful/Stateless Session Bean combination

    Hi.
    Im in the process of designing a small card game(2-4 concurrent players), and I need to keep the state stored somewhere. I was thinking about putting most of the functionality together with state in a stateful session bean, but that doesnt scale very well.
    Another option is to have the state stored on the client side and use stateless session beans, but then I have to pass state data on every method call.
    I was thinking of another solution, using small light-weight stateful session beans to hold the state information, and link them to stateless session beans who do the hard work(with local interfaces).
    Is this a good solution which will scale well?
    How many bytes of memory do you think a SFSB with a couple of strings or integers + a reference to a SLSB will take? Thank you.

    Hint:
    To improve performance, you might choose a stateless session bean if it has any of these traits:
    - The bean's state has no data for a specific client.
    - In a single method invocation, the bean performs a generic task for all clients. For example, you might use a stateless session bean to send an email that confirms an online order.
    - The bean fetches from a database a set of read-only data that is often used by clients. Such a bean, for example, could retrieve the table rows that represent the products that are on sale this month.
    http://java.sun.com/j2ee/1.4/docs/tutorial-update2/doc/EJBConcepts3.html

  • Question about operations allowed in methods of stateless and stateful bean

    Hello,
    Can anyone tell me why ejbRemove and ejbCreate are allowed entreprise beans and resource manager access in stateful session beans and not in stateless session beans?
    Thanks in advance,
    Julien Martin.

    Salut Julien,
    Can anyone tell me why ejbRemove and ejbCreate are
    allowed entreprise beans and resource manager access
    in stateful session beans and not in stateless session
    beans?I'm not sure I fully understand your question, but here is some information that may answer it.
    The user is the one who creates and removes a stateful session bean. The container is the one who creates and removes a stateless session bean. So the user can pass any parameters to the create of a SFSB because he theorically knows what to pass. The container doesn't, and doesn't want to. It just wants to create SLSB to pool them, but it doesn't pool SFSB.
    Maybe it doesn't answer your question. Can you reformulate?
    Kexkey

  • Stateless and Stateful beans.

    Please tell me what are the important differences between stateless, and stateful beans.
    Thanks in advance.

    See this thread
    http://forum.java.sun.com/thread.jsp?forum=13&thread=529706&tstart=15&trange=15

  • Difference between stateful and stateless session beans

    can any body explain simply what is the difference between stateful and stateless session beans? also in what kind of situations we can use these.

    Hi
    This is the classificatio os Session Bean.
    (1) Statfull
    (2) Stateless
    Stateful means u will persists the state of the object.
    USESE:
    In a Banking system u can use the statful session just for maintaing the
    state.
    (2) STATELESS: that's mean u do't want to persists any state of the object. that's mean a single Request is coming ,do the desire and give the output.
    EX: A Credit Card System is the Example of Stateless.
    May it will helpfull to understands u. if any need write here
    saM

  • Transaction Management -  App Module in Stateless Session Bean

    Hi All,
    We are using Application Module in local mode in a Stateless Session Bean. The application module gets the database connection from the datasource of the application server(Oracle 9iAS).
    The problem that we are facing is as follows
    - When a database update/insert is made using the Application Module and the ViewObject (and the underlying Entity Object), the changes are not being commited.
    Please note that we are not using the ApplicationModule.getTransaction.commit() as it does not give us commit/rollback control from another Session Bean/UseCase. We instead are relying on the Container to manager the transaction and commit the database changes. But the container does not seem to refresh the changes to the database.
    Q1 - Is there a contract between the container and the application module that needs to be created so that the container managed-transaction and the application module work together ?
    Any help in this matter would be greatly appreciated.
    -Ankur Sinha

    Q1 - Is there a contract between the container and the application module that needs to be created so that the container managed-transaction and the application module work together ?For stateless beans you have to call postChanges in the business method for the changes to be applied to the db. For stateful beans bc4j we do that automatically just before the transaction ends.
    Take a look at the following howto
    http://otn.oracle.com/products/jdev/howtos/bc4j/ejbstateless_with_bc4j.html
    In 9.0.3 you'll be able to create a stateless service bean declaritively.
    dhiraj Hi dhiraj,
    - I looked at the example but was not able to find the ContainerManagedTxnHandlerImpl class in the BC4J jars. Can you point me to the latest version of BC4J on technet ?. I already have JDeveloper 9.0.2
    - Regarding your response, what do you mean by creating stateless service bean declaritively ?
    Thanks,
    Ankur

  • Registering EJB/Stateless Session Bean Web Service in Registry

    Hi verybody!
    I would like to know how I can register a Web Service in a registry. The web service is implemented as a session bean.
    The problem is not the actual code to register the service, but how and where can I hook this code into the application so that it is started when the application server is started.
    I've read the Sun J2EE tutorial which registered the service in the moment when the context for the servlet for an ordinary web client was created. This is not what I want. I would like to register the service when starting the EJB container, without the need to give it a kick from some external interface.
    Any help or ideas will be greatly welcome
    Regards
    PI

    1. But I thought you were using a 'stateful session bean'?
    2. For stateless session beans, there is no direct link between a remote reference and an instance of the bean. It is safe to hang on to the remote reference as long as you would like, of course it may go stale if the server dies. You will also find that the create() method does not actually contact the server, so doing it each usage costs very little. So, either way you should be fine.
    3. As for memory leaks, make sure that you are closing all statements, result sets, etc. promptly. These are commonly the problem. Also, use hprof or some other profile tool to determine what types of data you are allocating and (with better tools) what types of data you may be holding on to references to.
    Chuck

  • Transactional error when using JMS from stateless session bean

    I get a transaction exception when committing a bean method responsible for sending to a JMS topic. This happens only occasionally when two separate threads invoke this method "at the same time".
    The scenario:
    Two separate threads running two different instances of a stateless session bean (slsb A). This ejb (slsb A) has an injected slsb B which is communicating with the the topic.
    Both instances of slsb A are utilising the same instance of slsb B.
    The CMT transactions for the two threads start in slsb A from methods with transaction attribute "RequiresNew". All nested methods are to other slsbs and have the transaction attribute "Required". The method in slsb B which sends the message is closing both the session and the connection to the topic.
    I'm running Glassfish version 9.1_02 (build b04-fcs) and JMS implementation OpenMQ version 4.1.
    Stacktrace (glassfish log):
    [#|2008-09-09T13:00:40.515+0200|SEVERE|sun-appserver9.1|javax.resourceadapter.mqjmsra.outbound.connection|_ThreadID=18;_ThreadName=httpSSLWorkerThread-8080-1;_RequestID=108e8418-71a6-4d8b-a94d-9e1edc885891;|commitTransaction (XA) on JMSService:jmsdirect failed for connectionId:5754505514139844608 and onePhase:false due to unkown JMSService server error.|#]
    [#|2008-09-09T13:00:40.515+0200|SEVERE|sun-appserver9.1|javax.enterprise.system.core.transaction|_ThreadID=18;_ThreadName=httpSSLWorkerThread-8080-1;org.omg.CORBA.INTERNAL:   vmcid: 0x0  minor code: 0 completed: Maybe;commit;_RequestID=108e8418-71a6-4d8b-a94d-9e1edc885891;|JTS5031: Exception [org.omg.CORBA.INTERNAL:   vmcid: 0x0  minor code: 0 completed: Maybe] on Resource [commit] operation.|#]
    [#|2008-09-09T13:00:40.531+0200|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=18;_ThreadName=httpSSLWorkerThread-8080-1;SubscriptionBean;|EJB5018: An exception was thrown during an ejb invocation on [SubscriptionBean]|#]
    [#|2008-09-09T13:00:40.531+0200|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=18;_ThreadName=httpSSLWorkerThread-8080-1;|
    javax.ejb.EJBException: Unable to complete container-managed transaction.; nested exception is: javax.transaction.SystemException: org.omg.CORBA.INTERNAL: JTS5031: Exception [org.omg.CORBA.INTERNAL:   vmcid: 0x0  minor code: 0 completed: Maybe] on Resource [commit] operation. vmcid: 0x0 minor code: 0 completed: No
    javax.transaction.SystemException: org.omg.CORBA.INTERNAL: JTS5031: Exception [org.omg.CORBA.INTERNAL:   vmcid: 0x0  minor code: 0 completed: Maybe] on Resource [commit] operation. vmcid: 0x0 minor code: 0 completed: No
         at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:321)
         at com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.commit(J2EETransactionManagerImpl.java:1030)
         at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:397)
         at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3792)
         at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3585)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1354)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:205)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127)
         at $Proxy130.requestNewSubscription(Unknown Source)
         at com.abeldrm.kms.core.services.subscription.SubscriptionWSBean.requestNewSubscription(SubscriptionWSBean.java:94)
         at sun.reflect.GeneratedMethodAccessor127.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
         at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
         at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
         at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
         at com.sun.ejb.containers.WebServiceInvocationHandler.invoke(WebServiceInvocationHandler.java:189)
         at $Proxy129.requestNewSubscription(Unknown Source)
         at sun.reflect.GeneratedMethodAccessor126.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.enterprise.webservice.InvokerImpl.invoke(InvokerImpl.java:81)
         at com.sun.enterprise.webservice.EjbInvokerImpl.invoke(EjbInvokerImpl.java:82)
         at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
         at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
         at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
         at com.sun.enterprise.webservice.MonitoringPipe.process(MonitoringPipe.java:147)
         at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
         at com.sun.xml.ws.tx.service.TxServerPipe.process(TxServerPipe.java:329)
         at com.sun.enterprise.webservice.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:218)
         at com.sun.enterprise.webservice.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:129)
         at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)
         at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444)
         at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
         at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
         at com.sun.enterprise.webservice.Ejb3MessageDispatcher.handlePost(Ejb3MessageDispatcher.java:113)
         at com.sun.enterprise.webservice.Ejb3MessageDispatcher.invoke(Ejb3MessageDispatcher.java:87)
         at com.sun.enterprise.webservice.EjbWebServiceServlet.dispatchToEjbEndpoint(EjbWebServiceServlet.java:226)
         at com.sun.enterprise.webservice.EjbWebServiceServlet.service(EjbWebServiceServlet.java:155)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
         at com.sun.enterprise.web.AdHocContextValve.invoke(AdHocContextValve.java:114)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:87)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
         at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
         at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    IMQ broker log:
    [09/Sep/2008:13:00:40 CEST] ERROR CommitTransaction: commit failed. Connection ID: 5754505514139844608, Transaction ID: 0:
    com.sun.messaging.jmq.jmsserver.util.BrokerException: Unknown Transaction 0
         at com.sun.messaging.jmq.jmsserver.data.protocol.ProtocolImpl.commitTransaction(ProtocolImpl.java:630)
         at com.sun.messaging.jmq.jmsserver.service.imq.IMQDirectService.commitTransaction(IMQDirectService.java:1735)
         at com.sun.messaging.jms.ra.DirectXAResource.commit(DirectXAResource.java:201)
         at com.sun.jts.jtsxa.OTSResourceImpl.commit(OTSResourceImpl.java:114)
         at com.sun.jts.CosTransactions.RegisteredResources.distributeCommit(RegisteredResources.java:795)
         at com.sun.jts.CosTransactions.TopCoordinator.commit(TopCoordinator.java:2111)
         at com.sun.jts.CosTransactions.CoordinatorTerm.commit(CoordinatorTerm.java:403)
         at com.sun.jts.CosTransactions.TerminatorImpl.commit(TerminatorImpl.java:249)
         at com.sun.jts.CosTransactions.CurrentImpl.commit(CurrentImpl.java:623)
         at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:309)
         at com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.commit(J2EETransactionManagerImpl.java:1030)
         at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:397)
         at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3792)
         at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3585)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1354)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:205)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127)
         at $Proxy130.requestNewSubscription(Unknown Source)
         at com.abeldrm.kms.core.services.subscription.SubscriptionWSBean.requestNewSubscription(SubscriptionWSBean.java:94)
         at sun.reflect.GeneratedMethodAccessor127.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
         at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
         at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
         at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
         at com.sun.ejb.containers.WebServiceInvocationHandler.invoke(WebServiceInvocationHandler.java:189)
         at $Proxy129.requestNewSubscription(Unknown Source)
         at sun.reflect.GeneratedMethodAccessor126.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.enterprise.webservice.InvokerImpl.invoke(InvokerImpl.java:81)
         at com.sun.enterprise.webservice.EjbInvokerImpl.invoke(EjbInvokerImpl.java:82)
         at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:146)
         at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:257)
         at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
         at com.sun.enterprise.webservice.MonitoringPipe.process(MonitoringPipe.java:147)
         at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:106)
         at com.sun.xml.ws.tx.service.TxServerPipe.process(TxServerPipe.java:329)
         at com.sun.enterprise.webservice.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:218)
         at com.sun.enterprise.webservice.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:129)
         at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
         at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
         at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
         at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
         at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
         at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243)
         at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444)
         at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
         at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
         at com.sun.enterprise.webservice.Ejb3MessageDispatcher.handlePost(Ejb3MessageDispatcher.java:113)
         at com.sun.enterprise.webservice.Ejb3MessageDispatcher.invoke(Ejb3MessageDispatcher.java:87)
         at com.sun.enterprise.webservice.EjbWebServiceServlet.dispatchToEjbEndpoint(EjbWebServiceServlet.java:226)
         at com.sun.enterprise.webservice.EjbWebServiceServlet.service(EjbWebServiceServlet.java:155)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
         at com.sun.enterprise.web.AdHocContextValve.invoke(AdHocContextValve.java:114)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:87)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
         at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
         at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
         at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
         at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
         at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    Have anyone any idea why this should fail?
    Regards,
    Jon

    I would suggest opening a case with [email protected] FWIW, I recall seeing
              something like this in WLS 6.0. I believe it is fixed in WLS 6.1
              -- Rob
              Chris Dupuy wrote:
              > Btw, this occurs when I create an stateful session bean that ends up
              > throwing an exception and setRollbackOnly() is called. From that point
              > forward, my logs fill with this message.
              >
              > Chris
              >
              > "Chris Dupuy" <[email protected]> wrote in message
              > news:[email protected]..
              > > anyone know what this means, and what you can do about it?
              > >
              > >
              > > <Error> <ConnectionManager> <atossd03> <cbeyondServer> <ExecuteThread:
              > '14'
              > > for queue: 'd
              > > efault'> <> <> <000000> <Closing:
              > 'weblogic.rjvm.t3.T3JVMConnection@488831'
              > > because of: 'Server received a message over an uniniti
              > > alized connection: 'JVMMessage from: 'null' to:
              > >
              > '5825313123619479267S:10.6.6.40:[8000,8000,8001,8001,8000,8001,-1]:cbeyond:c
              > > beyond
              > > Server' cmd: 'CMD_REQUEST', QOS: '101', responseId: '2', invokableId: '1',
              > > flags: 'JVMIDs Not Sent, TX Context Not Sent', abbrev o
              > > ffset: '204'''>
              > >
              > >
              > >
              

  • Where to store stateless session bean reference?

    Hi,
    I am currently writing my first ejb-jar <-> web app pair of applications. Thanks to EJB3.0 and J2EE5 the ejb part was quite easy to learn. J2EE has become a really cool platform in its recent version.
    On the Web Application side I have the following question:
    Where should references to stateless session beans generally be stored? Is it OK to store them in the ServletContext? In the HTTP session? Or is it better to do a JNDI lookup on a per request basis?

    Application Scope (ServletContext) if many servlets use it, initialised by applicationListener (big advantage is that your webapp will not load if bean lookup fails.
    Page scope (instance variable of servlet ), initialised in init() method of servlet if only needed by this page (servlet).
    Session scope: makes no sense for stateless session beans, useful for stateful session beans only
    Request scope: rarely used for this because JNI lookup overhead.
    Hope this helps, R

  • How to use jta in toplink and stateless session bean EJB 3.0?

    I have an application with techologies jsf,stateless session bean, adf, toplink
    generated by toplink workbench.
    In web side ı want to use two methods in stateless session bean which are updated
    different tables. I call these methods in my page backing bean.
    I also want to JTA in web side. My first methods is done correctly, but second method has an error. I wanto to rollback all transaction.
    How can ı do that? with using JTA in Toplink...

    Yuichi
    Did you manage to solve this?  I'm doing something similar and seeing the same problem, although they're up to 7.3 SP7.
    Any help greatly appreciated.
    Lewis

Maybe you are looking for

  • My computer no longer recognizes my iphone after I updated the phone.

    What do I have to do to correct that?

  • Array of numbers

    Iam having array of 32 numbers,from these array of 32 numbers I want to select only the first number.how can I do this.

  • Workflow for using Pages offline

    How do I set up for this scenario. Have a Pages document in iCloud.  Will be flying to Europe (no internet) so want to work on the document - and then when I arrive and have internet access want the new version to overwrite the old version. Any sugge

  • Critical error with default host

    Hi, I am relatively new to Web Logic and think I have made an error within the Web Logic Console with the default host parameter. As a result, I can no longer start up my WLS. Is there a way I can edit this parameter outside of the Web Logic Console?

  • How to invoke a bean in WLS from a servlet in JWS

              Hi,           I have an application where in i am invoking an EJB in WLS from a servlet in JWS.Could any one give me the correct steps to approach this problem.Till now i was using WLS as webserver itself.can i use the same t3 protocol in m