-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: @PersistenceUnit not working
PostPosted: Wed Sep 21, 2011 10:11 am 
Newbie

Joined: Fri Aug 19, 2011 5:28 pm
Posts: 4
I want to use the @PersistenceUnit annotation in my app to create an application managed EntityManager



Code:
    @PersistenceUnit(unitName="primary")




    private static EntityManagerFactory entityManagerFactory;       
    EntityManager entityManager = entityManagerFactory.createEntityManager();





This doesn't seem to be working. I run my code through a debugger and discover that entityManagerFactory is null. My guess is that the injection of Persistence context with the @PersistenceUnit annotation is not working.








My app is a CDI app - - I converted it to CDI by creating a beans.xml file in WEB-INF. I'm using JBoss 7. This is a basic struts hibernate project deployed by Maven. I'm only adding CDI so that I can inject the PersistenceUnit at this point in the code.

Is there anything I need to configure within CDI to get the annotation to work? Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.