Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to lookup a local interface for a session bean?

 
Matt S Andersson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello.

I am trying out EJBs for the first time and i ran into a problem trying to lookup the local interface of a session bean.


My session EJB looks like this:

package model;

@Stateless
@Remote
@Local
public class SessionEJBBean implements SessionEJBLocal, SessionEJB {
...
}

The local interface:

package model;

@Local
public interface SessionEJBLocal {
...
}

And my remote interface (that i don't wish to use):

package model;

@Remote
public interface SessionEJB {
...
}

Now i have a simple test client where i would like to use the session bean. I tried this (among a few other ideas that didn't work):

@EJB(name = "model/SessionEJBBean", beanInterface = SessionEJBLocal.class)
public class SessionEJBClient1 {
public static void main(String [] args) {
try {
final Context context = getInitialContext();
Object ref = context.lookup("java:comp/env/model/SessionEJBBean");
SessionEJBLocal sessionEJB = (SessionEJBLocal) ref;
...
}

This fails with the error message: "javax.naming.NameNotFoundException: While trying to lookup 'java:comp.env/model/SessionEJBBean' didn't find subcontext 'java:comp'. Resolved '' [Root exception is javax.naming.NameNotFoundException: While trying to lookup 'java:comp.env/model/SessionEJBBean' didn't find subcontext 'java:comp'. Resolved '']; remaining name 'java:comp/env/model/SessionEJBBean'
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)"

Can someone please give me a hand here?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic