Annotation @EJB - NullPointerException lors de l'invocation
Bonjour,
Nouveau dans le monde des EJB 3.0 (ah, le bon vieux temps des EJB 2.1 et leurs tags XDOCLET), j'ai des difficultés à utiliser les annotations @EJB.
Au sein d'un même EAR, j'ai un JAR qui contient toutes les classes et un WAR qui contient les pages JSP.
J'ai déclaré une interface Local
Code:
1 2 3 4
| @Local
public interface TestService {
public String hello(String name);
} |
Puis, le bean en Stateless
Code:
1 2 3 4 5 6 7 8
|
@Stateless
public class TestServiceBean implements TestService {
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public String hello(String name) {
return "hello "+name;
}
} |
Coté Action Struts, une simple déclaration via l'annotation @EJB
Code:
1 2 3 4 5 6
| public class AccueilAction extends Action {
@EJB TestService testService ;
public ActionForward process(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
testService.hello("fedfil);
} |
Et là, j'obtiens un malheureux java.lang.NullPointerException.
Après quelques recherches, j'ai modifié mon fichier web.xml pour être bien en servlet 2.5.
Code:
1 2 3 4 5 6 7 8 9
| <?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
metadata-complete="false">
...
</web-app> |
Dernières précisions, je travaille sous weblogic 10.3.3.
Des idées ?
Merci !