[jboss-user] [EJB3] - EntityManager in a @Service

Andrea Polci do-not-reply at jboss.com
Mon Apr 18 03:57:45 EDT 2011


Andrea Polci [http://community.jboss.org/people/apolci] created the discussion

"EntityManager in a @Service"

To view the discussion, visit: http://community.jboss.org/message/600535#600535

--------------------------------------------------------------
I'm trying to write a @Service that need access to an EntityManager.
I'll use the service throw the JMX console.

The problem is that I can't find a way to inject the entity manager into the service.

This is a simplified version of my code:

public inteface MyManager {
   public void method(String argument);
}
 
@Service(objectName="xxxx:service=myservice")
public class MyMBean implements MyManager {
 
  @PersistenceContext(unitName="my-persistence-unit")
  private EntityManager em;
 
  public void method(String argument) {
    // code using em
  }
}



The service get exposed throgh the jmx console, but em is always null.

I tried to @Inject an entity manager configured in a @Producer, but i get the same result.

I'm using JBoss AS 6.0.0 Final

Thanks for any help,
Andrea
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/600535#600535]

Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110418/fe7d5410/attachment.html 


More information about the jboss-user mailing list