Seam @create doesn't end before other methods call the component

Good. I have a problem with SEAM (2.1.1.GA) that doesn't make any sense to me.

I have a component that is session bound and annotated with @AutoCreate.

The component has a create method annotated with @Create.

The problem is that before CREATING THE END METHOD, the seam calls another method on the same component instance. Since the create method did not complete this second method, it is throwing errors.

Is this the expected behavior? Of course, other calls to the component should block until creation is complete ?!

Does anyone know anything about this ... I'm kind of at my witty end. At the moment I'm just trying to solve the problem, but it seems like it shouldn't be an issue in the first place.

+2


source to share


2 answers


What is calling the second method?

If this is another Bean that is also auto-generated at startup, then enter your first Bean as a dependency.



@AutoCreate
@Startup(depends={"firstBean"})
@Name("secondBean")
public class SecondBean() {
...
}

      

+3


source


Old question, but since I stumbled upon this question today, it might be helpful to someone else.

This is what Component.newInstance () does:

instance = instantiate();

if (getScope()!=STATELESS) {
   //put it in the context _before_ calling postconstuct or create
   getScope().getContext().set(name, instance); 
}

postConstruct(instance);

if (getScope()!=STATELESS) {
   callCreateMethod(instance);

   if (Events.exists()) {
       Events.instance().raiseEvent("org.jboss.seam.postCreate." + name, instance);
   }
}

      

So, the sequence of events:



  • instantiate component
  • put your component in session scope
  • call method @Create

Step 2 means that other methods of the component can be called from other threads before the method completes @Create

.

So that's the problem. Call it a bug in Seam. In my case, I could work around this by using the constructor instead @Create

.

+2


source







All Articles