You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John Walstra <jw...@spoonserver.com> on 2002/09/06 01:28:47 UTC

JNDI hates me

javax.naming.NamingException: Cannot create resource instance

I can't get pass that error. I have no problem with javamail, but when I try 
to roll my own I get the above.

Here is the debug message when I start Tomcat ...

Resolve: -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN 
http://java.sun.com/dtd/web-app_2_3.dtd
  Using alternate DTD /javax/servlet/resources/web-app_2_3.dtd
XmlMapper: org.apache.catalina.core.StandardContext.setPublicId(-//Sun 
Microsystems, Inc.//DTD Web Application 2.3//EN)
XmlMapper: org.apache.catalina.core.StandardContext.addTaglib( /orataglib, 
/WEB-INF/tlds/orataglib_1_0_3.tld)
XmlMapper: org.apache.catalina.core.StandardContext.addTaglib( /lms, 
/WEB-INF/tlds/lms-1.0.tld)
XmlMapper: new null org.apache.catalina.deploy.ContextResource resource-ref 
ContextResource[name=null, scope=Shareable]
XmlMapper: org.apache.catalina.deploy.ContextResource.setName( map/Server)
XmlMapper: org.apache.catalina.deploy.ContextResource.setType( 
org.apache.commons.pool.PoolableObjectFactor)
XmlMapper: org.apache.catalina.deploy.ContextResource.setAuth( Container)
XmlMapper: Calling org.apache.catalina.core.StandardContext.addResource 
ContextResource[name=map/Server, 
type=org.apache.commons.pool.PoolableObjectFactor, auth=Container, 
scope=Shareable]
XmlMapper: pop resource-ref org.apache.catalina.deploy.ContextResource: 
ContextResource[name=map/Server, 
type=org.apache.commons.pool.PoolableObjectFactor, auth=Container, 
scope=Shareable]
XmlMapper: Debug level: 3

I've added a grant rule in catalina.policy ...

grant {
        // Required for JNDI lookup of named JDBC DataSource's and
        // javamail named MimePart DataSource used to send mail
        permission java.util.PropertyPermission "org.apache.commons.pool.*", 
"read";

I've added to my server.xml ...

<Resource name="map/Server" auth="Container" 
type="org.apache.commons.pool.PoolableObjectFactor
y"/>

I've added to my web.xml ...

  <resource-ref>
    <res-ref-name>map/Server</res-ref-name>
    <res-type>org.apache.commons.pool.PoolableObjectFactor</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>

Here's is my code ...

    try
    {
      Context ctx = new InitialContext();
      if( ctx == null )
      {
        throw new Exception( "No context" );
      }

      PoolableObjectFactory serverMapFactory = 
(PoolableObjectFactory)ctx.lookup("java:comp/env/map/Server" );
      if( serverMapFactory != null )
      {
        serverMapPool = new StackObjectPool( serverMapFactory, 1000 );
      }
      else
      {
        throw new Exception( "Could not get serverMapFactory" );
      }
    }
    catch( Exception e )
    {
      e.printStackTrace( System.err );
    }

Why oh why does JNDI hate me?

-- 
John Walstra
jwalstra@spoonserver.com

Program load too heavy for processor to lift.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>