I tried to do this on Wildfly, but without success using the @EJB annotation, the JSP probably doesn't have a CDI. Therefore, I implemented it differently (not so brightly):
Before:
<% LoginAction loginAction; try { Properties properties = new Properties(); properties.put("jboss.naming.client.ejb.context", true); properties.put(Context.URL_PKG_PREFIXES,"org.jboss.ejb.client.naming"); Context ctx=new InitialContext(properties); loginAction = (LoginAction) ctx.lookup("java:module/LoginAction"); session.setAttribute("loginAction", loginAction); //this is to be able to use loginAction on EL Expressions! } catch (Exception e) { e.printStackTrace(); } %>
And everything else remains unchanged!
source share