[jboss-user] [JBoss Seam] - Re: One Seam component calling another

breako do-not-reply at jboss.com
Mon Dec 31 10:55:13 EST 2007


"sdegardin" wrote : 
  | 1: use @In annotation. (recommended)  
  | 
Thanks for your suggestion. I used the @In annotation but the problem is that the second Seam component does not get it's Seam managed EntityManager set up correctly.

Basically, I have two Seam components both involved in the same transacation. Both Seam Components have Seam managed EntityManagers and because there are involved in the same transaction, the persistence context should be propagated and shared. 

First Seam Component:


  | @Name("manager")
  | @Scope(CONVERSATION)
  | public class ManagerPojo {
  | 
  |   @In
  |   private EntityManager em;
  | 
  |   @In (required=false, value="instancegenerator", create=true)  
  |   private InstanceGeneratorPOJO instanceGeneratorPOJO;
  | 
  |   @Begin(join=true, flushMode=FlushModeType.MANUAL)
  |   public void persist() {
  |         //...
  |         instanceGeneratorPOJO.getNextInstance("Person");
  |         //...
  |   }
  | 
  |   //...
  | }
  | 

Second Seam Component:

  | @Name("instancegenerator")
  | @Scope(CONVERSATION)
  | public class InstanceGeneratorPOJO { 
  |      @In 
  |      private EntityManager entityManager;  
  |       
  |      public Long getNextInstance(String type) {
  |          //... 
  |      }
  | 
  | }
  | 

When persist() is invoked I get:


  | 15:50:41,937 FATAL [application] org.jboss.seam.RequiredException: @In attribute requires non-null value: instancegenerator.entityManager
  | javax.faces.el.EvaluationException: org.jboss.seam.RequiredException: @In attribute requires non-null value: instancegenerator.entityManager
  | 

Note: If I remove the create=true in the first Seam component, i.e.


  |   @In (required=false, value="instancegenerator")  
  |   private InstanceGeneratorPOJO instanceGeneratorPOJO;
  | 

the instanceGenerator reference is null and I get a Null pointer exception in the persist() method

anybody got any ideas?



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116185#4116185

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116185



More information about the jboss-user mailing list