You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by phanibalaji <ph...@gmail.com> on 2008/04/01 12:11:34 UTC

Getting serializable exceptions while running stateful session bean.

I am using Apache Geronimo2.1 and the OPENEJB container setting are as
follows in config.xml (Pool size is 3).

   <module name="org.apache.geronimo.configs/openejb/2.1/car">
        <gbean name="EJBNetworkService">
            <attribute name="port">${OpenEJBPort + PortOffset}</attribute>
            <attribute name="host">${ServerHostname}</attribute>
        </gbean>
        <gbean name="DefaultStatefulContainer">
            <attribute name="properties">PoolSize 3
                                StrictPooling true</attribute>
        </gbean>
    </module>

I have the following bean class

___________________________________________________________
package examples.session.stateful;

import javax.ejb.*;
import javax.interceptor.Interceptors;



@Stateful
@Remote(Count.class)
@Interceptors(CountCallbacks.class)
public class CountBean implements Count {
	private static int numberofbeans = 0;
	
    /** The current counter is our conversational state. */
    private int val;

	 public CountBean(){ numberofbeans++;
System.out.println("number_of_beans="+numberofbeans);}
    /**
     * The count() business method.
     */
    public int count() {
        System.out.println("count()");
        return ++val;
    }

    /**
     * The set() business method.
     */
    public void set(int val) {
        this.val = val;
        System.out.println("set()");
    }

    /**
     * The remove method is annotated so that the container knows
     * it can remove the bean after this method returns.
     */
    @Remove
    public void remove() {
        System.out.println("remove()");
    }

}

___________________________________________________________


I have the following standalone EJB client 

___________________________________________________________

package examples.session.stateful;

import javax.naming.*;

/**
 * This class is a simple client for a stateful session bean.
 *
 * To illustrate how passivation works, configure your EJB server
 * to allow only 2 stateful session beans in memory. (Consult your 
 * vendor documentation for details on how to do this.) We create 
 * 3 beans in this example to see how and when beans are passivated.
 */
public class CountClient {

    public static final int noOfClients = 3;

    public static void main(String[] args) {
        try {
            /* Get a reference to the bean */
			java.util.Properties env = new java.util.Properties();

	
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.RemoteInitialContextFactory");
     	env.put(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");
		
            Context ctx = new InitialContext(env);

            /* An array to hold the Count beans */
            Count count[] = new Count[noOfClients];
            int countVal = 0;

            /* Create and count() on each member of array */
            System.out.println("Instantiating beans...");
            for (int i = 0; i < noOfClients; i++) {
                count[i] = (Count) ctx.lookup("CountBeanRemote");

                /* initialize each bean to the current count value */
                count[i].set(countVal);

                /* Add 1 and print */
                countVal = count[i].count();
                System.out.println(countVal);

                /*  Sleep for 1/2 second */
                Thread.sleep(100);
            }

            /*
             * Let's call count() on each bean to  make sure the 
             * beans were passivated and activated properly.
             */
            System.out.println("Calling count() on beans...");
            for (int i = 0; i < noOfClients; i++) {

                /* Add 1 and print */
                countVal = count[i].count();
                System.out.println(countVal);

                /* call remove to let the container dispose of the bean */
                count[i].remove();

                /*  Sleep for 1/2 second */
                Thread.sleep(50);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
__________________________________________________________________

The client creates three stateful session beans and the Geronimo server is
also configured to have max 3 bean instances. I am presuming that, server
need not passivate any bean instances as number of clients are same as
number bean instances. However, when I run the client, I see the following
exceptions on the client command window.

___________________________________________________________________
C:\>java examples.session.stateful.CountClient
Instantiating beans...
1
2
javax.naming.NamingException: Unknown error in container [Root exception is
java.lang.reflect.UndeclaredThrowableExceptio
        at
org.apache.openejb.server.ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:125)
        at
org.apache.openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:168)
        at
org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:126)
        at
org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:84)
        at
org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:60)
        at
org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java:76)
        at
org.apache.openejb.server.ServiceAccessController.service(ServiceAccessController.java:55)
        at
org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java:118)
        at java.lang.Thread.run(Thread.java:803)
Caused by: java.lang.reflect.UndeclaredThrowableException
        at $Proxy18.create(Unknown Source)
        at
org.apache.openejb.core.ivm.naming.BusinessRemoteReference.getObject(BusinessRemoteReference.java:33)
        at
org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:150)
        at
org.apache.openejb.server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:174)
        at
org.apache.openejb.server.ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:119)
        ... 8 more
Caused by: java.rmi.RemoteException: Container has suffered a
SystemException; nested exception is:
        java.io.NotSerializableException:
examples.session.stateful.CountBean
        at
org.apache.openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:243)
        at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
        at
org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
        ... 13 more
Caused by: java.io.NotSerializableException:
examples.session.stateful.CountBean
        at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1108)
        at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1462)
        at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1434)
        at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1377)
        at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
        at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1462)
        at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1434)
        at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1377)
        at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
        at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
        at
org.apache.openejb.core.stateful.SimplePassivater.passivate(SimplePassivater.java:73)
        at
org.apache.openejb.core.stateful.SimplePassivater.passivate(SimplePassivater.java:93)
        at
org.apache.openejb.core.stateful.StatefulInstanceManager.passivate(StatefulInstanceManager.java:489)
        at
org.apache.openejb.core.stateful.StatefulInstanceManager$BeanEntryQueue.add(StatefulInstanceManager.java:581)
        at
org.apache.openejb.core.stateful.StatefulInstanceManager.poolInstance(StatefulInstanceManager.java:415)
        at
org.apache.openejb.core.stateful.StatefulContainer.createEJBObject(StatefulContainer.java:291)
        at
org.apache.openejb.core.stateful.StatefulContainer.invoke(StatefulContainer.java:241)
        at
org.apache.openejb.core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
        at
org.apache.openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:158)
        ... 15 more
______________________________________________________________________________________

Only when pool size is set to 4 does the client run successfully as below
       <gbean name="DefaultStatefulContainer">
            <attribute name="properties">PoolSize 4
                                StrictPooling true</attribute>
        </gbean>


Can somebody suggest me what's happening?? We want restrict number of
stateful bean instances and with the above observation, I guess, if number
of clients become more than what's configured in Geronimo server, we hit the
Serializable exception.

Thanks in advance.

Phani B Madgula
-- 
View this message in context: http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16417509.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Getting serializable exceptions while running stateful session bean.

Posted by phanibalaji <ph...@gmail.com>.
Let me try with the latest OpenEJB image and try. I will update once it's
done.

Thanks for all the info.

Phani


David Blevins wrote:
> 
> I'm guessing examples.session.stateful.CountCallbacks is an  
> interceptor.  If it is than definitely have it implement  
> java.io.Serializable as well and the problem should go away (that was  
> also fixed in the forthcoming release).
> 
> -David
> 
> 
> On Apr 4, 2008, at 1:47 AM, phanibalaji wrote:
>>
>> Here is what being thrown on the command window of the EJB client
>> _________________________________________________________
>>
>> Instantiating beans...
>> 1
>> 2
>> javax.naming.NamingException: Unknown error in container [Root  
>> exception is
>> java.lang.reflect.UndeclaredThrowableException]
>>        at
>> org 
>> .apache 
>> .openejb 
>> .server 
>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:125)
>>        at
>> org 
>> .apache 
>> .openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:168)
>>        at
>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:126)
>>        at
>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:84)
>>        at
>> org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:60)
>>        at
>> org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java:76)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .server.ServiceAccessController.service(ServiceAccessController.java: 
>> 55)
>>        at
>> org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java:118)
>>        at java.lang.Thread.run(Thread.java:803)
>> Caused by: java.lang.reflect.UndeclaredThrowableException
>>        at $Proxy18.create(Unknown Source)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core 
>> .ivm 
>> .naming 
>> .BusinessRemoteReference.getObject(BusinessRemoteReference.java:33)
>>        at
>> org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java: 
>> 150)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:174)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .server 
>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:119)
>>        ... 8 more
>> Caused by: java.rmi.RemoteException: Container has suffered a
>> SystemException; nested exception is:
>>        java.io.NotSerializableException:
>> examples.session.stateful.CountCallbacks
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:243)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .util 
>> .proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
>>        ... 13 more
>> Caused by: java.io.NotSerializableException:
>> examples.session.stateful.CountCallbacks
>>        at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1108)
>>        at
>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
>>        at java.util.HashMap.writeObject(HashMap.java:1040)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at
>> sun 
>> .reflect 
>> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
>>        at
>> sun 
>> .reflect 
>> .DelegatingMethodAccessorImpl 
>> .invoke(DelegatingMethodAccessorImpl.java:43)
>>        at java.lang.reflect.Method.invoke(Method.java:615)
>>        at
>> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java: 
>> 972)
>>        at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
>> 1426)
>>        at
>> java 
>> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
>> 1377)
>>        at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
>>        at
>> java 
>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
>> 1462)
>>        at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
>> 1434)
>>        at
>> java 
>> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
>> 1377)
>>        at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
>>        at
>> java 
>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
>> 1462)
>>        at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
>> 1434)
>>        at
>> java 
>> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
>> 1377)
>>        at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
>>        at
>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:73)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:93)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core 
>> .stateful 
>> .StatefulInstanceManager.passivate(StatefulInstanceManager.java:489)
>>        at
>> org.apache.openejb.core.stateful.StatefulInstanceManager 
>> $BeanEntryQueue.add(StatefulInstanceManager.java:581)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core 
>> .stateful 
>> .StatefulInstanceManager.poolInstance(StatefulInstanceManager.java: 
>> 415)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core 
>> .stateful.StatefulContainer.createEJBObject(StatefulContainer.java: 
>> 291)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.stateful.StatefulContainer.invoke(StatefulContainer.java:241)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:158)
>>        ... 15 more
>>
>> _________________________________________________________
>>
>> Here is what observed in the Geronimo log
>> __________________________________________________________
>>
>> 14:13:11,132 INFO  [startup] Assembling app:
>> C:\IBM\Geronimo-2.1\var\temp\geronimo-deployer7663.tmpdir\stateful.jar
>> 14:13:11,162 INFO  [startup] Jndi(name=CountBeanRemote) -->
>> Ejb(deployment-id=EmployeeDemo-stateful-ejb-dd/CountBean)
>> 14:13:11,172 INFO  [startup] Created
>> Ejb(deployment-id=EmployeeDemo-stateful-ejb-dd/CountBean,
>> ejb-name=CountBean, container=Default Stateful Container)
>> 14:13:11,172 INFO  [startup] Deployed
>> Application(path=C:\IBM\Geronimo-2.1\var\temp\geronimo- 
>> deployer7663.tmpdir\stateful.jar)
>> 14:13:11,252 INFO  [DirectoryHotDeployer]     Deployed
>> samples/EmployeeDemo-stateful-ejb-dd/2.1/jar
>>
>> 14:13:26,264 INFO  [OpenEJB] invoking method create on
>> EmployeeDemo-stateful-ejb-dd/CountBean
>> 14:13:26,354 INFO  [OpenEJB] finished invoking method create
>> 14:13:27,035 INFO  [OpenEJB] The following method doesn't have a  
>> transaction
>> policy assigned: public abstract void
>> examples.session.stateful.Count.set(int)
>> 14:13:27,085 INFO  [Transaction] TX Required: Started transaction
>> org.apache.geronimo.transaction.manager.TransactionImpl@62786278
>> 14:13:27,095 INFO  [Transaction] TX Required: Committing transaction
>> org.apache.geronimo.transaction.manager.TransactionImpl@62786278
>> 14:13:27,105 INFO  [OpenEJB] The following method doesn't have a  
>> transaction
>> policy assigned: public abstract int  
>> examples.session.stateful.Count.count()
>> 14:13:27,105 INFO  [Transaction] TX Required: Started transaction
>> org.apache.geronimo.transaction.manager.TransactionImpl@6a5e6a5e
>> 14:13:27,105 INFO  [Transaction] TX Required: Committing transaction
>> org.apache.geronimo.transaction.manager.TransactionImpl@6a5e6a5e
>> 14:13:27,215 INFO  [OpenEJB] invoking method create on
>> EmployeeDemo-stateful-ejb-dd/CountBean
>> 14:13:27,215 INFO  [OpenEJB] finished invoking method create
>> 14:13:27,225 INFO  [Transaction] TX Required: Started transaction
>> org.apache.geronimo.transaction.manager.TransactionImpl@266c266c
>> 14:13:27,225 INFO  [Transaction] TX Required: Committing transaction
>> org.apache.geronimo.transaction.manager.TransactionImpl@266c266c
>> 14:13:27,235 INFO  [Transaction] TX Required: Started transaction
>> org.apache.geronimo.transaction.manager.TransactionImpl@45c445c4
>> 14:13:27,235 INFO  [Transaction] TX Required: Committing transaction
>> org.apache.geronimo.transaction.manager.TransactionImpl@45c445c4
>> 14:13:27,345 INFO  [OpenEJB] invoking method create on
>> EmployeeDemo-stateful-ejb-dd/CountBean
>> 14:13:27,355 INFO  [OpenEJB] Passivating to file
>> C:\IBM\Geronimo-2.1\var\temp 
>> \f359d12e4a271795=40e71719=1191899ac1e=-7ff7
>> 14:13:27,375 INFO  [OpenEJB] Passivation failed
>> java.io.NotSerializableException:  
>> examples.session.stateful.CountCallbacks
>> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
>> 1108)
>> 	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java: 
>> 324)
>> 	at java.util.HashMap.writeObject(HashMap.java:1040)
>> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> 	at
>> sun 
>> .reflect 
>> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
>> 	at
>> sun 
>> .reflect 
>> .DelegatingMethodAccessorImpl 
>> .invoke(DelegatingMethodAccessorImpl.java:43)
>> 	at java.lang.reflect.Method.invoke(Method.java:615)
>> 	at  
>> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java: 
>> 972)
>> 	at  
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
>> 1426)
>> 	at
>> java 
>> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
>> 1377)
>> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
>> 1106)
>> 	at
>> java 
>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
>> 1462)
>> 	at  
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
>> 1434)
>> 	at
>> java 
>> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
>> 1377)
>> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
>> 1106)
>> 	at
>> java 
>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
>> 1462)
>> 	at  
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
>> 1434)
>> 	at
>> java 
>> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
>> 1377)
>> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
>> 1106)
>> 	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java: 
>> 324)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:73)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:93)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .core 
>> .stateful 
>> .StatefulInstanceManager.passivate(StatefulInstanceManager.java:489)
>> 	at
>> org.apache.openejb.core.stateful.StatefulInstanceManager 
>> $BeanEntryQueue.add(StatefulInstanceManager.java:581)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .core 
>> .stateful 
>> .StatefulInstanceManager.poolInstance(StatefulInstanceManager.java: 
>> 415)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .core 
>> .stateful.StatefulContainer.createEJBObject(StatefulContainer.java: 
>> 291)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .core.stateful.StatefulContainer.invoke(StatefulContainer.java:241)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:158)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .util 
>> .proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
>> 	at $Proxy18.create(Unknown Source)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .core 
>> .ivm 
>> .naming 
>> .BusinessRemoteReference.getObject(BusinessRemoteReference.java:33)
>> 	at
>> org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java: 
>> 150)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:174)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .server 
>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:119)
>> 	at
>> org 
>> .apache 
>> .openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:168)
>> 	at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java: 
>> 126)
>> 	at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java: 
>> 84)
>> 	at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java: 
>> 60)
>> 	at  
>> org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java:76)
>> 	at
>> org 
>> .apache 
>> .openejb 
>> .server.ServiceAccessController.service(ServiceAccessController.java: 
>> 55)
>> 	at org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java: 
>> 118)
>> 	at java.lang.Thread.run(Thread.java:803)
>>
>> __________________________________________________________
>>
>>
>> David Blevins wrote:
>>>
>>> Hmm, that should definitely work.  Can you post the exact error?
>>>
>>> -David
>>>
>>> On Apr 3, 2008, at 12:32 AM, phanibalaji wrote:
>>>>
>>>> I tried this as well, but without success. Hitting the same error.
>>>>
>>>> Here is the CountBean.java
>>>>
>>>> _______________________________________________________________________
>>>>
>>>> package examples.session.stateful;
>>>>
>>>> import javax.ejb.*;
>>>> import javax.interceptor.Interceptors;
>>>>
>>>>
>>>>
>>>> @Stateful
>>>> @Remote(Count.class)
>>>> @Interceptors(CountCallbacks.class)
>>>> public class CountBean implements Count, java.io.Serializable {
>>>> 	private static int numberofbeans = 0;
>>>> 	
>>>>   /** The current counter is our conversational state. */
>>>>   private int val;
>>>>
>>>> 	 public CountBean(){ numberofbeans++;
>>>> System.out.println("number_of_beans="+numberofbeans);}
>>>>   /**
>>>>    * The count() business method.
>>>>    */
>>>>   public int count() {
>>>>       System.out.println("count()");
>>>>       return ++val;
>>>>   }
>>>>
>>>>   /**
>>>>    * The set() business method.
>>>>    */
>>>>   public void set(int val) {
>>>>       this.val = val;
>>>>       System.out.println("set()");
>>>>   }
>>>>
>>>>   /**
>>>>    * The remove method is annotated so that the container knows
>>>>    * it can remove the bean after this method returns.
>>>>    */
>>>>   @Remove
>>>>   public void remove() {
>>>>       System.out.println("remove()");
>>>>   }
>>>>
>>>> }
>>>>
>>>> _______________________________________________________________________
>>>>
>>>> Thanks
>>>> Phani B Madgula
>>>>
>>>>
>>>>
>>>> David Blevins wrote:
>>>>>
>>>>> This issue was fixed in the forthcoming OpenEJB 3.0 final, which  
>>>>> will
>>>>> be included in Geronimo 2.1.1.
>>>>>
>>>>> In the meantime you can have your stateful bean implement the
>>>>> javax.io.Serializable interface and all should work fine.
>>>>>
>>>>> -David
>>>>>
>>>>> On Apr 1, 2008, at 3:11 AM, phanibalaji wrote:
>>>>>>
>>>>>> I am using Apache Geronimo2.1 and the OPENEJB container setting
>>>>>> are as
>>>>>> follows in config.xml (Pool size is 3).
>>>>>>
>>>>>> <module name="org.apache.geronimo.configs/openejb/2.1/car">
>>>>>>      <gbean name="EJBNetworkService">
>>>>>>          <attribute name="port">${OpenEJBPort + PortOffset}</
>>>>>> attribute>
>>>>>>          <attribute name="host">${ServerHostname}</attribute>
>>>>>>      </gbean>
>>>>>>      <gbean name="DefaultStatefulContainer">
>>>>>>          <attribute name="properties">PoolSize 3
>>>>>>                              StrictPooling true</attribute>
>>>>>>      </gbean>
>>>>>>  </module>
>>>>>>
>>>>>> I have the following bean class
>>>>>>
>>>>>> ___________________________________________________________
>>>>>> package examples.session.stateful;
>>>>>>
>>>>>> import javax.ejb.*;
>>>>>> import javax.interceptor.Interceptors;
>>>>>>
>>>>>>
>>>>>>
>>>>>> @Stateful
>>>>>> @Remote(Count.class)
>>>>>> @Interceptors(CountCallbacks.class)
>>>>>> public class CountBean implements Count {
>>>>>> 	private static int numberofbeans = 0;
>>>>>> 	
>>>>>>  /** The current counter is our conversational state. */
>>>>>>  private int val;
>>>>>>
>>>>>> 	 public CountBean(){ numberofbeans++;
>>>>>> System.out.println("number_of_beans="+numberofbeans);}
>>>>>>  /**
>>>>>>   * The count() business method.
>>>>>>   */
>>>>>>  public int count() {
>>>>>>      System.out.println("count()");
>>>>>>      return ++val;
>>>>>>  }
>>>>>>
>>>>>>  /**
>>>>>>   * The set() business method.
>>>>>>   */
>>>>>>  public void set(int val) {
>>>>>>      this.val = val;
>>>>>>      System.out.println("set()");
>>>>>>  }
>>>>>>
>>>>>>  /**
>>>>>>   * The remove method is annotated so that the container knows
>>>>>>   * it can remove the bean after this method returns.
>>>>>>   */
>>>>>>  @Remove
>>>>>>  public void remove() {
>>>>>>      System.out.println("remove()");
>>>>>>  }
>>>>>>
>>>>>> }
>>>>>>
>>>>>> ___________________________________________________________
>>>>>>
>>>>>>
>>>>>> I have the following standalone EJB client
>>>>>>
>>>>>> ___________________________________________________________
>>>>>>
>>>>>> package examples.session.stateful;
>>>>>>
>>>>>> import javax.naming.*;
>>>>>>
>>>>>> /**
>>>>>> * This class is a simple client for a stateful session bean.
>>>>>> *
>>>>>> * To illustrate how passivation works, configure your EJB server
>>>>>> * to allow only 2 stateful session beans in memory. (Consult your
>>>>>> * vendor documentation for details on how to do this.) We create
>>>>>> * 3 beans in this example to see how and when beans are  
>>>>>> passivated.
>>>>>> */
>>>>>> public class CountClient {
>>>>>>
>>>>>>  public static final int noOfClients = 3;
>>>>>>
>>>>>>  public static void main(String[] args) {
>>>>>>      try {
>>>>>>          /* Get a reference to the bean */
>>>>>> 			java.util.Properties env = new java.util.Properties();
>>>>>>
>>>>>> 	
>>>>>> env
>>>>>> .put
>>>>>> (Context
>>>>>> .INITIAL_CONTEXT_FACTORY
>>>>>> ,"org.apache.openejb.client.RemoteInitialContextFactory");
>>>>>>   	env.put(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");
>>>>>> 		
>>>>>>          Context ctx = new InitialContext(env);
>>>>>>
>>>>>>          /* An array to hold the Count beans */
>>>>>>          Count count[] = new Count[noOfClients];
>>>>>>          int countVal = 0;
>>>>>>
>>>>>>          /* Create and count() on each member of array */
>>>>>>          System.out.println("Instantiating beans...");
>>>>>>          for (int i = 0; i < noOfClients; i++) {
>>>>>>              count[i] = (Count) ctx.lookup("CountBeanRemote");
>>>>>>
>>>>>>              /* initialize each bean to the current count value */
>>>>>>              count[i].set(countVal);
>>>>>>
>>>>>>              /* Add 1 and print */
>>>>>>              countVal = count[i].count();
>>>>>>              System.out.println(countVal);
>>>>>>
>>>>>>              /*  Sleep for 1/2 second */
>>>>>>              Thread.sleep(100);
>>>>>>          }
>>>>>>
>>>>>>          /*
>>>>>>           * Let's call count() on each bean to  make sure the
>>>>>>           * beans were passivated and activated properly.
>>>>>>           */
>>>>>>          System.out.println("Calling count() on beans...");
>>>>>>          for (int i = 0; i < noOfClients; i++) {
>>>>>>
>>>>>>              /* Add 1 and print */
>>>>>>              countVal = count[i].count();
>>>>>>              System.out.println(countVal);
>>>>>>
>>>>>>              /* call remove to let the container dispose of the
>>>>>> bean */
>>>>>>              count[i].remove();
>>>>>>
>>>>>>              /*  Sleep for 1/2 second */
>>>>>>              Thread.sleep(50);
>>>>>>          }
>>>>>>      } catch (Exception e) {
>>>>>>          e.printStackTrace();
>>>>>>      }
>>>>>>  }
>>>>>> }
>>>>>> __________________________________________________________________
>>>>>>
>>>>>> The client creates three stateful session beans and the Geronimo
>>>>>> server is
>>>>>> also configured to have max 3 bean instances. I am presuming that,
>>>>>> server
>>>>>> need not passivate any bean instances as number of clients are
>>>>>> same as
>>>>>> number bean instances. However, when I run the client, I see the
>>>>>> following
>>>>>> exceptions on the client command window.
>>>>>>
>>>>>> ___________________________________________________________________
>>>>>> C:\>java examples.session.stateful.CountClient
>>>>>> Instantiating beans...
>>>>>> 1
>>>>>> 2
>>>>>> javax.naming.NamingException: Unknown error in container [Root
>>>>>> exception is
>>>>>> java.lang.reflect.UndeclaredThrowableExceptio
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .server
>>>>>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java: 
>>>>>> 125)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:
>>>>>> 168)
>>>>>>      at
>>>>>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java: 
>>>>>> 126)
>>>>>>      at
>>>>>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java: 
>>>>>> 84)
>>>>>>      at
>>>>>> org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java: 
>>>>>> 60)
>>>>>>      at
>>>>>> org 
>>>>>> .apache.openejb.server.ServiceLogger.service(ServiceLogger.java:
>>>>>> 76)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .server
>>>>>> .ServiceAccessController.service(ServiceAccessController.java:
>>>>>> 55)
>>>>>>      at
>>>>>> org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java:
>>>>>> 118)
>>>>>>      at java.lang.Thread.run(Thread.java:803)
>>>>>> Caused by: java.lang.reflect.UndeclaredThrowableException
>>>>>>      at $Proxy18.create(Unknown Source)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .core
>>>>>> .ivm
>>>>>> .naming
>>>>>> .BusinessRemoteReference.getObject(BusinessRemoteReference.java: 
>>>>>> 33)
>>>>>>      at
>>>>>> org
>>>>>> .apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:
>>>>>> 150)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:
>>>>>> 174)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .server
>>>>>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java: 
>>>>>> 119)
>>>>>>      ... 8 more
>>>>>> Caused by: java.rmi.RemoteException: Container has suffered a
>>>>>> SystemException; nested exception is:
>>>>>>      java.io.NotSerializableException:
>>>>>> examples.session.stateful.CountBean
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java: 
>>>>>> 243)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .util
>>>>>> .proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java: 
>>>>>> 49)
>>>>>>      ... 13 more
>>>>>> Caused by: java.io.NotSerializableException:
>>>>>> examples.session.stateful.CountBean
>>>>>>      at
>>>>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:
>>>>>> 1108)
>>>>>>      at
>>>>>> java
>>>>>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:
>>>>>> 1462)
>>>>>>      at
>>>>>> java 
>>>>>> .io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:
>>>>>> 1434)
>>>>>>      at
>>>>>> java
>>>>>> .io 
>>>>>> .ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:
>>>>>> 1377)
>>>>>>      at
>>>>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:
>>>>>> 1106)
>>>>>>      at
>>>>>> java
>>>>>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:
>>>>>> 1462)
>>>>>>      at
>>>>>> java 
>>>>>> .io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:
>>>>>> 1434)
>>>>>>      at
>>>>>> java
>>>>>> .io 
>>>>>> .ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:
>>>>>> 1377)
>>>>>>      at
>>>>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:
>>>>>> 1106)
>>>>>>      at
>>>>>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java: 
>>>>>> 324)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java: 
>>>>>> 73)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java: 
>>>>>> 93)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .core
>>>>>> .stateful
>>>>>> .StatefulInstanceManager.passivate(StatefulInstanceManager.java: 
>>>>>> 489)
>>>>>>      at
>>>>>> org.apache.openejb.core.stateful.StatefulInstanceManager
>>>>>> $BeanEntryQueue.add(StatefulInstanceManager.java:581)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .core
>>>>>> .stateful
>>>>>> .StatefulInstanceManager 
>>>>>> .poolInstance(StatefulInstanceManager.java:
>>>>>> 415)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .core
>>>>>> .stateful 
>>>>>> .StatefulContainer.createEJBObject(StatefulContainer.java:
>>>>>> 291)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .core.stateful.StatefulContainer.invoke(StatefulContainer.java: 
>>>>>> 241)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
>>>>>>      at
>>>>>> org
>>>>>> .apache
>>>>>> .openejb
>>>>>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java: 
>>>>>> 158)
>>>>>>      ... 15 more
>>>>>> ______________________________________________________________________________________
>>>>>>
>>>>>> Only when pool size is set to 4 does the client run successfully  
>>>>>> as
>>>>>> below
>>>>>>     <gbean name="DefaultStatefulContainer">
>>>>>>          <attribute name="properties">PoolSize 4
>>>>>>                              StrictPooling true</attribute>
>>>>>>      </gbean>
>>>>>>
>>>>>>
>>>>>> Can somebody suggest me what's happening?? We want restrict number
>>>>>> of
>>>>>> stateful bean instances and with the above observation, I guess,  
>>>>>> if
>>>>>> number
>>>>>> of clients become more than what's configured in Geronimo  
>>>>>> server, we
>>>>>> hit the
>>>>>> Serializable exception.
>>>>>>
>>>>>> Thanks in advance.
>>>>>>
>>>>>> Phani B Madgula
>>>>>> -- 
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16417509.html
>>>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> -- 
>>>> View this message in context:
>>>> http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16467194.html
>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16488945.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16557405.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Getting serializable exceptions while running stateful session bean.

Posted by David Blevins <da...@visi.com>.
I'm guessing examples.session.stateful.CountCallbacks is an  
interceptor.  If it is than definitely have it implement  
java.io.Serializable as well and the problem should go away (that was  
also fixed in the forthcoming release).

-David


On Apr 4, 2008, at 1:47 AM, phanibalaji wrote:
>
> Here is what being thrown on the command window of the EJB client
> _________________________________________________________
>
> Instantiating beans...
> 1
> 2
> javax.naming.NamingException: Unknown error in container [Root  
> exception is
> java.lang.reflect.UndeclaredThrowableException]
>        at
> org 
> .apache 
> .openejb 
> .server 
> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:125)
>        at
> org 
> .apache 
> .openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:168)
>        at
> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:126)
>        at
> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:84)
>        at
> org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:60)
>        at
> org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java:76)
>        at
> org 
> .apache 
> .openejb 
> .server.ServiceAccessController.service(ServiceAccessController.java: 
> 55)
>        at
> org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java:118)
>        at java.lang.Thread.run(Thread.java:803)
> Caused by: java.lang.reflect.UndeclaredThrowableException
>        at $Proxy18.create(Unknown Source)
>        at
> org 
> .apache 
> .openejb 
> .core 
> .ivm 
> .naming 
> .BusinessRemoteReference.getObject(BusinessRemoteReference.java:33)
>        at
> org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java: 
> 150)
>        at
> org 
> .apache 
> .openejb 
> .server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:174)
>        at
> org 
> .apache 
> .openejb 
> .server 
> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:119)
>        ... 8 more
> Caused by: java.rmi.RemoteException: Container has suffered a
> SystemException; nested exception is:
>        java.io.NotSerializableException:
> examples.session.stateful.CountCallbacks
>        at
> org 
> .apache 
> .openejb 
> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:243)
>        at
> org 
> .apache 
> .openejb 
> .core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
>        at
> org 
> .apache 
> .openejb 
> .util 
> .proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
>        ... 13 more
> Caused by: java.io.NotSerializableException:
> examples.session.stateful.CountCallbacks
>        at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1108)
>        at
> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
>        at java.util.HashMap.writeObject(HashMap.java:1040)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at
> sun 
> .reflect 
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
>        at
> sun 
> .reflect 
> .DelegatingMethodAccessorImpl 
> .invoke(DelegatingMethodAccessorImpl.java:43)
>        at java.lang.reflect.Method.invoke(Method.java:615)
>        at
> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java: 
> 972)
>        at
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
> 1426)
>        at
> java 
> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
> 1377)
>        at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
>        at
> java 
> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
> 1462)
>        at
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
> 1434)
>        at
> java 
> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
> 1377)
>        at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
>        at
> java 
> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
> 1462)
>        at
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
> 1434)
>        at
> java 
> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
> 1377)
>        at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
>        at
> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
>        at
> org 
> .apache 
> .openejb 
> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:73)
>        at
> org 
> .apache 
> .openejb 
> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:93)
>        at
> org 
> .apache 
> .openejb 
> .core 
> .stateful 
> .StatefulInstanceManager.passivate(StatefulInstanceManager.java:489)
>        at
> org.apache.openejb.core.stateful.StatefulInstanceManager 
> $BeanEntryQueue.add(StatefulInstanceManager.java:581)
>        at
> org 
> .apache 
> .openejb 
> .core 
> .stateful 
> .StatefulInstanceManager.poolInstance(StatefulInstanceManager.java: 
> 415)
>        at
> org 
> .apache 
> .openejb 
> .core 
> .stateful.StatefulContainer.createEJBObject(StatefulContainer.java: 
> 291)
>        at
> org 
> .apache 
> .openejb 
> .core.stateful.StatefulContainer.invoke(StatefulContainer.java:241)
>        at
> org 
> .apache 
> .openejb 
> .core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
>        at
> org 
> .apache 
> .openejb 
> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:158)
>        ... 15 more
>
> _________________________________________________________
>
> Here is what observed in the Geronimo log
> __________________________________________________________
>
> 14:13:11,132 INFO  [startup] Assembling app:
> C:\IBM\Geronimo-2.1\var\temp\geronimo-deployer7663.tmpdir\stateful.jar
> 14:13:11,162 INFO  [startup] Jndi(name=CountBeanRemote) -->
> Ejb(deployment-id=EmployeeDemo-stateful-ejb-dd/CountBean)
> 14:13:11,172 INFO  [startup] Created
> Ejb(deployment-id=EmployeeDemo-stateful-ejb-dd/CountBean,
> ejb-name=CountBean, container=Default Stateful Container)
> 14:13:11,172 INFO  [startup] Deployed
> Application(path=C:\IBM\Geronimo-2.1\var\temp\geronimo- 
> deployer7663.tmpdir\stateful.jar)
> 14:13:11,252 INFO  [DirectoryHotDeployer]     Deployed
> samples/EmployeeDemo-stateful-ejb-dd/2.1/jar
>
> 14:13:26,264 INFO  [OpenEJB] invoking method create on
> EmployeeDemo-stateful-ejb-dd/CountBean
> 14:13:26,354 INFO  [OpenEJB] finished invoking method create
> 14:13:27,035 INFO  [OpenEJB] The following method doesn't have a  
> transaction
> policy assigned: public abstract void
> examples.session.stateful.Count.set(int)
> 14:13:27,085 INFO  [Transaction] TX Required: Started transaction
> org.apache.geronimo.transaction.manager.TransactionImpl@62786278
> 14:13:27,095 INFO  [Transaction] TX Required: Committing transaction
> org.apache.geronimo.transaction.manager.TransactionImpl@62786278
> 14:13:27,105 INFO  [OpenEJB] The following method doesn't have a  
> transaction
> policy assigned: public abstract int  
> examples.session.stateful.Count.count()
> 14:13:27,105 INFO  [Transaction] TX Required: Started transaction
> org.apache.geronimo.transaction.manager.TransactionImpl@6a5e6a5e
> 14:13:27,105 INFO  [Transaction] TX Required: Committing transaction
> org.apache.geronimo.transaction.manager.TransactionImpl@6a5e6a5e
> 14:13:27,215 INFO  [OpenEJB] invoking method create on
> EmployeeDemo-stateful-ejb-dd/CountBean
> 14:13:27,215 INFO  [OpenEJB] finished invoking method create
> 14:13:27,225 INFO  [Transaction] TX Required: Started transaction
> org.apache.geronimo.transaction.manager.TransactionImpl@266c266c
> 14:13:27,225 INFO  [Transaction] TX Required: Committing transaction
> org.apache.geronimo.transaction.manager.TransactionImpl@266c266c
> 14:13:27,235 INFO  [Transaction] TX Required: Started transaction
> org.apache.geronimo.transaction.manager.TransactionImpl@45c445c4
> 14:13:27,235 INFO  [Transaction] TX Required: Committing transaction
> org.apache.geronimo.transaction.manager.TransactionImpl@45c445c4
> 14:13:27,345 INFO  [OpenEJB] invoking method create on
> EmployeeDemo-stateful-ejb-dd/CountBean
> 14:13:27,355 INFO  [OpenEJB] Passivating to file
> C:\IBM\Geronimo-2.1\var\temp 
> \f359d12e4a271795=40e71719=1191899ac1e=-7ff7
> 14:13:27,375 INFO  [OpenEJB] Passivation failed
> java.io.NotSerializableException:  
> examples.session.stateful.CountCallbacks
> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
> 1108)
> 	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java: 
> 324)
> 	at java.util.HashMap.writeObject(HashMap.java:1040)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun 
> .reflect 
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
> 	at
> sun 
> .reflect 
> .DelegatingMethodAccessorImpl 
> .invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:615)
> 	at  
> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java: 
> 972)
> 	at  
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
> 1426)
> 	at
> java 
> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
> 1377)
> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
> 1106)
> 	at
> java 
> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
> 1462)
> 	at  
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
> 1434)
> 	at
> java 
> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
> 1377)
> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
> 1106)
> 	at
> java 
> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
> 1462)
> 	at  
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
> 1434)
> 	at
> java 
> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
> 1377)
> 	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
> 1106)
> 	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java: 
> 324)
> 	at
> org 
> .apache 
> .openejb 
> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:73)
> 	at
> org 
> .apache 
> .openejb 
> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:93)
> 	at
> org 
> .apache 
> .openejb 
> .core 
> .stateful 
> .StatefulInstanceManager.passivate(StatefulInstanceManager.java:489)
> 	at
> org.apache.openejb.core.stateful.StatefulInstanceManager 
> $BeanEntryQueue.add(StatefulInstanceManager.java:581)
> 	at
> org 
> .apache 
> .openejb 
> .core 
> .stateful 
> .StatefulInstanceManager.poolInstance(StatefulInstanceManager.java: 
> 415)
> 	at
> org 
> .apache 
> .openejb 
> .core 
> .stateful.StatefulContainer.createEJBObject(StatefulContainer.java: 
> 291)
> 	at
> org 
> .apache 
> .openejb 
> .core.stateful.StatefulContainer.invoke(StatefulContainer.java:241)
> 	at
> org 
> .apache 
> .openejb 
> .core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
> 	at
> org 
> .apache 
> .openejb 
> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:158)
> 	at
> org 
> .apache 
> .openejb 
> .core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
> 	at
> org 
> .apache 
> .openejb 
> .util 
> .proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
> 	at $Proxy18.create(Unknown Source)
> 	at
> org 
> .apache 
> .openejb 
> .core 
> .ivm 
> .naming 
> .BusinessRemoteReference.getObject(BusinessRemoteReference.java:33)
> 	at
> org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java: 
> 150)
> 	at
> org 
> .apache 
> .openejb 
> .server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:174)
> 	at
> org 
> .apache 
> .openejb 
> .server 
> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:119)
> 	at
> org 
> .apache 
> .openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:168)
> 	at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java: 
> 126)
> 	at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java: 
> 84)
> 	at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java: 
> 60)
> 	at  
> org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java:76)
> 	at
> org 
> .apache 
> .openejb 
> .server.ServiceAccessController.service(ServiceAccessController.java: 
> 55)
> 	at org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java: 
> 118)
> 	at java.lang.Thread.run(Thread.java:803)
>
> __________________________________________________________
>
>
> David Blevins wrote:
>>
>> Hmm, that should definitely work.  Can you post the exact error?
>>
>> -David
>>
>> On Apr 3, 2008, at 12:32 AM, phanibalaji wrote:
>>>
>>> I tried this as well, but without success. Hitting the same error.
>>>
>>> Here is the CountBean.java
>>>
>>> _______________________________________________________________________
>>>
>>> package examples.session.stateful;
>>>
>>> import javax.ejb.*;
>>> import javax.interceptor.Interceptors;
>>>
>>>
>>>
>>> @Stateful
>>> @Remote(Count.class)
>>> @Interceptors(CountCallbacks.class)
>>> public class CountBean implements Count, java.io.Serializable {
>>> 	private static int numberofbeans = 0;
>>> 	
>>>   /** The current counter is our conversational state. */
>>>   private int val;
>>>
>>> 	 public CountBean(){ numberofbeans++;
>>> System.out.println("number_of_beans="+numberofbeans);}
>>>   /**
>>>    * The count() business method.
>>>    */
>>>   public int count() {
>>>       System.out.println("count()");
>>>       return ++val;
>>>   }
>>>
>>>   /**
>>>    * The set() business method.
>>>    */
>>>   public void set(int val) {
>>>       this.val = val;
>>>       System.out.println("set()");
>>>   }
>>>
>>>   /**
>>>    * The remove method is annotated so that the container knows
>>>    * it can remove the bean after this method returns.
>>>    */
>>>   @Remove
>>>   public void remove() {
>>>       System.out.println("remove()");
>>>   }
>>>
>>> }
>>>
>>> _______________________________________________________________________
>>>
>>> Thanks
>>> Phani B Madgula
>>>
>>>
>>>
>>> David Blevins wrote:
>>>>
>>>> This issue was fixed in the forthcoming OpenEJB 3.0 final, which  
>>>> will
>>>> be included in Geronimo 2.1.1.
>>>>
>>>> In the meantime you can have your stateful bean implement the
>>>> javax.io.Serializable interface and all should work fine.
>>>>
>>>> -David
>>>>
>>>> On Apr 1, 2008, at 3:11 AM, phanibalaji wrote:
>>>>>
>>>>> I am using Apache Geronimo2.1 and the OPENEJB container setting
>>>>> are as
>>>>> follows in config.xml (Pool size is 3).
>>>>>
>>>>> <module name="org.apache.geronimo.configs/openejb/2.1/car">
>>>>>      <gbean name="EJBNetworkService">
>>>>>          <attribute name="port">${OpenEJBPort + PortOffset}</
>>>>> attribute>
>>>>>          <attribute name="host">${ServerHostname}</attribute>
>>>>>      </gbean>
>>>>>      <gbean name="DefaultStatefulContainer">
>>>>>          <attribute name="properties">PoolSize 3
>>>>>                              StrictPooling true</attribute>
>>>>>      </gbean>
>>>>>  </module>
>>>>>
>>>>> I have the following bean class
>>>>>
>>>>> ___________________________________________________________
>>>>> package examples.session.stateful;
>>>>>
>>>>> import javax.ejb.*;
>>>>> import javax.interceptor.Interceptors;
>>>>>
>>>>>
>>>>>
>>>>> @Stateful
>>>>> @Remote(Count.class)
>>>>> @Interceptors(CountCallbacks.class)
>>>>> public class CountBean implements Count {
>>>>> 	private static int numberofbeans = 0;
>>>>> 	
>>>>>  /** The current counter is our conversational state. */
>>>>>  private int val;
>>>>>
>>>>> 	 public CountBean(){ numberofbeans++;
>>>>> System.out.println("number_of_beans="+numberofbeans);}
>>>>>  /**
>>>>>   * The count() business method.
>>>>>   */
>>>>>  public int count() {
>>>>>      System.out.println("count()");
>>>>>      return ++val;
>>>>>  }
>>>>>
>>>>>  /**
>>>>>   * The set() business method.
>>>>>   */
>>>>>  public void set(int val) {
>>>>>      this.val = val;
>>>>>      System.out.println("set()");
>>>>>  }
>>>>>
>>>>>  /**
>>>>>   * The remove method is annotated so that the container knows
>>>>>   * it can remove the bean after this method returns.
>>>>>   */
>>>>>  @Remove
>>>>>  public void remove() {
>>>>>      System.out.println("remove()");
>>>>>  }
>>>>>
>>>>> }
>>>>>
>>>>> ___________________________________________________________
>>>>>
>>>>>
>>>>> I have the following standalone EJB client
>>>>>
>>>>> ___________________________________________________________
>>>>>
>>>>> package examples.session.stateful;
>>>>>
>>>>> import javax.naming.*;
>>>>>
>>>>> /**
>>>>> * This class is a simple client for a stateful session bean.
>>>>> *
>>>>> * To illustrate how passivation works, configure your EJB server
>>>>> * to allow only 2 stateful session beans in memory. (Consult your
>>>>> * vendor documentation for details on how to do this.) We create
>>>>> * 3 beans in this example to see how and when beans are  
>>>>> passivated.
>>>>> */
>>>>> public class CountClient {
>>>>>
>>>>>  public static final int noOfClients = 3;
>>>>>
>>>>>  public static void main(String[] args) {
>>>>>      try {
>>>>>          /* Get a reference to the bean */
>>>>> 			java.util.Properties env = new java.util.Properties();
>>>>>
>>>>> 	
>>>>> env
>>>>> .put
>>>>> (Context
>>>>> .INITIAL_CONTEXT_FACTORY
>>>>> ,"org.apache.openejb.client.RemoteInitialContextFactory");
>>>>>   	env.put(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");
>>>>> 		
>>>>>          Context ctx = new InitialContext(env);
>>>>>
>>>>>          /* An array to hold the Count beans */
>>>>>          Count count[] = new Count[noOfClients];
>>>>>          int countVal = 0;
>>>>>
>>>>>          /* Create and count() on each member of array */
>>>>>          System.out.println("Instantiating beans...");
>>>>>          for (int i = 0; i < noOfClients; i++) {
>>>>>              count[i] = (Count) ctx.lookup("CountBeanRemote");
>>>>>
>>>>>              /* initialize each bean to the current count value */
>>>>>              count[i].set(countVal);
>>>>>
>>>>>              /* Add 1 and print */
>>>>>              countVal = count[i].count();
>>>>>              System.out.println(countVal);
>>>>>
>>>>>              /*  Sleep for 1/2 second */
>>>>>              Thread.sleep(100);
>>>>>          }
>>>>>
>>>>>          /*
>>>>>           * Let's call count() on each bean to  make sure the
>>>>>           * beans were passivated and activated properly.
>>>>>           */
>>>>>          System.out.println("Calling count() on beans...");
>>>>>          for (int i = 0; i < noOfClients; i++) {
>>>>>
>>>>>              /* Add 1 and print */
>>>>>              countVal = count[i].count();
>>>>>              System.out.println(countVal);
>>>>>
>>>>>              /* call remove to let the container dispose of the
>>>>> bean */
>>>>>              count[i].remove();
>>>>>
>>>>>              /*  Sleep for 1/2 second */
>>>>>              Thread.sleep(50);
>>>>>          }
>>>>>      } catch (Exception e) {
>>>>>          e.printStackTrace();
>>>>>      }
>>>>>  }
>>>>> }
>>>>> __________________________________________________________________
>>>>>
>>>>> The client creates three stateful session beans and the Geronimo
>>>>> server is
>>>>> also configured to have max 3 bean instances. I am presuming that,
>>>>> server
>>>>> need not passivate any bean instances as number of clients are
>>>>> same as
>>>>> number bean instances. However, when I run the client, I see the
>>>>> following
>>>>> exceptions on the client command window.
>>>>>
>>>>> ___________________________________________________________________
>>>>> C:\>java examples.session.stateful.CountClient
>>>>> Instantiating beans...
>>>>> 1
>>>>> 2
>>>>> javax.naming.NamingException: Unknown error in container [Root
>>>>> exception is
>>>>> java.lang.reflect.UndeclaredThrowableExceptio
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .server
>>>>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java: 
>>>>> 125)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:
>>>>> 168)
>>>>>      at
>>>>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java: 
>>>>> 126)
>>>>>      at
>>>>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java: 
>>>>> 84)
>>>>>      at
>>>>> org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java: 
>>>>> 60)
>>>>>      at
>>>>> org 
>>>>> .apache.openejb.server.ServiceLogger.service(ServiceLogger.java:
>>>>> 76)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .server
>>>>> .ServiceAccessController.service(ServiceAccessController.java:
>>>>> 55)
>>>>>      at
>>>>> org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java:
>>>>> 118)
>>>>>      at java.lang.Thread.run(Thread.java:803)
>>>>> Caused by: java.lang.reflect.UndeclaredThrowableException
>>>>>      at $Proxy18.create(Unknown Source)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .core
>>>>> .ivm
>>>>> .naming
>>>>> .BusinessRemoteReference.getObject(BusinessRemoteReference.java: 
>>>>> 33)
>>>>>      at
>>>>> org
>>>>> .apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:
>>>>> 150)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:
>>>>> 174)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .server
>>>>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java: 
>>>>> 119)
>>>>>      ... 8 more
>>>>> Caused by: java.rmi.RemoteException: Container has suffered a
>>>>> SystemException; nested exception is:
>>>>>      java.io.NotSerializableException:
>>>>> examples.session.stateful.CountBean
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java: 
>>>>> 243)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .util
>>>>> .proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java: 
>>>>> 49)
>>>>>      ... 13 more
>>>>> Caused by: java.io.NotSerializableException:
>>>>> examples.session.stateful.CountBean
>>>>>      at
>>>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:
>>>>> 1108)
>>>>>      at
>>>>> java
>>>>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:
>>>>> 1462)
>>>>>      at
>>>>> java 
>>>>> .io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:
>>>>> 1434)
>>>>>      at
>>>>> java
>>>>> .io 
>>>>> .ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:
>>>>> 1377)
>>>>>      at
>>>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:
>>>>> 1106)
>>>>>      at
>>>>> java
>>>>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:
>>>>> 1462)
>>>>>      at
>>>>> java 
>>>>> .io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:
>>>>> 1434)
>>>>>      at
>>>>> java
>>>>> .io 
>>>>> .ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:
>>>>> 1377)
>>>>>      at
>>>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:
>>>>> 1106)
>>>>>      at
>>>>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java: 
>>>>> 324)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java: 
>>>>> 73)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java: 
>>>>> 93)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .core
>>>>> .stateful
>>>>> .StatefulInstanceManager.passivate(StatefulInstanceManager.java: 
>>>>> 489)
>>>>>      at
>>>>> org.apache.openejb.core.stateful.StatefulInstanceManager
>>>>> $BeanEntryQueue.add(StatefulInstanceManager.java:581)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .core
>>>>> .stateful
>>>>> .StatefulInstanceManager 
>>>>> .poolInstance(StatefulInstanceManager.java:
>>>>> 415)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .core
>>>>> .stateful 
>>>>> .StatefulContainer.createEJBObject(StatefulContainer.java:
>>>>> 291)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .core.stateful.StatefulContainer.invoke(StatefulContainer.java: 
>>>>> 241)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
>>>>>      at
>>>>> org
>>>>> .apache
>>>>> .openejb
>>>>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java: 
>>>>> 158)
>>>>>      ... 15 more
>>>>> ______________________________________________________________________________________
>>>>>
>>>>> Only when pool size is set to 4 does the client run successfully  
>>>>> as
>>>>> below
>>>>>     <gbean name="DefaultStatefulContainer">
>>>>>          <attribute name="properties">PoolSize 4
>>>>>                              StrictPooling true</attribute>
>>>>>      </gbean>
>>>>>
>>>>>
>>>>> Can somebody suggest me what's happening?? We want restrict number
>>>>> of
>>>>> stateful bean instances and with the above observation, I guess,  
>>>>> if
>>>>> number
>>>>> of clients become more than what's configured in Geronimo  
>>>>> server, we
>>>>> hit the
>>>>> Serializable exception.
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> Phani B Madgula
>>>>> -- 
>>>>> View this message in context:
>>>>> http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16417509.html
>>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16467194.html
>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16488945.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>


Re: Getting serializable exceptions while running stateful session bean.

Posted by phanibalaji <ph...@gmail.com>.
Here is what being thrown on the command window of the EJB client
_________________________________________________________

Instantiating beans...
1
2
javax.naming.NamingException: Unknown error in container [Root exception is
java.lang.reflect.UndeclaredThrowableException]
        at
org.apache.openejb.server.ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:125)
        at
org.apache.openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:168)
        at
org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:126)
        at
org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:84)
        at
org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:60)
        at
org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java:76)
        at
org.apache.openejb.server.ServiceAccessController.service(ServiceAccessController.java:55)
        at
org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java:118)
        at java.lang.Thread.run(Thread.java:803)
Caused by: java.lang.reflect.UndeclaredThrowableException
        at $Proxy18.create(Unknown Source)
        at
org.apache.openejb.core.ivm.naming.BusinessRemoteReference.getObject(BusinessRemoteReference.java:33)
        at
org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:150)
        at
org.apache.openejb.server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:174)
        at
org.apache.openejb.server.ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:119)
        ... 8 more
Caused by: java.rmi.RemoteException: Container has suffered a
SystemException; nested exception is:
        java.io.NotSerializableException:
examples.session.stateful.CountCallbacks
        at
org.apache.openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:243)
        at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
        at
org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
        ... 13 more
Caused by: java.io.NotSerializableException:
examples.session.stateful.CountCallbacks
        at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1108)
        at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
        at java.util.HashMap.writeObject(HashMap.java:1040)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:615)
        at
java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:972)
        at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1426)
        at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1377)
        at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
        at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1462)
        at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1434)
        at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1377)
        at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
        at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1462)
        at
java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1434)
        at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1377)
        at
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
        at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
        at
org.apache.openejb.core.stateful.SimplePassivater.passivate(SimplePassivater.java:73)
        at
org.apache.openejb.core.stateful.SimplePassivater.passivate(SimplePassivater.java:93)
        at
org.apache.openejb.core.stateful.StatefulInstanceManager.passivate(StatefulInstanceManager.java:489)
        at
org.apache.openejb.core.stateful.StatefulInstanceManager$BeanEntryQueue.add(StatefulInstanceManager.java:581)
        at
org.apache.openejb.core.stateful.StatefulInstanceManager.poolInstance(StatefulInstanceManager.java:415)
        at
org.apache.openejb.core.stateful.StatefulContainer.createEJBObject(StatefulContainer.java:291)
        at
org.apache.openejb.core.stateful.StatefulContainer.invoke(StatefulContainer.java:241)
        at
org.apache.openejb.core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
        at
org.apache.openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:158)
        ... 15 more

_________________________________________________________

Here is what observed in the Geronimo log
__________________________________________________________

14:13:11,132 INFO  [startup] Assembling app:
C:\IBM\Geronimo-2.1\var\temp\geronimo-deployer7663.tmpdir\stateful.jar
14:13:11,162 INFO  [startup] Jndi(name=CountBeanRemote) -->
Ejb(deployment-id=EmployeeDemo-stateful-ejb-dd/CountBean)
14:13:11,172 INFO  [startup] Created
Ejb(deployment-id=EmployeeDemo-stateful-ejb-dd/CountBean,
ejb-name=CountBean, container=Default Stateful Container)
14:13:11,172 INFO  [startup] Deployed
Application(path=C:\IBM\Geronimo-2.1\var\temp\geronimo-deployer7663.tmpdir\stateful.jar)
14:13:11,252 INFO  [DirectoryHotDeployer]     Deployed
samples/EmployeeDemo-stateful-ejb-dd/2.1/jar

14:13:26,264 INFO  [OpenEJB] invoking method create on
EmployeeDemo-stateful-ejb-dd/CountBean
14:13:26,354 INFO  [OpenEJB] finished invoking method create
14:13:27,035 INFO  [OpenEJB] The following method doesn't have a transaction
policy assigned: public abstract void
examples.session.stateful.Count.set(int)
14:13:27,085 INFO  [Transaction] TX Required: Started transaction
org.apache.geronimo.transaction.manager.TransactionImpl@62786278
14:13:27,095 INFO  [Transaction] TX Required: Committing transaction
org.apache.geronimo.transaction.manager.TransactionImpl@62786278
14:13:27,105 INFO  [OpenEJB] The following method doesn't have a transaction
policy assigned: public abstract int examples.session.stateful.Count.count()
14:13:27,105 INFO  [Transaction] TX Required: Started transaction
org.apache.geronimo.transaction.manager.TransactionImpl@6a5e6a5e
14:13:27,105 INFO  [Transaction] TX Required: Committing transaction
org.apache.geronimo.transaction.manager.TransactionImpl@6a5e6a5e
14:13:27,215 INFO  [OpenEJB] invoking method create on
EmployeeDemo-stateful-ejb-dd/CountBean
14:13:27,215 INFO  [OpenEJB] finished invoking method create
14:13:27,225 INFO  [Transaction] TX Required: Started transaction
org.apache.geronimo.transaction.manager.TransactionImpl@266c266c
14:13:27,225 INFO  [Transaction] TX Required: Committing transaction
org.apache.geronimo.transaction.manager.TransactionImpl@266c266c
14:13:27,235 INFO  [Transaction] TX Required: Started transaction
org.apache.geronimo.transaction.manager.TransactionImpl@45c445c4
14:13:27,235 INFO  [Transaction] TX Required: Committing transaction
org.apache.geronimo.transaction.manager.TransactionImpl@45c445c4
14:13:27,345 INFO  [OpenEJB] invoking method create on
EmployeeDemo-stateful-ejb-dd/CountBean
14:13:27,355 INFO  [OpenEJB] Passivating to file
C:\IBM\Geronimo-2.1\var\temp\f359d12e4a271795=40e71719=1191899ac1e=-7ff7
14:13:27,375 INFO  [OpenEJB] Passivation failed 
java.io.NotSerializableException: examples.session.stateful.CountCallbacks
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1108)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
	at java.util.HashMap.writeObject(HashMap.java:1040)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:615)
	at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:972)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1426)
	at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1377)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
	at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1462)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1434)
	at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1377)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
	at
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1462)
	at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1434)
	at
java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1377)
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
	at
org.apache.openejb.core.stateful.SimplePassivater.passivate(SimplePassivater.java:73)
	at
org.apache.openejb.core.stateful.SimplePassivater.passivate(SimplePassivater.java:93)
	at
org.apache.openejb.core.stateful.StatefulInstanceManager.passivate(StatefulInstanceManager.java:489)
	at
org.apache.openejb.core.stateful.StatefulInstanceManager$BeanEntryQueue.add(StatefulInstanceManager.java:581)
	at
org.apache.openejb.core.stateful.StatefulInstanceManager.poolInstance(StatefulInstanceManager.java:415)
	at
org.apache.openejb.core.stateful.StatefulContainer.createEJBObject(StatefulContainer.java:291)
	at
org.apache.openejb.core.stateful.StatefulContainer.invoke(StatefulContainer.java:241)
	at
org.apache.openejb.core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
	at
org.apache.openejb.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:158)
	at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
	at
org.apache.openejb.util.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
	at $Proxy18.create(Unknown Source)
	at
org.apache.openejb.core.ivm.naming.BusinessRemoteReference.getObject(BusinessRemoteReference.java:33)
	at
org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:150)
	at
org.apache.openejb.server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:174)
	at
org.apache.openejb.server.ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:119)
	at
org.apache.openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:168)
	at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:126)
	at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:84)
	at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:60)
	at org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java:76)
	at
org.apache.openejb.server.ServiceAccessController.service(ServiceAccessController.java:55)
	at org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java:118)
	at java.lang.Thread.run(Thread.java:803)

__________________________________________________________


David Blevins wrote:
> 
> Hmm, that should definitely work.  Can you post the exact error?
> 
> -David
> 
> On Apr 3, 2008, at 12:32 AM, phanibalaji wrote:
>>
>> I tried this as well, but without success. Hitting the same error.
>>
>> Here is the CountBean.java
>>
>> _______________________________________________________________________
>>
>> package examples.session.stateful;
>>
>> import javax.ejb.*;
>> import javax.interceptor.Interceptors;
>>
>>
>>
>> @Stateful
>> @Remote(Count.class)
>> @Interceptors(CountCallbacks.class)
>> public class CountBean implements Count, java.io.Serializable {
>> 	private static int numberofbeans = 0;
>> 	
>>    /** The current counter is our conversational state. */
>>    private int val;
>>
>> 	 public CountBean(){ numberofbeans++;
>> System.out.println("number_of_beans="+numberofbeans);}
>>    /**
>>     * The count() business method.
>>     */
>>    public int count() {
>>        System.out.println("count()");
>>        return ++val;
>>    }
>>
>>    /**
>>     * The set() business method.
>>     */
>>    public void set(int val) {
>>        this.val = val;
>>        System.out.println("set()");
>>    }
>>
>>    /**
>>     * The remove method is annotated so that the container knows
>>     * it can remove the bean after this method returns.
>>     */
>>    @Remove
>>    public void remove() {
>>        System.out.println("remove()");
>>    }
>>
>> }
>>
>> _______________________________________________________________________
>>
>> Thanks
>> Phani B Madgula
>>
>>
>>
>> David Blevins wrote:
>>>
>>> This issue was fixed in the forthcoming OpenEJB 3.0 final, which will
>>> be included in Geronimo 2.1.1.
>>>
>>> In the meantime you can have your stateful bean implement the
>>> javax.io.Serializable interface and all should work fine.
>>>
>>> -David
>>>
>>> On Apr 1, 2008, at 3:11 AM, phanibalaji wrote:
>>>>
>>>> I am using Apache Geronimo2.1 and the OPENEJB container setting  
>>>> are as
>>>> follows in config.xml (Pool size is 3).
>>>>
>>>>  <module name="org.apache.geronimo.configs/openejb/2.1/car">
>>>>       <gbean name="EJBNetworkService">
>>>>           <attribute name="port">${OpenEJBPort + PortOffset}</
>>>> attribute>
>>>>           <attribute name="host">${ServerHostname}</attribute>
>>>>       </gbean>
>>>>       <gbean name="DefaultStatefulContainer">
>>>>           <attribute name="properties">PoolSize 3
>>>>                               StrictPooling true</attribute>
>>>>       </gbean>
>>>>   </module>
>>>>
>>>> I have the following bean class
>>>>
>>>> ___________________________________________________________
>>>> package examples.session.stateful;
>>>>
>>>> import javax.ejb.*;
>>>> import javax.interceptor.Interceptors;
>>>>
>>>>
>>>>
>>>> @Stateful
>>>> @Remote(Count.class)
>>>> @Interceptors(CountCallbacks.class)
>>>> public class CountBean implements Count {
>>>> 	private static int numberofbeans = 0;
>>>> 	
>>>>   /** The current counter is our conversational state. */
>>>>   private int val;
>>>>
>>>> 	 public CountBean(){ numberofbeans++;
>>>> System.out.println("number_of_beans="+numberofbeans);}
>>>>   /**
>>>>    * The count() business method.
>>>>    */
>>>>   public int count() {
>>>>       System.out.println("count()");
>>>>       return ++val;
>>>>   }
>>>>
>>>>   /**
>>>>    * The set() business method.
>>>>    */
>>>>   public void set(int val) {
>>>>       this.val = val;
>>>>       System.out.println("set()");
>>>>   }
>>>>
>>>>   /**
>>>>    * The remove method is annotated so that the container knows
>>>>    * it can remove the bean after this method returns.
>>>>    */
>>>>   @Remove
>>>>   public void remove() {
>>>>       System.out.println("remove()");
>>>>   }
>>>>
>>>> }
>>>>
>>>> ___________________________________________________________
>>>>
>>>>
>>>> I have the following standalone EJB client
>>>>
>>>> ___________________________________________________________
>>>>
>>>> package examples.session.stateful;
>>>>
>>>> import javax.naming.*;
>>>>
>>>> /**
>>>> * This class is a simple client for a stateful session bean.
>>>> *
>>>> * To illustrate how passivation works, configure your EJB server
>>>> * to allow only 2 stateful session beans in memory. (Consult your
>>>> * vendor documentation for details on how to do this.) We create
>>>> * 3 beans in this example to see how and when beans are passivated.
>>>> */
>>>> public class CountClient {
>>>>
>>>>   public static final int noOfClients = 3;
>>>>
>>>>   public static void main(String[] args) {
>>>>       try {
>>>>           /* Get a reference to the bean */
>>>> 			java.util.Properties env = new java.util.Properties();
>>>>
>>>> 	
>>>> env
>>>> .put
>>>> (Context
>>>> .INITIAL_CONTEXT_FACTORY
>>>> ,"org.apache.openejb.client.RemoteInitialContextFactory");
>>>>    	env.put(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");
>>>> 		
>>>>           Context ctx = new InitialContext(env);
>>>>
>>>>           /* An array to hold the Count beans */
>>>>           Count count[] = new Count[noOfClients];
>>>>           int countVal = 0;
>>>>
>>>>           /* Create and count() on each member of array */
>>>>           System.out.println("Instantiating beans...");
>>>>           for (int i = 0; i < noOfClients; i++) {
>>>>               count[i] = (Count) ctx.lookup("CountBeanRemote");
>>>>
>>>>               /* initialize each bean to the current count value */
>>>>               count[i].set(countVal);
>>>>
>>>>               /* Add 1 and print */
>>>>               countVal = count[i].count();
>>>>               System.out.println(countVal);
>>>>
>>>>               /*  Sleep for 1/2 second */
>>>>               Thread.sleep(100);
>>>>           }
>>>>
>>>>           /*
>>>>            * Let's call count() on each bean to  make sure the
>>>>            * beans were passivated and activated properly.
>>>>            */
>>>>           System.out.println("Calling count() on beans...");
>>>>           for (int i = 0; i < noOfClients; i++) {
>>>>
>>>>               /* Add 1 and print */
>>>>               countVal = count[i].count();
>>>>               System.out.println(countVal);
>>>>
>>>>               /* call remove to let the container dispose of the
>>>> bean */
>>>>               count[i].remove();
>>>>
>>>>               /*  Sleep for 1/2 second */
>>>>               Thread.sleep(50);
>>>>           }
>>>>       } catch (Exception e) {
>>>>           e.printStackTrace();
>>>>       }
>>>>   }
>>>> }
>>>> __________________________________________________________________
>>>>
>>>> The client creates three stateful session beans and the Geronimo
>>>> server is
>>>> also configured to have max 3 bean instances. I am presuming that,
>>>> server
>>>> need not passivate any bean instances as number of clients are  
>>>> same as
>>>> number bean instances. However, when I run the client, I see the
>>>> following
>>>> exceptions on the client command window.
>>>>
>>>> ___________________________________________________________________
>>>> C:\>java examples.session.stateful.CountClient
>>>> Instantiating beans...
>>>> 1
>>>> 2
>>>> javax.naming.NamingException: Unknown error in container [Root
>>>> exception is
>>>> java.lang.reflect.UndeclaredThrowableExceptio
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .server
>>>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:125)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java: 
>>>> 168)
>>>>       at
>>>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:126)
>>>>       at
>>>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:84)
>>>>       at
>>>> org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:60)
>>>>       at
>>>> org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java: 
>>>> 76)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .server 
>>>> .ServiceAccessController.service(ServiceAccessController.java:
>>>> 55)
>>>>       at
>>>> org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java: 
>>>> 118)
>>>>       at java.lang.Thread.run(Thread.java:803)
>>>> Caused by: java.lang.reflect.UndeclaredThrowableException
>>>>       at $Proxy18.create(Unknown Source)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .core
>>>> .ivm
>>>> .naming
>>>> .BusinessRemoteReference.getObject(BusinessRemoteReference.java:33)
>>>>       at
>>>> org 
>>>> .apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:
>>>> 150)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java: 
>>>> 174)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .server
>>>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:119)
>>>>       ... 8 more
>>>> Caused by: java.rmi.RemoteException: Container has suffered a
>>>> SystemException; nested exception is:
>>>>       java.io.NotSerializableException:
>>>> examples.session.stateful.CountBean
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:243)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .util
>>>> .proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
>>>>       ... 13 more
>>>> Caused by: java.io.NotSerializableException:
>>>> examples.session.stateful.CountBean
>>>>       at
>>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
>>>> 1108)
>>>>       at
>>>> java
>>>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:
>>>> 1462)
>>>>       at
>>>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:
>>>> 1434)
>>>>       at
>>>> java
>>>> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:
>>>> 1377)
>>>>       at
>>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
>>>> 1106)
>>>>       at
>>>> java
>>>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:
>>>> 1462)
>>>>       at
>>>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:
>>>> 1434)
>>>>       at
>>>> java
>>>> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:
>>>> 1377)
>>>>       at
>>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
>>>> 1106)
>>>>       at
>>>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:73)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:93)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .core
>>>> .stateful
>>>> .StatefulInstanceManager.passivate(StatefulInstanceManager.java:489)
>>>>       at
>>>> org.apache.openejb.core.stateful.StatefulInstanceManager
>>>> $BeanEntryQueue.add(StatefulInstanceManager.java:581)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .core
>>>> .stateful
>>>> .StatefulInstanceManager.poolInstance(StatefulInstanceManager.java:
>>>> 415)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .core
>>>> .stateful.StatefulContainer.createEJBObject(StatefulContainer.java:
>>>> 291)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .core.stateful.StatefulContainer.invoke(StatefulContainer.java:241)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
>>>>       at
>>>> org
>>>> .apache
>>>> .openejb
>>>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:158)
>>>>       ... 15 more
>>>> ______________________________________________________________________________________
>>>>
>>>> Only when pool size is set to 4 does the client run successfully as
>>>> below
>>>>      <gbean name="DefaultStatefulContainer">
>>>>           <attribute name="properties">PoolSize 4
>>>>                               StrictPooling true</attribute>
>>>>       </gbean>
>>>>
>>>>
>>>> Can somebody suggest me what's happening?? We want restrict number  
>>>> of
>>>> stateful bean instances and with the above observation, I guess, if
>>>> number
>>>> of clients become more than what's configured in Geronimo server, we
>>>> hit the
>>>> Serializable exception.
>>>>
>>>> Thanks in advance.
>>>>
>>>> Phani B Madgula
>>>> -- 
>>>> View this message in context:
>>>> http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16417509.html
>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>>
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16467194.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16488945.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Getting serializable exceptions while running stateful session bean.

Posted by David Blevins <da...@visi.com>.
Hmm, that should definitely work.  Can you post the exact error?

-David

On Apr 3, 2008, at 12:32 AM, phanibalaji wrote:
>
> I tried this as well, but without success. Hitting the same error.
>
> Here is the CountBean.java
>
> _______________________________________________________________________
>
> package examples.session.stateful;
>
> import javax.ejb.*;
> import javax.interceptor.Interceptors;
>
>
>
> @Stateful
> @Remote(Count.class)
> @Interceptors(CountCallbacks.class)
> public class CountBean implements Count, java.io.Serializable {
> 	private static int numberofbeans = 0;
> 	
>    /** The current counter is our conversational state. */
>    private int val;
>
> 	 public CountBean(){ numberofbeans++;
> System.out.println("number_of_beans="+numberofbeans);}
>    /**
>     * The count() business method.
>     */
>    public int count() {
>        System.out.println("count()");
>        return ++val;
>    }
>
>    /**
>     * The set() business method.
>     */
>    public void set(int val) {
>        this.val = val;
>        System.out.println("set()");
>    }
>
>    /**
>     * The remove method is annotated so that the container knows
>     * it can remove the bean after this method returns.
>     */
>    @Remove
>    public void remove() {
>        System.out.println("remove()");
>    }
>
> }
>
> _______________________________________________________________________
>
> Thanks
> Phani B Madgula
>
>
>
> David Blevins wrote:
>>
>> This issue was fixed in the forthcoming OpenEJB 3.0 final, which will
>> be included in Geronimo 2.1.1.
>>
>> In the meantime you can have your stateful bean implement the
>> javax.io.Serializable interface and all should work fine.
>>
>> -David
>>
>> On Apr 1, 2008, at 3:11 AM, phanibalaji wrote:
>>>
>>> I am using Apache Geronimo2.1 and the OPENEJB container setting  
>>> are as
>>> follows in config.xml (Pool size is 3).
>>>
>>>  <module name="org.apache.geronimo.configs/openejb/2.1/car">
>>>       <gbean name="EJBNetworkService">
>>>           <attribute name="port">${OpenEJBPort + PortOffset}</
>>> attribute>
>>>           <attribute name="host">${ServerHostname}</attribute>
>>>       </gbean>
>>>       <gbean name="DefaultStatefulContainer">
>>>           <attribute name="properties">PoolSize 3
>>>                               StrictPooling true</attribute>
>>>       </gbean>
>>>   </module>
>>>
>>> I have the following bean class
>>>
>>> ___________________________________________________________
>>> package examples.session.stateful;
>>>
>>> import javax.ejb.*;
>>> import javax.interceptor.Interceptors;
>>>
>>>
>>>
>>> @Stateful
>>> @Remote(Count.class)
>>> @Interceptors(CountCallbacks.class)
>>> public class CountBean implements Count {
>>> 	private static int numberofbeans = 0;
>>> 	
>>>   /** The current counter is our conversational state. */
>>>   private int val;
>>>
>>> 	 public CountBean(){ numberofbeans++;
>>> System.out.println("number_of_beans="+numberofbeans);}
>>>   /**
>>>    * The count() business method.
>>>    */
>>>   public int count() {
>>>       System.out.println("count()");
>>>       return ++val;
>>>   }
>>>
>>>   /**
>>>    * The set() business method.
>>>    */
>>>   public void set(int val) {
>>>       this.val = val;
>>>       System.out.println("set()");
>>>   }
>>>
>>>   /**
>>>    * The remove method is annotated so that the container knows
>>>    * it can remove the bean after this method returns.
>>>    */
>>>   @Remove
>>>   public void remove() {
>>>       System.out.println("remove()");
>>>   }
>>>
>>> }
>>>
>>> ___________________________________________________________
>>>
>>>
>>> I have the following standalone EJB client
>>>
>>> ___________________________________________________________
>>>
>>> package examples.session.stateful;
>>>
>>> import javax.naming.*;
>>>
>>> /**
>>> * This class is a simple client for a stateful session bean.
>>> *
>>> * To illustrate how passivation works, configure your EJB server
>>> * to allow only 2 stateful session beans in memory. (Consult your
>>> * vendor documentation for details on how to do this.) We create
>>> * 3 beans in this example to see how and when beans are passivated.
>>> */
>>> public class CountClient {
>>>
>>>   public static final int noOfClients = 3;
>>>
>>>   public static void main(String[] args) {
>>>       try {
>>>           /* Get a reference to the bean */
>>> 			java.util.Properties env = new java.util.Properties();
>>>
>>> 	
>>> env
>>> .put
>>> (Context
>>> .INITIAL_CONTEXT_FACTORY
>>> ,"org.apache.openejb.client.RemoteInitialContextFactory");
>>>    	env.put(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");
>>> 		
>>>           Context ctx = new InitialContext(env);
>>>
>>>           /* An array to hold the Count beans */
>>>           Count count[] = new Count[noOfClients];
>>>           int countVal = 0;
>>>
>>>           /* Create and count() on each member of array */
>>>           System.out.println("Instantiating beans...");
>>>           for (int i = 0; i < noOfClients; i++) {
>>>               count[i] = (Count) ctx.lookup("CountBeanRemote");
>>>
>>>               /* initialize each bean to the current count value */
>>>               count[i].set(countVal);
>>>
>>>               /* Add 1 and print */
>>>               countVal = count[i].count();
>>>               System.out.println(countVal);
>>>
>>>               /*  Sleep for 1/2 second */
>>>               Thread.sleep(100);
>>>           }
>>>
>>>           /*
>>>            * Let's call count() on each bean to  make sure the
>>>            * beans were passivated and activated properly.
>>>            */
>>>           System.out.println("Calling count() on beans...");
>>>           for (int i = 0; i < noOfClients; i++) {
>>>
>>>               /* Add 1 and print */
>>>               countVal = count[i].count();
>>>               System.out.println(countVal);
>>>
>>>               /* call remove to let the container dispose of the
>>> bean */
>>>               count[i].remove();
>>>
>>>               /*  Sleep for 1/2 second */
>>>               Thread.sleep(50);
>>>           }
>>>       } catch (Exception e) {
>>>           e.printStackTrace();
>>>       }
>>>   }
>>> }
>>> __________________________________________________________________
>>>
>>> The client creates three stateful session beans and the Geronimo
>>> server is
>>> also configured to have max 3 bean instances. I am presuming that,
>>> server
>>> need not passivate any bean instances as number of clients are  
>>> same as
>>> number bean instances. However, when I run the client, I see the
>>> following
>>> exceptions on the client command window.
>>>
>>> ___________________________________________________________________
>>> C:\>java examples.session.stateful.CountClient
>>> Instantiating beans...
>>> 1
>>> 2
>>> javax.naming.NamingException: Unknown error in container [Root
>>> exception is
>>> java.lang.reflect.UndeclaredThrowableExceptio
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .server
>>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:125)
>>>       at
>>> org
>>> .apache
>>> .openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java: 
>>> 168)
>>>       at
>>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:126)
>>>       at
>>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:84)
>>>       at
>>> org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:60)
>>>       at
>>> org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java: 
>>> 76)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .server 
>>> .ServiceAccessController.service(ServiceAccessController.java:
>>> 55)
>>>       at
>>> org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java: 
>>> 118)
>>>       at java.lang.Thread.run(Thread.java:803)
>>> Caused by: java.lang.reflect.UndeclaredThrowableException
>>>       at $Proxy18.create(Unknown Source)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .core
>>> .ivm
>>> .naming
>>> .BusinessRemoteReference.getObject(BusinessRemoteReference.java:33)
>>>       at
>>> org 
>>> .apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:
>>> 150)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java: 
>>> 174)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .server
>>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:119)
>>>       ... 8 more
>>> Caused by: java.rmi.RemoteException: Container has suffered a
>>> SystemException; nested exception is:
>>>       java.io.NotSerializableException:
>>> examples.session.stateful.CountBean
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:243)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .util
>>> .proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
>>>       ... 13 more
>>> Caused by: java.io.NotSerializableException:
>>> examples.session.stateful.CountBean
>>>       at
>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
>>> 1108)
>>>       at
>>> java
>>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:
>>> 1462)
>>>       at
>>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:
>>> 1434)
>>>       at
>>> java
>>> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:
>>> 1377)
>>>       at
>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
>>> 1106)
>>>       at
>>> java
>>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:
>>> 1462)
>>>       at
>>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:
>>> 1434)
>>>       at
>>> java
>>> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:
>>> 1377)
>>>       at
>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java: 
>>> 1106)
>>>       at
>>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:73)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:93)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .core
>>> .stateful
>>> .StatefulInstanceManager.passivate(StatefulInstanceManager.java:489)
>>>       at
>>> org.apache.openejb.core.stateful.StatefulInstanceManager
>>> $BeanEntryQueue.add(StatefulInstanceManager.java:581)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .core
>>> .stateful
>>> .StatefulInstanceManager.poolInstance(StatefulInstanceManager.java:
>>> 415)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .core
>>> .stateful.StatefulContainer.createEJBObject(StatefulContainer.java:
>>> 291)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .core.stateful.StatefulContainer.invoke(StatefulContainer.java:241)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
>>>       at
>>> org
>>> .apache
>>> .openejb
>>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:158)
>>>       ... 15 more
>>> ______________________________________________________________________________________
>>>
>>> Only when pool size is set to 4 does the client run successfully as
>>> below
>>>      <gbean name="DefaultStatefulContainer">
>>>           <attribute name="properties">PoolSize 4
>>>                               StrictPooling true</attribute>
>>>       </gbean>
>>>
>>>
>>> Can somebody suggest me what's happening?? We want restrict number  
>>> of
>>> stateful bean instances and with the above observation, I guess, if
>>> number
>>> of clients become more than what's configured in Geronimo server, we
>>> hit the
>>> Serializable exception.
>>>
>>> Thanks in advance.
>>>
>>> Phani B Madgula
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16417509.html
>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16467194.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>


Re: Getting serializable exceptions while running stateful session bean.

Posted by phanibalaji <ph...@gmail.com>.
I tried this as well, but without success. Hitting the same error.

Here is the CountBean.java 

_______________________________________________________________________

package examples.session.stateful;

import javax.ejb.*;
import javax.interceptor.Interceptors;



@Stateful
@Remote(Count.class)
@Interceptors(CountCallbacks.class)
public class CountBean implements Count, java.io.Serializable {
	private static int numberofbeans = 0;
	
    /** The current counter is our conversational state. */
    private int val;

	 public CountBean(){ numberofbeans++;
System.out.println("number_of_beans="+numberofbeans);}
    /**
     * The count() business method.
     */
    public int count() {
        System.out.println("count()");
        return ++val;
    }

    /**
     * The set() business method.
     */
    public void set(int val) {
        this.val = val;
        System.out.println("set()");
    }

    /**
     * The remove method is annotated so that the container knows
     * it can remove the bean after this method returns.
     */
    @Remove
    public void remove() {
        System.out.println("remove()");
    }

}

_______________________________________________________________________

Thanks
Phani B Madgula



David Blevins wrote:
> 
> This issue was fixed in the forthcoming OpenEJB 3.0 final, which will  
> be included in Geronimo 2.1.1.
> 
> In the meantime you can have your stateful bean implement the  
> javax.io.Serializable interface and all should work fine.
> 
> -David
> 
> On Apr 1, 2008, at 3:11 AM, phanibalaji wrote:
>>
>> I am using Apache Geronimo2.1 and the OPENEJB container setting are as
>> follows in config.xml (Pool size is 3).
>>
>>   <module name="org.apache.geronimo.configs/openejb/2.1/car">
>>        <gbean name="EJBNetworkService">
>>            <attribute name="port">${OpenEJBPort + PortOffset}</ 
>> attribute>
>>            <attribute name="host">${ServerHostname}</attribute>
>>        </gbean>
>>        <gbean name="DefaultStatefulContainer">
>>            <attribute name="properties">PoolSize 3
>>                                StrictPooling true</attribute>
>>        </gbean>
>>    </module>
>>
>> I have the following bean class
>>
>> ___________________________________________________________
>> package examples.session.stateful;
>>
>> import javax.ejb.*;
>> import javax.interceptor.Interceptors;
>>
>>
>>
>> @Stateful
>> @Remote(Count.class)
>> @Interceptors(CountCallbacks.class)
>> public class CountBean implements Count {
>> 	private static int numberofbeans = 0;
>> 	
>>    /** The current counter is our conversational state. */
>>    private int val;
>>
>> 	 public CountBean(){ numberofbeans++;
>> System.out.println("number_of_beans="+numberofbeans);}
>>    /**
>>     * The count() business method.
>>     */
>>    public int count() {
>>        System.out.println("count()");
>>        return ++val;
>>    }
>>
>>    /**
>>     * The set() business method.
>>     */
>>    public void set(int val) {
>>        this.val = val;
>>        System.out.println("set()");
>>    }
>>
>>    /**
>>     * The remove method is annotated so that the container knows
>>     * it can remove the bean after this method returns.
>>     */
>>    @Remove
>>    public void remove() {
>>        System.out.println("remove()");
>>    }
>>
>> }
>>
>> ___________________________________________________________
>>
>>
>> I have the following standalone EJB client
>>
>> ___________________________________________________________
>>
>> package examples.session.stateful;
>>
>> import javax.naming.*;
>>
>> /**
>> * This class is a simple client for a stateful session bean.
>> *
>> * To illustrate how passivation works, configure your EJB server
>> * to allow only 2 stateful session beans in memory. (Consult your
>> * vendor documentation for details on how to do this.) We create
>> * 3 beans in this example to see how and when beans are passivated.
>> */
>> public class CountClient {
>>
>>    public static final int noOfClients = 3;
>>
>>    public static void main(String[] args) {
>>        try {
>>            /* Get a reference to the bean */
>> 			java.util.Properties env = new java.util.Properties();
>>
>> 	
>> env 
>> .put 
>> (Context 
>> .INITIAL_CONTEXT_FACTORY 
>> ,"org.apache.openejb.client.RemoteInitialContextFactory");
>>     	env.put(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");
>> 		
>>            Context ctx = new InitialContext(env);
>>
>>            /* An array to hold the Count beans */
>>            Count count[] = new Count[noOfClients];
>>            int countVal = 0;
>>
>>            /* Create and count() on each member of array */
>>            System.out.println("Instantiating beans...");
>>            for (int i = 0; i < noOfClients; i++) {
>>                count[i] = (Count) ctx.lookup("CountBeanRemote");
>>
>>                /* initialize each bean to the current count value */
>>                count[i].set(countVal);
>>
>>                /* Add 1 and print */
>>                countVal = count[i].count();
>>                System.out.println(countVal);
>>
>>                /*  Sleep for 1/2 second */
>>                Thread.sleep(100);
>>            }
>>
>>            /*
>>             * Let's call count() on each bean to  make sure the
>>             * beans were passivated and activated properly.
>>             */
>>            System.out.println("Calling count() on beans...");
>>            for (int i = 0; i < noOfClients; i++) {
>>
>>                /* Add 1 and print */
>>                countVal = count[i].count();
>>                System.out.println(countVal);
>>
>>                /* call remove to let the container dispose of the  
>> bean */
>>                count[i].remove();
>>
>>                /*  Sleep for 1/2 second */
>>                Thread.sleep(50);
>>            }
>>        } catch (Exception e) {
>>            e.printStackTrace();
>>        }
>>    }
>> }
>> __________________________________________________________________
>>
>> The client creates three stateful session beans and the Geronimo  
>> server is
>> also configured to have max 3 bean instances. I am presuming that,  
>> server
>> need not passivate any bean instances as number of clients are same as
>> number bean instances. However, when I run the client, I see the  
>> following
>> exceptions on the client command window.
>>
>> ___________________________________________________________________
>> C:\>java examples.session.stateful.CountClient
>> Instantiating beans...
>> 1
>> 2
>> javax.naming.NamingException: Unknown error in container [Root  
>> exception is
>> java.lang.reflect.UndeclaredThrowableExceptio
>>        at
>> org 
>> .apache 
>> .openejb 
>> .server 
>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:125)
>>        at
>> org 
>> .apache 
>> .openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:168)
>>        at
>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:126)
>>        at
>> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:84)
>>        at
>> org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:60)
>>        at
>> org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java:76)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .server.ServiceAccessController.service(ServiceAccessController.java: 
>> 55)
>>        at
>> org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java:118)
>>        at java.lang.Thread.run(Thread.java:803)
>> Caused by: java.lang.reflect.UndeclaredThrowableException
>>        at $Proxy18.create(Unknown Source)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core 
>> .ivm 
>> .naming 
>> .BusinessRemoteReference.getObject(BusinessRemoteReference.java:33)
>>        at
>> org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java: 
>> 150)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:174)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .server 
>> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:119)
>>        ... 8 more
>> Caused by: java.rmi.RemoteException: Container has suffered a
>> SystemException; nested exception is:
>>        java.io.NotSerializableException:
>> examples.session.stateful.CountBean
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:243)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .util 
>> .proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
>>        ... 13 more
>> Caused by: java.io.NotSerializableException:
>> examples.session.stateful.CountBean
>>        at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1108)
>>        at
>> java 
>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
>> 1462)
>>        at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
>> 1434)
>>        at
>> java 
>> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
>> 1377)
>>        at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
>>        at
>> java 
>> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
>> 1462)
>>        at
>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
>> 1434)
>>        at
>> java 
>> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
>> 1377)
>>        at
>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
>>        at
>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:73)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:93)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core 
>> .stateful 
>> .StatefulInstanceManager.passivate(StatefulInstanceManager.java:489)
>>        at
>> org.apache.openejb.core.stateful.StatefulInstanceManager 
>> $BeanEntryQueue.add(StatefulInstanceManager.java:581)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core 
>> .stateful 
>> .StatefulInstanceManager.poolInstance(StatefulInstanceManager.java: 
>> 415)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core 
>> .stateful.StatefulContainer.createEJBObject(StatefulContainer.java: 
>> 291)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.stateful.StatefulContainer.invoke(StatefulContainer.java:241)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
>>        at
>> org 
>> .apache 
>> .openejb 
>> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:158)
>>        ... 15 more
>> ______________________________________________________________________________________
>>
>> Only when pool size is set to 4 does the client run successfully as  
>> below
>>       <gbean name="DefaultStatefulContainer">
>>            <attribute name="properties">PoolSize 4
>>                                StrictPooling true</attribute>
>>        </gbean>
>>
>>
>> Can somebody suggest me what's happening?? We want restrict number of
>> stateful bean instances and with the above observation, I guess, if  
>> number
>> of clients become more than what's configured in Geronimo server, we  
>> hit the
>> Serializable exception.
>>
>> Thanks in advance.
>>
>> Phani B Madgula
>> -- 
>> View this message in context:
>> http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16417509.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16467194.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Getting serializable exceptions while running stateful session bean.

Posted by David Blevins <da...@visi.com>.
This issue was fixed in the forthcoming OpenEJB 3.0 final, which will  
be included in Geronimo 2.1.1.

In the meantime you can have your stateful bean implement the  
javax.io.Serializable interface and all should work fine.

-David

On Apr 1, 2008, at 3:11 AM, phanibalaji wrote:
>
> I am using Apache Geronimo2.1 and the OPENEJB container setting are as
> follows in config.xml (Pool size is 3).
>
>   <module name="org.apache.geronimo.configs/openejb/2.1/car">
>        <gbean name="EJBNetworkService">
>            <attribute name="port">${OpenEJBPort + PortOffset}</ 
> attribute>
>            <attribute name="host">${ServerHostname}</attribute>
>        </gbean>
>        <gbean name="DefaultStatefulContainer">
>            <attribute name="properties">PoolSize 3
>                                StrictPooling true</attribute>
>        </gbean>
>    </module>
>
> I have the following bean class
>
> ___________________________________________________________
> package examples.session.stateful;
>
> import javax.ejb.*;
> import javax.interceptor.Interceptors;
>
>
>
> @Stateful
> @Remote(Count.class)
> @Interceptors(CountCallbacks.class)
> public class CountBean implements Count {
> 	private static int numberofbeans = 0;
> 	
>    /** The current counter is our conversational state. */
>    private int val;
>
> 	 public CountBean(){ numberofbeans++;
> System.out.println("number_of_beans="+numberofbeans);}
>    /**
>     * The count() business method.
>     */
>    public int count() {
>        System.out.println("count()");
>        return ++val;
>    }
>
>    /**
>     * The set() business method.
>     */
>    public void set(int val) {
>        this.val = val;
>        System.out.println("set()");
>    }
>
>    /**
>     * The remove method is annotated so that the container knows
>     * it can remove the bean after this method returns.
>     */
>    @Remove
>    public void remove() {
>        System.out.println("remove()");
>    }
>
> }
>
> ___________________________________________________________
>
>
> I have the following standalone EJB client
>
> ___________________________________________________________
>
> package examples.session.stateful;
>
> import javax.naming.*;
>
> /**
> * This class is a simple client for a stateful session bean.
> *
> * To illustrate how passivation works, configure your EJB server
> * to allow only 2 stateful session beans in memory. (Consult your
> * vendor documentation for details on how to do this.) We create
> * 3 beans in this example to see how and when beans are passivated.
> */
> public class CountClient {
>
>    public static final int noOfClients = 3;
>
>    public static void main(String[] args) {
>        try {
>            /* Get a reference to the bean */
> 			java.util.Properties env = new java.util.Properties();
>
> 	
> env 
> .put 
> (Context 
> .INITIAL_CONTEXT_FACTORY 
> ,"org.apache.openejb.client.RemoteInitialContextFactory");
>     	env.put(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");
> 		
>            Context ctx = new InitialContext(env);
>
>            /* An array to hold the Count beans */
>            Count count[] = new Count[noOfClients];
>            int countVal = 0;
>
>            /* Create and count() on each member of array */
>            System.out.println("Instantiating beans...");
>            for (int i = 0; i < noOfClients; i++) {
>                count[i] = (Count) ctx.lookup("CountBeanRemote");
>
>                /* initialize each bean to the current count value */
>                count[i].set(countVal);
>
>                /* Add 1 and print */
>                countVal = count[i].count();
>                System.out.println(countVal);
>
>                /*  Sleep for 1/2 second */
>                Thread.sleep(100);
>            }
>
>            /*
>             * Let's call count() on each bean to  make sure the
>             * beans were passivated and activated properly.
>             */
>            System.out.println("Calling count() on beans...");
>            for (int i = 0; i < noOfClients; i++) {
>
>                /* Add 1 and print */
>                countVal = count[i].count();
>                System.out.println(countVal);
>
>                /* call remove to let the container dispose of the  
> bean */
>                count[i].remove();
>
>                /*  Sleep for 1/2 second */
>                Thread.sleep(50);
>            }
>        } catch (Exception e) {
>            e.printStackTrace();
>        }
>    }
> }
> __________________________________________________________________
>
> The client creates three stateful session beans and the Geronimo  
> server is
> also configured to have max 3 bean instances. I am presuming that,  
> server
> need not passivate any bean instances as number of clients are same as
> number bean instances. However, when I run the client, I see the  
> following
> exceptions on the client command window.
>
> ___________________________________________________________________
> C:\>java examples.session.stateful.CountClient
> Instantiating beans...
> 1
> 2
> javax.naming.NamingException: Unknown error in container [Root  
> exception is
> java.lang.reflect.UndeclaredThrowableExceptio
>        at
> org 
> .apache 
> .openejb 
> .server 
> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:125)
>        at
> org 
> .apache 
> .openejb.server.ejbd.EjbDaemon.processJndiRequest(EjbDaemon.java:168)
>        at
> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:126)
>        at
> org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:84)
>        at
> org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:60)
>        at
> org.apache.openejb.server.ServiceLogger.service(ServiceLogger.java:76)
>        at
> org 
> .apache 
> .openejb 
> .server.ServiceAccessController.service(ServiceAccessController.java: 
> 55)
>        at
> org.apache.openejb.server.ServiceDaemon$1.run(ServiceDaemon.java:118)
>        at java.lang.Thread.run(Thread.java:803)
> Caused by: java.lang.reflect.UndeclaredThrowableException
>        at $Proxy18.create(Unknown Source)
>        at
> org 
> .apache 
> .openejb 
> .core 
> .ivm 
> .naming 
> .BusinessRemoteReference.getObject(BusinessRemoteReference.java:33)
>        at
> org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java: 
> 150)
>        at
> org 
> .apache 
> .openejb 
> .server.ejbd.JndiRequestHandler.doLookup(JndiRequestHandler.java:174)
>        at
> org 
> .apache 
> .openejb 
> .server 
> .ejbd.JndiRequestHandler.processRequest(JndiRequestHandler.java:119)
>        ... 8 more
> Caused by: java.rmi.RemoteException: Container has suffered a
> SystemException; nested exception is:
>        java.io.NotSerializableException:
> examples.session.stateful.CountBean
>        at
> org 
> .apache 
> .openejb 
> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:243)
>        at
> org 
> .apache 
> .openejb 
> .core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:245)
>        at
> org 
> .apache 
> .openejb 
> .util 
> .proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:49)
>        ... 13 more
> Caused by: java.io.NotSerializableException:
> examples.session.stateful.CountBean
>        at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1108)
>        at
> java 
> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
> 1462)
>        at
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
> 1434)
>        at
> java 
> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
> 1377)
>        at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
>        at
> java 
> .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java: 
> 1462)
>        at
> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java: 
> 1434)
>        at
> java 
> .io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java: 
> 1377)
>        at
> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1106)
>        at
> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:324)
>        at
> org 
> .apache 
> .openejb 
> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:73)
>        at
> org 
> .apache 
> .openejb 
> .core.stateful.SimplePassivater.passivate(SimplePassivater.java:93)
>        at
> org 
> .apache 
> .openejb 
> .core 
> .stateful 
> .StatefulInstanceManager.passivate(StatefulInstanceManager.java:489)
>        at
> org.apache.openejb.core.stateful.StatefulInstanceManager 
> $BeanEntryQueue.add(StatefulInstanceManager.java:581)
>        at
> org 
> .apache 
> .openejb 
> .core 
> .stateful 
> .StatefulInstanceManager.poolInstance(StatefulInstanceManager.java: 
> 415)
>        at
> org 
> .apache 
> .openejb 
> .core 
> .stateful.StatefulContainer.createEJBObject(StatefulContainer.java: 
> 291)
>        at
> org 
> .apache 
> .openejb 
> .core.stateful.StatefulContainer.invoke(StatefulContainer.java:241)
>        at
> org 
> .apache 
> .openejb 
> .core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:267)
>        at
> org 
> .apache 
> .openejb 
> .core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:158)
>        ... 15 more
> ______________________________________________________________________________________
>
> Only when pool size is set to 4 does the client run successfully as  
> below
>       <gbean name="DefaultStatefulContainer">
>            <attribute name="properties">PoolSize 4
>                                StrictPooling true</attribute>
>        </gbean>
>
>
> Can somebody suggest me what's happening?? We want restrict number of
> stateful bean instances and with the above observation, I guess, if  
> number
> of clients become more than what's configured in Geronimo server, we  
> hit the
> Serializable exception.
>
> Thanks in advance.
>
> Phani B Madgula
> -- 
> View this message in context: http://www.nabble.com/Getting-serializable-exceptions-while-running-stateful-session-bean.-tp16417509p16417509.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>