I have a EAP created with Eclipse containing two modules: a Dynamic Web Application, and a EJB module.
The application.xml of the EAP:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" id="Application_ID" version="7">
<display-name>JExecuterEAP</display-name>
<module>
<ejb>JExecuterEJB.jar</ejb>
</module>
<module>
<web>
<web-uri>JExecuter.war</web-uri>
<context-root>JExecuter</context-root>
</web>
</module>
</application>
The EJB module:
package myp;
import javax.ejb.Stateless;
@Stateless
public class ExecutionEngineBean implements IExecutionEngine {
public ExecutionEngineBean() {
}
@Override
public void test() {
System.out.println("Test EJB");
}
}
package myp;
import javax.ejb.Remote;
@Remote
public interface IExecutionEngine {
public void test();
}
The Web Application:
import myp.IExecutionEngine;
@ServerEndpoint(value = "/executerendpoint")
public class ExecuterEndpoint {
@EJB
IExecutionEngine bean;
private static final Logger logger = Logger.getLogger("ExecuterEndpoint");
@OnOpen
public void openConnection(Session sesion) {
logger.log(Level.INFO, "open conection");
//Here the EJB is NULL
}
@OnMessage
public void onMessage(Session session, String msg) {
}
}
I'm doing the deployment in GlassFish 4.1.