I'm trying to inject an EJB to a servlet using JBoss7 and its not working. The code works fine on JBoss 6 I package the EJB code out of the WAR, and the interfaces with the WAR but I don't get injection in the SERVLETS(GWT Servlets).
My code looks like
Interface:
@Local
public interface MyService{
}
Implementation:
@Stateless(name = "MyService")
@TransactionManagement(TransactionManagementType.CONTAINER)
public class MyServiceImpl implements MyService {
}
Servlet
@EJB(name = "MyService")
private MyService service;
The same implementation was working fine in JBoss AS 6. I ran out of ideas. Please help.
If your EJB is only a local one, you can put every thing in the war.
If there is only one implementation of the interface you can remove the name of the EJB, the container will resolve the EJB injection base on the type. (You can remove the the interface all together with EJB 3.1).
If you need more, you should provide the archive (EAR or WAR) structure and some log entry (EJB list + error when making the injection).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With