I've managed to get it working. The main problem was that the SLSB needed to be Remote because the code using it wasn't located in the same EAR-file.
The way i did it:
Jar containing only interfaces:
public interface SimpleStatelessBeanCommon {
public String getHello();
}
@Local
public interface SimpleStatelessBeanLocal extends SimpleStatelessBeanCommon{
}
@Remote
public interface SimpleStatelessBeanRemote extends SimpleStatelessBeanCommon{
}
War containing Bean implementation (with dependency to jar with interfaces)
@Stateless
public class SimpleStatelessSessionBean implements SimpleStatelessBeanLocal, SimpleStatelessBeanRemote {
public String getHello() {
return "Hello from stateless session bean";
}
}
War using the Bean (with dependency to jar with interfaces)
@WebServlet("/SimpleServlet")
public class SimpleServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@EJB
SimpleStatelessBeanRemote simpleStatelessSessionBean;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().println(simpleStatelessSessionBean.getHello());
}
}
I'll still take a look at what fvu posted.
Any optimization suggestions or remarks are still appreciated.