persistence@glassfish.java.net

RE: war not see ejb jar...

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Wed, 1 Oct 2008 16:07:30 +0100

Martin,
 
I understand what you are saying. I am having the exact problem and have been research in google
and also following the JEE 5 tutorial.
 
I get a nullPointer exception as well.
 
I went to the following forum:
 
http://www.nabble.com/EJB-Injection-in-Managed-Bean-to18497939s134.html#a19733431
 
 and someone suggested
 
http://people.apache.org/builds/geronimo/server/binaries/trunk/latest/
 
Geronimo is another server to Glass fish or Sun application server. But it's compatible with
JEE applications apparently.
 
I am yet to learn how to install this and test my application if it works. I don't know
if you would like to take a look. The Glass fish team needs to explain this issue in detail and
document it so people can get help. And trust me you are not the only one.
 
With my problem though, the injection works within my servlets when retrieving data but
I get the null pointer when inserting data.
 
I really can't explain why.
 
eve



Date: Wed, 1 Oct 2008 10:08:26 -0400From: pm.renaud_at_gmail.comTo: ejb_at_glassfish.dev.java.netSubject: Re: war not see ejb jar...
Is my question not clear... or difficult?
On Tue, Sep 30, 2008 at 2:05 PM, Martin Renaud <pm.renaud_at_gmail.com> wrote:

Hi,i really don't understand what you mean. I've separated the client (.war) and ejbs (ejb .jar). Java EE seems to be very tricky...an example would be appreate. I joined a zip file which contain the exercice. This project have been created whit MyEclipse.You're going to find 3 directories: BeanProject which englobe the Web and the EJB. BeanProjectWeb include JSP/servlet/etc and BeanProjectEJB include ejb objects. Both are deployed to a Glassfish server. In debug mode, only directories are deployed (directory BeanProjectWeb.war and directory BeanProjectEJB.jar (these are not file)). I whish to not create a .ear file. Because eventually, other .war files are going to use that BeanProjectEJB.jar file.thank.Martin Renaud



On Tue, Sep 30, 2008 at 1:40 PM, Kenneth Saks <Kenneth.Saks_at_sun.com> wrote:

Hi Martin,

There are two typical ways this is done. The first is simply to repackage the interface within the .war. The second is to refactor the EJB client view classes and put them in a .jar file that is placed within a directory named "lib" at the top-level of the .ear. Any .jars in that directory are required to be visible to all modules in the .ear.






On Sep 30, 2008, at 1:34 PM, Martin Renaud wrote:

Hi Experts, I've created a bean project which use a JSP/Servlet client and EJB objects (sessionBean). Both are on the same server. From them, i've deployed on the server a war and a ejb-jar... but i'm having a problem. The war file seems unable to see the ejb-jar once deployed. In fact the only way to get ejb-jar visible from the war is to add it into the classpath of the war file. But i didn't see any example or tutorial who talk about adding the ejb-jar into the classpath of the war. I'm using annotation according to this example: https://glassfish.dev.java.net/javaee5/ejb/examples/Sful.html. I'm using MyEclipse 6.x and a Glassfish 2.x server. ClientSessionRemote.java



Code:

package com.imagem; import javax.ejb.Remote; @Remote public interface ClientSessionRemote { public java.lang.String SayHello(); } ClientSession.java



Code:

package com.imagem; import javax.ejb.Stateful; @Stateful public class ClientSession implements ClientSessionRemote { public String SayHello(){ String msg="Hello! I am Session Bean"; System.out.println(msg); return msg; } } Controller.java (servlet)



Code:

public class Controller extends HttpServlet { @EJB private ClientSessionRemote m_testClientSessionBean; ...some code... public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out; response.setContentType("text/html"); String title = "EJB Example"; out = response.getWriter(); out.println("<html>"); out.println("<head>"); out.println("<title>Hello World Servlet!</title>"); out.println("</head>"); out.println("<body>"); out.println("<p align=\"center\"><font size=\"4\" color=\"#000080\">Servlet Calling Session Bean</font></p>"); try{ //ClientSessionRemote client = (ClientSessionRemote) new InitialContext().lookup("java:comp/env/StatefulClientSession"); //ClientSessionRemote client = (ClientSessionRemote) new InitialContext().lookup(ClientSessionRemote.class.getName()); //out.println("<p align=\"center\"> Message from Session Bean is: <b>" + client.SayHello() + "</b></p>"); //System.out.println("Message = " + client.SayHello()); out.println("<p align=\"center\"> Message from Session Bean is: <b>" + m_testClientSessionBean.SayHello() + "</b></p>"); } catch(Exception CreateException){ CreateException.printStackTrace(); } out.println("<p align=\"center\"><a href=\"javascript:history.back()\">Go to Home</a></p>"); out.println("</body>"); out.println("</html>"); out.close(); } ...some code... } What else do i need to do?? any help would be appreciate!!! thks Martin Renaud-- Martin Renaud-- Martin Renaud
_________________________________________________________________
Make a mini you and download it into Windows Live Messenger
http://clk.atdmt.com/UKM/go/111354029/direct/01/