Accessing SLSB w / local interface from WEB APP

Hi,

I have trouble referencing the SLSB with @Local interface from Web app.

I have an .ear consisting of .war with web module and .jar with EJB module. The .ear is deployed into Sun Application Server (Java Application Platform SDK Update 2).

I'd like to use the @Local interface on my SLSB because no remote access is needed - both modules reside in the same .ear and get deployed in the same AS.

Inside my web app I tried to use @EJB annotation to reference the Bean, but without success (I get null pointer exceptions). I'd rather not use the JNDI or Service Locator Pattern, so how to make the dependency injection work? Have someone seen a working code on this? All the examples in JAVAEE tutorial use @Remote interface for some reason, which I'd like to avoid.

Regards,

Alexiey

[830 byte] By [arybinskya] at [2007-11-26 20:22:55]
# 1

Hi Alexiey,

What kind of class did you declare the @EJB on? The JavaEE environment annotations are

only supported on certain special managed classes such as servlets, JSF managed beans,

EJB bean classes, etc.If you are using one of those classes, you should also check that your

web.xml refers to the latest version of the web_app.xsd.

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http

://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/x

ml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

Otherwise, the web application is considered "J2EE 1.4 or earlier" and is not processed

for annotations.

If you want to access a local ejb reference from a POJO or utility class running in the

web tier, we have an EJB FAQ entry that explains how to do it :

https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#POJOLocalEJB

--ken

ksaksa at 2007-7-10 0:48:36 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...