I'm reasonably new to JEE6 and EJBs, so this is probably a beginner error...
So I have a JEE6 application with entities (anotated POJOs, serializable), facades (@LocalBean SLSBs, implementing the persistence layer via JPA 2) and Stateless Session Beans (EJB3) with Remote interfaces (providing business logic and access to the entities via facades).
This is working fine. The Remote SLSB can retrieve/create and manipulate entities.
Now, I'm trying to do this from a Web Application (deployed on the same Glassfish V3, entity+interface definitions from JEE app imported as separate jar). I have a Servlet, that has an instance of the SLSB injected. I get it to retrieve an entity, and the following happens (I can see it in the logs):
- the remote SLSB gets instantiated, its method called
- SLSB instantiates the facade, calls the 'get' method
- facade retrieves instance of entity from DB, returns it
(all is good until here, entity properties are correctly populated)
- SLSB returns the instance of the entity to the caller
- calling servlet receives .. an empty instance of the entity !! All fields of the entity are at their default, it is as if it's a newly instantiated, "empty" object...
What is going wrong? This should work, right?
Thanks,
Hank
PS: Let me know if I should post more code...
MyServlet:
public class MyServlet extends HttpServlet {
@EJB
private CampaignControllerRemote campaignController; // remote SLSB
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/plain");
PrintWriter out = response.getWriter();
try {
Campaign c = campaignController.getCampaign(5L); // id of an existing campaign
out.println("Got "+ c.getSomeString()); // c exists, but c.getSomeString returns null !!
} finally {
out.close();
}
}
...
}
[Message sent by forum member 'hverbeek']
http://forums.java.net/jive/thread.jspa?messageID=398221