During deploying of my ear I get the following error:
java.lang.RuntimeException: <injection-target> could not be found: com.javawebwizard.common.persistence.dao.jpa.BaseDAO.persistentUnitJndi
which really confuses me. I don't know what to check Any help would be highly appreaciated. Please see the code below:
My JSF managed bean:
public class MagazinBackingBean {
@EJB
MagazinFacade facade;
...
The EJB:
@Stateless
@PersistenceContext(name = BaseDAO.PERSISTENT_UNIT_JNDI_NAME, unitName="magazinPU")
public class MagazinFacadeBean implements MagazinFacade {
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void inregistreazaMagazin(String cif) throws JWWException {
MagazinPO magazin = new MagazinPO();
magazin.setCif(cif);
MagazinDAO dao = new MagazinDAO();
dao.insert(magazin); }
}
The application.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<description>Magazin</description>
<display-name>Magazin</display-name>
<module>
<ejb>Magazin-ejb.jar</ejb>
</module>
<module>
<web>
<web-uri>Magazin-war.war</web-uri>
<context-root>Magazin</context-root>
</web>
</module>
<module>
<java>common.jar</java>> <- BaseDao is in here!
</module>
</application>
Thanks,
Felix
Use www.jaaava.com - A Google CSE for Java
Felix Sima
Ranch Hand
Joined: Feb 06, 2008
Posts: 40
posted
0
Hi.
I think I have understood the problem. I create the DAO using the "new" operator, in a method of the ejb.
At this point the DI has been already performed.
I must put
as a field of the ejb, not in my DAO.
Best regards,
Felix
Use www.jaaava.com - A Google CSE for Java
Felix Sima
Ranch Hand
Joined: Feb 06, 2008
Posts: 40
posted
0
Hi.
I still have the error. The solution described in the last post, did not solve my problem
Best regards,
Felix
Satya Maheshwari
Ranch Hand
Joined: Jan 01, 2007
Posts: 368
posted
0
@Felix Sima
As you have already identified, dependency injection will work only in managed classes and 'MagazinDAO' is'nt a managed class. As for the error still coming, could you post the persistence.xml you used to configure the datasource.
Thanks and Regards
Felix Sima
Ranch Hand
Joined: Feb 06, 2008
Posts: 40
posted
0
Hello.
Now it finally works
From my tests it seems that the <injection-target> could not be found ... error is launched when
annotation is used outside of a managed component.
I also had an error in my persistence.xml. I used "jdbc/someDS" instead of "java:/someDS". I'm using JBoss 5.0.0.GA application server.
Thank you.
Best regards,
Felix
Use www.jaaava.com - A Google CSE for Java
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.