[ 
https://issues.apache.org/jira/browse/OWB-534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12999991#comment-12999991
 ] 

Matthias Weßendorf commented on OWB-534:
----------------------------------------

Attached is a simple example. It uses my "abstractGenericDao"

unzip the file and run the following command "mvn".
This downloads jetty etc and starts the container on localhost:9090

afterwards point the browser to that URL and use the app to see the OWB bug.

Click the "all" link - or try to create a new employee ==> Both actions fail 
due to a NPE in the base DAO class.


================== WORK AROUND ============

Now to make it work.... you could change the EmployeeServiceImpl and replace 
this:

<toReplace>
  @Inject
  private EmployeeDao dao;
  //private SimpleEmployeeDao dao;
</toReplace>

with this:
<replacement>
  @Inject
  private SimpleEmployeeDao dao;
</replacement>


==> This makes it working, but it's not desired to use DAOs like that. 

The goal is to make the @PersistenceContext annotation working via abstract 
base classes as well (instead of only simple classes)

> Injection of @PersistenceContext does not work with abstract/base classes
> -------------------------------------------------------------------------
>
>                 Key: OWB-534
>                 URL: https://issues.apache.org/jira/browse/OWB-534
>             Project: OpenWebBeans
>          Issue Type: Bug
>          Components: Injection and Lookup
>    Affects Versions: 1.0.0
>            Reporter: Matthias Weßendorf
>            Assignee: Gurkan Erdogdu
>            Priority: Critical
>         Attachments: OWB-534.zip
>
>
> I am using an "AbstractGenericDao" class for all of my DAOs.
> In there I use @PersistenceContext(unitName = "myUnit") to inject the 
> EntityManager
> The concrete DAO (e.g. EmployeeDao (which extends AbstractGenericDao)) is 
> inject (via @Inject) to a Service IMPL.
> Now, when executing some logic on that DAO, where it delegates to the 
> EntityManager (e.g. em.persist(...);) I am getting a NullPointerException, 
> indicating that the EntityManager is NULL 

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to