tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anjib Mulepati <anji...@hotmail.com>
Subject Re: JNDI configuration with 6.0.29
Date Thu, 08 Sep 2011 21:51:58 GMT

when i click  on java:/comp 
<http://localhost:8080/ClientDAOTest/newjsp.jsp?path=java:/comp> it gave 
error

Error: Cannot create resource instance

                 javax.naming.NamingException: Cannot create resource instance
	at org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:113)
	at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
	at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:113)
	at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:71)
	at org.apache.jsp.newjsp_jsp._jspService(newjsp_jsp.java:106)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:662)

    When I click onjdbc  <http://localhost:8080/ClientDAOTest/newjsp.jsp?path=java:comp/env/jdbc>

it give error

Error: Name jdbc is not bound in this Context

                 javax.naming.NameNotFoundException: Name jdbc is not 
bound in this Context
     at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
     at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
     at 
org.apache.naming.factory.ResourceLinkFactory.getObjectInstance(ResourceLinkFactory.java:97)
     at 
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
     at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
     at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
     at 
org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:113)
     at 
org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:71)
     at org.apache.jsp.newjsp_jsp._jspService(newjsp_jsp.java:106)
     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     at 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
     at 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
     at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
     at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
     at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
     at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
     at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
     at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
     at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
     at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
     at 
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
     at java.lang.Thread.run(Thread.java:662)





On 9/8/2011 5:11 PM, Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Anjib,
>
> On 9/8/2011 4:51 PM, Anjib Mulepati wrote:
>> DataSource ds = null; try { 40.           Context initCtx = new
>> InitialContext(); 41.            Context envCtx = (Context)
>> initCtx.lookup("java:comp/env"); 42.           ds = (DataSource)
>> envCtx.lookup("jdbc/dynic");
> Odd to use a local variable for this, but I guess you could do that.
>
> I've seen "java:comp/env" and "java:/comp/env", but both seem to work.
>
> Try running this JSP. It's a bit fragile, but it should get the job done.
>
> - -chris
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <%@page pageEncoding="UTF-8"
>     session="false"
>     language="Java"
>     import="
>      javax.naming.InitialContext,
>      javax.naming.Binding,
>      javax.naming.Context,
>      javax.naming.NamingEnumeration,
>      javax.naming.NamingException
>     "
> %>
> <%
>    String path = "java:/comp/env";
>
>    String pathParam = request.getParameter("path");
>    if(null != pathParam&&  !"".equals(pathParam.trim()))
>      path = pathParam.trim();
>
>    int pos = path.lastIndexOf('/');
>    String parent = pos>  0 ? path.substring(0, pos) : "java:comp/env";
> %>
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head>
>    <title>JNDI Browser:<%= path %></title>
> </head>
> <body>
>    <h1>JNDI Browser:<%= path %></h1>
>
>    <p><a href="?path=<%= parent %>"><%= parent %></a></p>
> <%
>    InitialContext ctx = null;
>    NamingEnumeration e = null;
>    try
>    {
>      ctx = new InitialContext();
>      e = ctx.listBindings(path);
>
>      if(e.hasMoreElements())
>      {
> %>
>    <ul>
> <%
>        while(e.hasMoreElements())
>        {
>          Binding b = (Binding)e.next();
> %>
>      <li>
> <%
>          if(b.getObject() instanceof Context)
>          {
> %>
>            <a href="?path=<%= path %>/<%= b.getName() %>"><%=
> b.getName() %></a>
> <%
>          }
>          else
>          {
> %>
>             <%= b.getName() %>  (<%= b.getClassName() %>)
> <%
>          }
> %>
>      </li>
> <%
>        }
> %>
>    </ul>
> <%
>      }
>      else
>      {
> %>
>    <p>JNDI context is empty</p>
> <%
>      }
>    }
>    catch (NamingException ne)
>    {
> %>
>    <p>Error:<%= ne.getMessage() %><pre>
>    <%
>      java.io.PrintWriter myout = new java.io.PrintWriter(out);
>      ne.printStackTrace(myout);
>      myout.flush();
>    %>
>    </pre></p>
> <%
>    }
>    finally
>    {
>      if(null != e) try { e.close(); } catch (NamingException ne)
>        { %><p><%= ne.getMessage() %></p><% }
>
>      if(null != ctx) try { ctx.close(); } catch (NamingException ne)
>        { %><p><%= ne.getMessage() %></p><% }
>    }//foo
> %>
> </body>
> </html>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk5pL3gACgkQ9CaO5/Lv0PBLAQCglRlAcKBZa5Gtrg494FfcvA2c
> /hIAoIu0fj/5ejz3+C3Pk/S8i1PeQG50
> =F0ZW
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message