[jboss-user] [EJB 3.0 Users] - java:comp/env not found in @service POJO bean

steeven do-not-reply at jboss.com
Tue Oct 27 04:13:00 EDT 2009


I'm trying to use Service POJO bean ( jboss extension of EJB3), but I found that PersitentUnit was not found!

@Service(name = MyService.SERVICE_NAME)
  | @Management(IMyService.class)
  | //@PersistenceContext(name="em") not work too
  | public class MyService implements IMyService {
  | 	public final static String SERVICE_NAME = "MyService";
  | 	@PersistenceContext()
  | 	private EntityManager em;
  | 	public void create() throws Exception {
  | 		log.info("Ems created");
  | 	}
  | 
  | 	@TransactionAttribute(TransactionAttributeType.REQUIRED)
  | 	public void start() throws Exception {
  | 		log.info("Ems started");
  | 		//em.xxx this line worked
  | 		new InitialContext().lookup("java:comp/env/em") not work.
  | 	}
  | }

ExceptioN:
javax.naming.NameNotFoundException: env not bound

I'm retrieving EnityManager from some util class, that nest called in other class, it will be great trouble to pass em inside.

Why no Enc in service POJO? any work around?

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

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



More information about the jboss-user mailing list