Since you are getting NullPointerException, it probably means injection
manager didn't come to picture. Otherwise, you should have got a
NameNotFound kind of exception. Is there any such exception in
server.log? For injection to work, version in web.xml must be greater
than equal to 2.5. GlassFish v2 only supports version 2.5. Are you using
version=2.5 in your web.xml file? GlassFish document [1] suggests that
if your just specify @EJB, GlassFish will try to resolve an EJB with
global JNDI name as the name of the remote business interface name. If
your EJB has only one remote business interface name, then the EJB will
be bound with that name in JNDI and things would match, but if your EJB
has multiple remote business interfaces, matching can't take place. So,
I suggest, you browse the JNDI tree using admin console and see what
names are used by the EJB. If things still don't work, send us the code
that shows how you have defined/annotated your EJBs and how you are
injecting the EJB in your web app. In the worst case, I suggest you
specify a mappedName attribute while annotating the EJB and then use the
same in the web app. Something like this:
@Remote public interface Foo {}
@Stateless(mappedName="FOO")
public class FooBean implements Foo {
}
// In the JSF managed bean:
@EJB(mappedName="FOO") private Foo foo;
One more thing you can do is to see the generated ejb-jar.xml and
sun-ejb-jar.xml in
domains/domain1/applications/j2ee-modules/<your-ejb-jar-name>/META-INF/
directory and see how GlassFish generates equivalent XML DD from
annotations to get a better understanding of the technology.
Thanks,
Sahoo
[1]
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#EJB_ejb-ref_ejb_local_ref
glassfish_at_javadesktop.org wrote:
> Hello Sahoo,
>
> Sorry for taking this matter again.
>
> I defined several EJB 3 with remote interfaces.
> I also defined Web Services which access this EJB through the remote interfaces.
> Applications accesing webservices work fine.
>
> Now I need that my visual JSF Web application to access the EJB´s remote interfaces.
> I declared the EJB jar as a library.
> I added the library as a resource to my Web Application, so I do not have the class not found problem.
>
> Within a JSF page I declared the the @EJB to the remote interface.
> When I try to access any method on the declared EJB I get a nullPointer Exception.
>
> The glassFish documentation states that it resolves the dependencies automatically if only remote interfaces exists.
>
> I am lost. Please advise. Thank you.
>
> Antonio
> [Message sent by forum member 'antoniojsg' (antoniojsg)]
>
> http://forums.java.net/jive/thread.jspa?messageID=333486
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>