Alan Chaney wrote:
Hi

I am using Eclipse 3.3, tomcat 6.0.14, linux and Java 1.5

I have a web app which uses a JNDI data source. I wrote a very simple test servlet to access the data source and display some values from the database. First time around I used a local application context in /META-INF/context.xml. This worked fine. I then moved the Resource definition to a GlobalNamingResource in server.xml and that worked fine with a ResourceRef in context.xml.

All well and good. I then renamed the app to ROOT with a path '/'.

The servlet still responds and renders text correctly at http://localhost:8080/ but I get a javax.naming.NameNotFoundException regardless of whether the resource definition in context.xml or GlobalNamingResource in server.xml and referenced in context.xml. Needless to say the database content is no longer displayed.

As a further test I exported the the war files as ROOT.war and deployed the war to a tomcat instance. It deployed OK but I still got the naming exception. I then deployed the original (non-ROOT) test app to the same server and that worked.

It seems that for some reason a ROOT app cannot access a JNDI DataSource. Has anyone seen anything like this or has any explanation

The exception report starts;


Failed to create datasource
javax.naming.NameNotFoundException: Name wrshowdbLink is not bound in this Context
    at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:781)



The context.xml is displayed below:

<?xml version="1.0" encoding="UTF-8"?>
<Context >
    <ResourceLink name="wrshowdbLink"         global="jdbc/wrshowdb"
        type="javax.sql.DataSource"
/>
</Context>

The web.xml for the ROOT app is:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns="http://java.sun.com/xml/ns/javaee"; xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; id="WebApp_ID" version="2.5">
  <display-name>ROOT</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description>Test of using root jndi</description>
    <display-name>RootJndi</display-name>
    <servlet-name>RootJndi</servlet-name>
    <servlet-class>com.writingshow.test.RootJndi</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>RootJndi</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

and the GlobalResourceDef is:

<Resource auth="Container" driverClassName="org.postgresql.Driver" maxActive="20" maxIdle="10" maxWait="3000" name="jdbc/wrshowdb" password="xxxxxxx" removeAbandoned="true" type="javax.sql.DataSource" url="jdbc:postgresql://127.0.0.1:5432/wrshowdb" username="wrshow"/>


Hi Alan,

Is there a ./conf/Catalina/host/ROOT.xml?

--
Regards

Gabe Wong
NGASI AppServer Manager
Application server installation and configuration AUTOMATION
http://www.ngasi.com


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to