this is my source ,develop is ok.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Context ctx = null;
try
{
ctx = new InitialContext();
test1LocalHome test1localhome = (test1LocalHome) ctx.lookup("test1Local");
String testok = test1localhome.create().getTest();
}
catch(Exception e)
{
e.printStackTrace();
}
}
but this is my exception
javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/test.jar#test1/local-home' Resolved: 'app/ejb' Unresolved:'test.jar#test1' ; remaining name 'test.jar#test1/local-home'
I use weblogic server,thanks!!!
Discussions
EJB programming & troubleshooting: I want to use an servlet to calling an sessionBean,what can I do
-
I want to use an servlet to calling an sessionBean,what can I do (2 messages)
- Posted by: jiang yh
- Posted on: July 02 2003 02:08 EDT
Threaded Messages (2)
- I want to use an servlet to calling an sessionBean,what can I do by Luc Vo on July 02 2003 03:42 EDT
- I want to use an servlet to calling an sessionBean,what can I do by Raffi Basmajian on July 02 2003 13:05 EDT
-
I want to use an servlet to calling an sessionBean,what can I do[ Go to top ]
- Posted by: Luc Vo
- Posted on: July 02 2003 03:42 EDT
- in response to jiang yh
I think you might have set your initial lookup environment wrong. Double check your JNDI names too (having a JNDI browser might help 'locate' your EJBs if you're not sure how/where to reference them)
Try this (replace java:comp/env by whatever Weblogic is set to):
Context initial = new InitialContext();
Context myEnv = (Context)initial.lookup("java:comp/env");
Object objYourEJBHome = myEnv.lookup("ejb/YourEJB");
create... -
I want to use an servlet to calling an sessionBean,what can I do[ Go to top ]
- Posted by: Raffi Basmajian
- Posted on: July 02 2003 13:05 EDT
- in response to Luc Vo
Your example will work provided that the EJB has been specified via a 'ref' in the deployment descriptor, otherwise, you cannot find it using JNDI ENC.
Creating an InitialContext with no argument defaults to the host and port on which the servlet is running, but if your EJBs are located elsewhere, then you need to explicitly specify the parameters in the context.
Raffi