Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Probelms with JNDI references  RSS feed

 
Tina Jain
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everybody,

I am using WSAD 5.1.2

I am trying to use a session bean from by servlet.

When I am trying to use JNDI It is working fine.

But when I am trying to access it thought references. It is giving me errors.

Here is the code.

<ejb-jar id="ejb-jar_ID">
<display-name>ShoppingCart</display-name>
<enterprise-beans>
<session id="Cart">
<ejb-name>Cart</ejb-name>
<home>com.shopping.CartHome</home>
<remote>com.shopping.Cart</remote>
<ejb-class>com.shopping.CartBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref id="EjbRef_1161104011546">
<ejb-ref-name>ejb/Cart</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.shopping.CartHome</home>
<remote>com.shopping.Cart</remote>
<ejb-link>Cart</ejb-link>
</ejb-ref>
</session>
</enterprise-beans>
<ejb-client-jar>ShoppingCartClient.jar</ejb-client-jar>
</ejb-jar>

From a servlet i am using this code.

When I am trying it with



ctx = new InitialContext();
String ejbref_name = " ejb/com/shopping/CartHome";
return ctx.lookup(ejbref_name);

it is working fine.

. When I am trying it with


ctx = new InitialContext();
String ejbref_name = "java:comp/env/ejb/Cart";
return ctx.lookup(ejbref_name);
it is giving me Error.

I also tried, this too is not working.

ctx = new InitialContext();
String ejbref_name = " ejb/Cart";
return ctx.lookup(ejbref_name);


Thanks for your talent and time.

This is the Error that i am getting.


10/17/06 12:01:33:609 CDT] 50290197 SystemErr R javax.naming.NameNotFoundException: Name comp/env/ejb not found in context "java:".
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1663)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1009)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:932)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1261)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:196)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:137)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at javax.naming.InitialContext.lookup(InitialContext.java:360)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.shopping.commons.ServiceLocator.getObject(ServiceLocator.java:34)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.shopping.commons.ServiceLocator.getCartHome(ServiceLocator.java:44)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.shopping.AddCartServlet.doPost(AddCartServlet.java:37)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.shopping.AddCartServlet.doGet(AddCartServlet.java:27)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
[10/17/06 12:01:33:609 CDT] 50290197 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
[10/17/06 12:01:33:984 CDT] 50290197 WebGroup E SRVE0026E: [Servlet Error]-[AddCartServlet]: java.lang.NullPointerException
at com.shopping.AddCartServlet.doPost(AddCartServlet.java:45)
at com.shopping.AddCartServlet.doGet(AddCartServlet.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a tutorial that demonstrates the various ways to configure JNDI and resource references using IBM's Rational Application Developer. Maybe it will give you some insights:

JNDI and Resource References with WebSphere

With the following entry in the web.xml file, I am able to invoke my EJB using java:comp/env/ejb/StatelessTimer:





local:ejb/ejb/com/examscam/ejb/PersonBMPLocalHome


I hope this helps.

-Cameron McKenzie
 
Tina Jain
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I went thought all the notes, but I was not able to get the right answers.

Please go thought my problems that I have posted.

Any help will be of great help.

I am trying thinks but it giving me error.

javax.naming.NameNotFoundException: Name "comp/env/" not found in context "java:".

There is something that i am missing please help.
 
Amit Agwal
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Couple of things, I have worked in JBoss and the things to look for shouldnt be a lot dfferent in other ApSevers.

-- Do check on the sever console that the application has reployed successfully without any errors after changes made.

-- The ejb-name should be the same fully qualified string which is case sensitive and should not contain unwanted spaces.
 
Emanuele Ghe
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tina Jain wrote:I went thought all the notes, but I was not able to get the right answers.

Please go thought my problems that I have posted.

Any help will be of great help.

I am trying thinks but it giving me error.

javax.naming.NameNotFoundException: Name "comp/env/" not found in context "java:".

There is something that i am missing please help.


Tina did you solved the problem ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!