tags:

views:

214

answers:

1

I have a simple web application, packed as an EAR, deployed on Glassfish. The EAR has a web module and an EJB module. The web module has a faces page, and a ManagedBean. The Faces page only has a button on it, and the button is tied to a method in the ManagedBean, and clicking the button does indeed fire the method.

The managed bean:

public class Bar {

    public Bar() {
    }

    @EJB StudentProfileFacade f;

    public void hello(ActionEvent evt) {
        System.out.println("*** f: " + f);
    }
}

The EJB is not getting injected, the error I get is:

Exception attempting to inject Unresolved Ejb-Ref com.web.Bar/f@jndi: com.StudentProfileFacade@[email protected]@Session@null into class com.web.Bar

What do I need to do so that the web module will find the EJB module, and the EJBs in it?

A: 

Hi,

try to do jndi lookup instead of di. It could look like:

private StudentProfileFacadeInt getStudentProfileFacade() { try { InitialContext ctx = new InitialContext(); return (StudentProfileFacadeInt) ctx.lookup("/StudentProfileFacade/local"); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("couldn't lookup StudentProfileFacade", e); } }

Where StudentProfileFacadeInt is a local interfejs for StudentProfileFacade.