persistence@glassfish.java.net

Re: war not see ejb jar...

From: Ian Evans <Ian.Evans_at_Sun.COM>
Date: Wed, 01 Oct 2008 14:51:35 -0700

Eve Pokua wrote:
> 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.

It's not clear from your explanation what exact error you are
encountering. You appear to have a run-time error, which is unrelated to
the packaging discussion in this thread.

For Java EE 5 applications, the best way to package a web app and an EJB
JAR together is in an EAR. The EAR contains both a WAR and an EJB JAR.
This is how many of the EJB examples in the Java EE 5 Tutorial are
organized (see the converter example, for one).

You must also keep in mind that some web components support injection,
and others do not. Servlets do, JSP pages do not. In JSF applications,
injection is supported in JSF managed beans. See the Duke's Bank example
in the Tutorial for an application that uses EJB injection in JSF
managed beans.

Geronimo, like GlassFish, is another Java EE server, and it is extremely
unlikely that the source of your error is the server. All Java EE 5
compliant servers follow the injection rules above, so you're better off
reducing the number of variables in getting your application working and
sticking with one Java EE server for testing your application.

-ian
-- 
Ian Evans
ian dot evans at sun dot com
Java EE technical documentation