Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
22. Apr 2008, 15:43 CET | Link

I am having a problem when I persist my EntityHome derived component. The persist completes successfully, but I am crashing inside seam framework code which attempts to debug log the persist operation.

Here is my persist code:


    public String persist() {
    	TeamManager teamManager = new TeamManager(userHome.getInstance(), teamHome.getInstance());
    	
    	TeamManagerHome teamManagerHome = new TeamManagerHome();
    	teamManagerHome.setTeamManagerId(teamManager.hashCode());
    	teamManagerHome.setInstance(teamManager);
    	
    	String result = teamManagerHome.persist(); 
    	return result;     	
    }

The crash happens inside the Seam framework after the entitymanager persist and flush.

The framework calls createdMessage to log the persist:


   /**
    * Add a {@link javax.faces.application.FacesMessage} and log a message when
    * the entity instance is created.
    * 
    * Utility method to add a {@link javax.faces.application.FacesMessage} from
    * the Seam managed resource bundle or, if not specified in the resource 
    * bundle, from {@link #getUpdatedMessage()} and log the entity when the 
    * managed entity is updated.
    * 
    * @see #getCreatedMessage()
    * @see #getCreatedMessageKey()
    */
   protected void createdMessage()
   {
      debug("created entity #0 #1", getEntityClass().getName(), getId());
      getFacesMessages().addFromResourceBundleOrDefault( SEVERITY_INFO, getCreatedMessageKey(), getCreatedMessage() );
   }

The debug() call does the following:


   protected void debug(Object object, Object... params)
   {
      log.debug(object, params);
   }

And in the above, the log object is null.

I use EntityHome all over my application without problem - not sure what I am doing differently in this case that would cause this.

The persist is being originated by a Save button click.

Hoping someone can help.

Regards, Mark

1 Reply:
23. Apr 2008, 10:25 CET | Link

I had exactly the same issue while extending the EntityController class, with Seam 2.0.2.CR1

@Stateful
@Name("rateManager")
public class RateManager extends EntityController implements IRateManager

It seems that the logger is not injected into the component.

For the moment I just use this dirty workaround :

  @Override
  protected void info(Object object, Object... params)
  {
  	if (getLog() != null)	
  		super.info(object, params);
  	else
  		System.out.println(object);
  }
 
  @Override
  protected void debug(Object object, Object... params)
  {
  	if (getLog() != null)	
  		super.debug(object, params);
  	else
  		System.out.println(object);
  }