I've been trying out many different avenues to make this work and
finally found the following bug, hopefully this will save other people
some time:

 

http://www.mail-archive.com/tomcat-dev@jakarta.apache.org/msg64410.html

 

which says:

 

>And finally i find the solution,that is to remove all Naming-*.jar out 

>from /%myapp_home%/WEB-INF/lib.I firmly think there's some disorder
with 

>tomcat classloader.In other words,ClassLoader may not check which class
to >be 

>loader first and which to be loaded second and which have already be
loaded!

 

-Ken

 

________________________________

From: Ken Hall 
Sent: Thursday, December 16, 2004 3:41 PM
To: '[EMAIL PROTECTED]'
Subject: tomcat 5.5 and jndi context naming error

 

Since downloading the new version of Tomcat 5.5.4, I have been
experiencing problems with jndi resources within my web app. I am
porting over from an existing server where that resource is working. The
error is listed at the bottom.

 

I saw in the release notes that naming-common.jar (JNDI Context
implementation) is one of the required files but it does not appear to
be included in the download. When I include it from a previous release,
it appears to not like it. When I leave it out, it can not find the jndi
context either.
 
java.lang.NoSuchMethodError:
org.apache.naming.NamingContextBindingsEnumeration.
<init>(Ljava/util/Iterator;)V
        at
org.apache.naming.resources.FileDirContext.listBindings(FileDirContex
t.java:335)
        at
org.apache.naming.resources.ProxyDirContext.listBindings(ProxyDirCont
ext.java:515)
        at
org.apache.catalina.util.ExtensionValidator.validateApplication(Exten
sionValidator.java:178)
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3
934)
 
 
Here is my set up. Any help is greatly appreciated. I can't do anything
with this release till this is solved. Thanks!

-Ken Hall

 

According to the docs, the preferred method is not messing with the
server.xml but creating an "application.xml". I've tried both name value
pairs and resource parameters. This is done and placed in the
conf\Catalina\localhost directory:

 

<?xml version='1.0' encoding='utf-8'?>

<Context docBase="c:/jakarta-tomcat-5.5/webapps/myapp" path="/myapp"
workDir="work\Catalina\localhost\myapp">

    <Resource auth="Container" name="jdbc/myapp"
type="javax.sql.DataSource"/>

    <ResourceParams name="jdbc/myapp">

      <parameter>

        <name>maxWait</name>

        <value>5000</value>

      </parameter>

      <parameter>

        <name>maxActive</name>

        <value>6</value>

      </parameter>

      <parameter>

        <name>username</name>

        <value>xx</value>

      </parameter>

      <parameter>

        <name>removeAbandoned</name>

        <value>true</value>

      </parameter>      

      <parameter>

        <name>password</name>

        <value>xx</value>

      </parameter>      

      <parameter>

        <name>url</name>

        <value>jdbc:jtds:sqlserver://server:1433/myapp</value>

      </parameter>

      <parameter>

        <name>driverClassName</name>

        <value>net.sourceforge.jtds.jdbc.Driver</value>

      </parameter>

      <parameter>

        <name>maxIdle</name>

        <value>2</value>

      </parameter>

    </ResourceParams>  

</Context>

 

 

In my app's web.xml I have:

 

            </servlet-mapping>         

 

              <resource-ref> 

                <res-ref-name>jdbc/myapp</res-ref-name>

                <res-type>javax.sql.DataSource</res-type>

                <res-auth>Container</res-auth>

              </resource-ref>

 

            <welcome-file-list>

 

 

 

My application is referencing the context like this: 

InitialContext initContext = new javax.naming.InitialContext();

Context envContext=(Context)initContext.lookup("java:comp/env");

DataSource ds = (DataSource)envContext.lookup("jdbc/myapp");

 

 

 

//Error upon calling context

SEVERE: Null component
Catalina:type=DataSource,path=/myapp,host=localhost,class=javax.sql.Data
Source,name="jdbc/myapp"

Unable to connect to myapp database. Class Not Found.Name java:comp is
not bound in this Context

javax.naming.NameNotFoundException: Name java:comp is not bound in this
Context

      at org.apache.naming.NamingContext.lookup(NamingContext.java:768)

      at org.apache.naming.NamingContext.lookup(NamingContext.java:151)

      at javax.naming.InitialContext.lookup(InitialContext.java:351)

      at my.load.servlet

      at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.jav
a:1053)

      at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:886)

      at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.j
ava:3817)

      at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4079
)

      at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.ja
va:755)

      at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)

      at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)

      at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:777)

      at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:672)

      at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:472)

      at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1079)

      at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:31
0)

      at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSu
pport.java:119)

      at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1011)

      at
org.apache.catalina.core.StandardHost.start(StandardHost.java:718)

      at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003)

      at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:437)

      at
org.apache.catalina.core.StandardService.start(StandardService.java:450)

      at
org.apache.catalina.core.StandardServer.start(StandardServer.java:2010)

      at org.apache.catalina.startup.Catalina.start(Catalina.java:537)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)

      at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:585)

      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)

      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)

 

Reply via email to