users@glassfish.java.net

Re: why does stateful ejb throw exception for calling super.finalize();

From: Steven Siebert <smsiebe_at_gmail.com>
Date: Fri, 25 Feb 2011 07:51:21 -0500

Gary,

What are you trying to accomplish? It's likely you can accomplish what you
are looking for by using the session beans lifecycle callbacks.

S

On Thu, Feb 24, 2011 at 10:47 PM, Marina Vatkina
<marina.vatkina_at_oracle.com>wrote:

> No, it's not ok to have finalaize method in the bean class.
>
> -marina
>
> emiddio-frontier wrote:
>
>> So does this mean its okay to have finalaize method but dont call
>> super.finalize(); ???
>>
>> I will try to find the spec section you mention.
>>
>> thanks
>>
>> gary
>>
>> ----- Original Message ----- From: "Marina Vatkina" <
>> marina.vatkina_at_oracle.com>
>> To: <users_at_glassfish.java.net>
>> Sent: Thursday, February 24, 2011 5:32 PM
>> Subject: Re: why does stateful ejb throw exception for calling
>> super.finalize();
>>
>>
>>
>> The EJB spec prohibits this method on a session bean - see section 4.9.2
>>> Session Bean Class
>>>
>>> -marina
>>>
>>> emiddio-frontier wrote:
>>>
>>>> why does stateful ejb throw exception for calling super.finalize();
>>>>
>>>> Thanks
>>>>
>>>> excerpt from log -- gfv301 and code snippet.
>>>>
>>>> gary
>>>>
>>>>
>>>> INFO: UserBean finalize:fCount:1
>>>> SEVERE: NRU-com.corejsf.UserBean: Cannot load from BACKUPSTORE FOR Key:
>>>> <190c02f00a81f-5a2427dc-0>
>>>> WARNING: A system exception occurred during an invocation on EJB
>>>> UserBean method public void com.corejsf.UserBean.finalize() throws
>>>> java.lang.Throwable
>>>> javax.ejb.NoSuchObjectLocalException: The EJB does not exist.
>>>> session-key: 190c02f00a81f-5a2427dc-0
>>>> at
>>>> com.sun.ejb.containers.StatefulSessionContainer._getContext(StatefulSessionContainer.java:1428)
>>>>
>>>> at
>>>> com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2467)
>>>> at
>>>> com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1860)
>>>> at
>>>> com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:188)
>>>>
>>>> at
>>>> com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:126)
>>>>
>>>> at $Proxy157.finalize(Unknown Source)
>>>> at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
>>>> at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
>>>> at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
>>>> at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
>>>>
>>>>
>>>>
>>>> @javax.inject.Named("user")
>>>> @javax.enterprise.context.RequestScoped
>>>> @javax.ejb.Stateful
>>>> public class UserBean {...
>>>>
>>>> @Override
>>>> public void finalize() throws Throwable {
>>>> fCount++;
>>>> System.out.println("UserBean finalize:fCount:" + fCount);
>>>> super.finalize();
>>>> }
>>>> ...
>>>>
>>>>
>>