Farath Shba
Farath Shba

Reputation: 31

JNDI binding EJB3 issues

I am stuck on a JNDI binding process on EJB3 and here is the source code which I am terribly stuck at.

/*
     * Create session bean.
     */
    public static AG20BWOPortal getSessionBean() throws NamingException, RemoteException, CreateException{
        if(wo == null){
            Context ic = new InitialContext();
            System.out.println("test1");
            Object obj = ic.lookup("ejb/sg/gov/hdb/ag20/ejb/AG20BWOPortalHome");  //JNDI name (from EJB module xmi file)
            System.out.println("test2");
            AG20BWOPortalHome home = (AG20BWOPortalHome) PortableRemoteObject.narrow(obj, AG20BWOPortalHome.class);
            wo = home.create();
        }
        return wo;
    }

My questions are

Upvotes: 1

Views: 228

Answers (1)

Farath Shba
Farath Shba

Reputation: 31

I am answering this on my own if anyone want to catch the drift of how I did this.

  1. EJB Implementation Class -> @Stateless Annotation
  2. EJB Remote Interface -> @Remote Annotation

This would bind the EJB classes together.

PS: Do not forget to remove the extends from EJB's remote interface as well.

Upvotes: 1

Related Questions