DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7274>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7274

.lookup return null instead of valid data source.

           Summary: .lookup return null instead of valid data source.
           Product: Tomcat 4
           Version: 4.0.2 Final
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Unknown
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I'm using Tomcat 4.0.1 final with no problems, but with Tomcat 4.0.2 LE final 
on JDK 1.4.0 the following does not work:

I have a PostgreSQL 7.2 database build with theese options:

  ./configure --enable-multibyte=UNICODE --enable-locale

I have create a database named "bildb" and a user "biluser" which owns this 
database. I'm using PosgreSQL jdbc driver: jdbc7.1-1.2.jar which have been 
placed in $CATALINA_HOME/common/lib. I have the following entry in my 
$CATALINE_HOME/conf/server.xml under service/engine/host/context:

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

<ResourceParams name="jdbc/bildb">
  <parameter>
    <name>user</name><value>biluser</value>
  </parameter>
  <parameter>
    <name>password</name><value>abcdef42</value>
  </parameter>
  <parameter>
    <name>driverClassName</name><value>org.postgresql.Driver</value>
  </parameter>
  <parameter>
    <name>driverName</name><value>jdbc:postgresql:bildb</value>
  </parameter>
</ResourceParams>

I have testet that I can connect to the database with the above credentials: 
psql -h localhost -p 5432 -U biluser -W bildb

I have the following in my WEB-INF/web.xml file:

<resource-ref>
  <description>Bildb connection</description>
  <res-ref-name>jdbc/bildb</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>

I'm using the following test JSP code to access the database:

1: Context initCtx = new javax.naming.InitialContext();
2: DataSource ds = (javax.sql.DataSource) initCtx.lookup
                                          ("java:comp/env/jdbc/bildb");
3: Connection conn = ds.getConnection();
4: conn.close();

When returning from the lookup call in line 2, I'm left with a null object, 
which of cause make the rest of the lines (3) go haywire. Changing the name of 
the resource to an invalid value makes the lookup throw an exception that the 
resource is not bound, which of course is what to except.

I can't se any trace in the log files for any error, so I'm quite stuck right 
now.

Please let me know if you need any further information.

Yours sincerely
Christian Damsgaard

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to