tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <>
Subject Re: @Singleton @PostActivate
Date Fri, 28 May 2010 22:01:09 GMT
Hi Marius,

On May 20, 2010, at 5:19 AM, Marius Kruger wrote:

> I first tried to use @PostConstruct, but that requires you to specify
> all dependent ejbs with @DependsOn,
> but I don't know at compile time which ejbs I need to depend on.

If it helps, you really only need @DependsOn if both of these conditions are true:

  1.  The other bean is an @Singleton as well.
  2.  It is actually invoked in @PostConstruct or before (i.e. a setter)

If that isn't the case then you don't need @DependsOn. If both of those are true and you don't
use @DependsOn, there's no guarantee that the bean you wish to use has actually been created

It's fine to play it risky, but be careful of circular dependencies as those will result in
a deadlock.  Basically @DependsOn allows us to order startup of Singleton beans in your jar
and detect circular dependencies.

> Then I tried to get my @PostConstruct method to call a @Asynchronous
> method with the hopes that
> it will only be called after the ejb container started up completely
> (and I can access any ejbs I want).
> @Asynchronous in openejb does not seem to do what I want at the moment.
> (
> )

We do have some @Asynchronous code working in trunk.  It doesn't yet support the xml versions
of the annotations, etc., but the core logic is there.  I can push a snapshot of that if you

> Then I tried to use @PostActivate in my @Singleton but it gives the
> exception below.

With that you should have gotten a warning like this:

WARN - WARN ... TestStateless:	@PostActivate is ignored for beans of type Stateless. Method:

There was a bug that prevent that from showing up.  I've gone ahead and fixed it and filed
this JIRA:

The most verbose version of that message (openejb.validation.output.level=VERBOSE) looks like

WARN - WARN ... TestStateless:	Beans of type Stateless are not allowed to use the @PostActivate
annotation.  This annotation is only permitted on Stateful SessionBeans.  The usage of @PostActivate
on bean method myActivate will be ignored and the annotation should be removed.

Basically, Passivation/Activation is a stateful bean concept that pertains to serializing
and deserializing a bean to disk in efforts to free up memory or move it in a cluster.

Hope this helps and thanks for reporting it!


View raw message