Skip to main content

ejb3 Timer Serializable

4 replies [Last post]
shyamals
Offline
Joined: 2009-06-09

In my Stateless bean, I have a method marked with @Timeout where I perform activities based on the timer expired.

@Timeout
public void onExpiration(Timer timer)
{
}

I see this in the logs and want to know if there is any way to avoid it.

thanks
shyamala.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
shyamals
Offline
Joined: 2009-06-09

Mark

Thanks for the response. Yes, that worked. I just removed the onExpiration method with the @Timeout annotation from the interface. For some reason I had assumed that if it needs to be callable on the bean, then it will also need to be present in the interface. Thanks again.

shyamals
Offline
Joined: 2009-06-09

Martin,
thanks for the response. however I still have not got the answer I am looking for, You have explained in detail about the pass by reference part. I am using Weblogic 10.3. My main focus of the question is about the Timer parameter of the method. Since it has been annotated with @Timeout, it expects a Timer parameter but at the same time, the Timer object is not serializable. This seems like an anomaly in the timer framework and the usage of it. I searched the web, for other users having this issue, but didnt find any. So there must be something I am missing.

thanks again
shyamala.

ksak
Offline
Joined: 2005-05-20

Why is the timeout method even exposed through the remote interface? The timeout method is a callback from the container to the bean instance. It plays no role from the perspective of a session bean client so it shouldn't be on an interface.

The EJB spec actually prohibits the passing of timers through the remote tier. As for the Timer object itself, it is a special container-provided object that is not guaranteed to be directly serializable. It can be converted to a serializable TimerHandle via Timer.getTimerHandle().

Martin Gainty

please read this tutorial of pass-by-reference
http://docs.sun.com/app/docs/doc/820-4337/beavo?l=en&a=view
pass-by-reference

Specifies the passing method used by a servlet or enterprise
bean calling a remote interface method in another bean that is colocated
within the same process.

If false (the default if this element
is not present), this application uses pass-by-value semantics.

If true, this application uses
pass-by-reference semantics.

Note –
The pass-by-reference element only
applies to remote calls. As defined in the EJB 2.1 specification,
section 5.4, calls to local interfaces use pass-by-reference semantics.

If the pass-by-reference element is set to
its default value of false, the passing semantics
for calls to remote interfaces comply with the EJB 2.1 specification,
section 5.4. If set to true, remote calls involve
pass-by-reference semantics instead of pass-by-value semantics, contrary
to this specification.

Portable programs cannot assume
that a copy of the object is made during such a call, and thus that
it’s safe to modify the original. Nor can they assume that a
copy is not made, and thus that changes to the object are visible
to both caller and callee. When this element is set to true,
parameters and return values should be considered read-only. The behavior
of a program that modifies such parameters or return values is undefined.

When a servlet or enterprise bean calls a remote interface method
in another bean that is colocated within the same process, by default
the Enterprise Server makes copies of all the call parameters in order
to preserve the pass-by-value semantics. This increases the call overhead
and decreases performance.

However, if the calling method does not change the object being
passed as a parameter, it is safe to pass the object itself without
making a copy of it. To do this, set the pass-by-reference value to true.

The setting of this element in the sun-application.xml file
applies to all EJB modules in the application. For an individually
deployed EJB module, you can set the same element in the sun-ejb-jar.xml file. If pass-by-reference is used at
both the bean and application level, the bean level takes precedence.

> To: users@glassfish.dev.java.net
> Subject: ejb3 Timer Serializable
>
> In my Stateless bean, I have a method marked with @Timeout where I perform activities based on the timer expired.
>
> @Timeout
> public void onExpiration(Timer timer)
> {
> }
>
> I see this in the logs and want to know if there is any way to avoid it.
>
>
>
> thanks
> shyamala.
> [Message sent by forum member 'shyamals' (shyamals)]
>
> http://forums.java.net/jive/thread.jspa?messageID=359455
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

_________________________________________________________________
Get free photo software from Windows Live
http://www.windowslive.com/online/photos?ocid=PID23393::T:WLMTAGL:ON:WL:...
[att1.html]