[jboss-dev-forums] [Design of POJO Server] - Re: NPE in TransactionScopedEntityManager

alesj do-not-reply at jboss.com
Thu Nov 6 05:17:24 EST 2008


I know what is the issue. ;-)

It's this change:
 - https://jira.jboss.org/jira/browse/JBDEPLOY-118

The problem there is that you're by-passing BMDFVisitor
that adds CLASS level scope to DUs Scope:

  |    protected DeploymentUnit addComponent(DeploymentUnit unit, BeanMetaData attachment)
  |    {
  |       DeploymentUnit component = super.addComponent(unit, attachment);
  |       String className = attachment.getBean();
  |       if (className != null)
  |       {
  |          Object qualifier;
  |          if (attachment.getClassLoader() == null)
  |          {
  |             ClassLoader cl = unit.getClassLoader();
  |             try
  |             {
  |                qualifier = cl.loadClass(className);
  |             }
  |             catch (Exception e)
  |             {
  |                throw new IllegalArgumentException("Exception loading class for ScopeKey addition.", e);              
  |             }
  |          }
  |          else
  |          {
  |             qualifier = className;
  |          }
  |          component.getScope().addScope(CommonLevels.CLASS, qualifier);
  |       }
  | 
  |       return component;
  |    }
  | 

So, the solution is that you stop hacking around components. ;-)
Component deployer shouldn't create new attachments, else similar issues can pop up.

Perhaps do this:

  |          DeploymentUnit parent = unit.getParent();
  |          if (parent == null)
  |             throw new IllegalArgumentException("Should not be null as this unit should be component.");
  |          
  |          parent.addAttachment(BeanMetaData.class.getName() + "." + name, builder.getBeanMetaData(), BeanMetaData.class);
  | 

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

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



More information about the jboss-dev-forums mailing list