tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tarek M. Nabil" <Tarek.Na...@itworx.com>
Subject RE: JNDI DataSource
Date Sun, 15 Jun 2003 13:04:07 GMT
Hi everyone,

I just managed to get this working. Obviously, it doesn't work if I put the <Resource>
and <Resource-params> tags inside the <GlobalNamingResources> element, even if
I create another <Resource> entry inside the <Context> element.

Someone once mentioned that maybe the tag inside the <Context> element should be the
<Resource-ref> tag, not the <Context> tag, but I really didn't know the syntax
for this one, so I couldn't try it.

Now, it works only if I put both the <Resource> and <Resource-params> tags inside
the <Context> element of my application. I find this rather limiting, because most of
the time, I don't wanna create a <Context> element for my application. I think there
must be some other way to do this, but I guess I don't know it.

The wierdest thing is, I DIDN'T need to add a <Resource-ref> element in my web.xml!!!!!!!!
What's this entry for anyway?

One other question I have is, do we have some sort of documentation or a DTD for this server.xml
file that we check for available elements and their attributes.

Thanks a lot for your help.

Tarek Nabil

-----Original Message-----
From: Tarek M. Nabil 
Sent: Sunday, June 15, 2003 12:45 PM
To: 'Tam, Michael'; 'Tomcat Users List'
Subject: RE: JNDI DataSource


Thanks Micheal.

Actually, I did put the jar that contains the driver in $CATALINA_HOME/common/lib. So, I guess
I'll just try what you recommended and if it works, then I think I'll switch to a different
driver and test to see if this is a driver specific thing. Maybe no one tried that driver
ever before.

Thanks,
Tarek Nabil

-----Original Message-----
From: Tam, Michael [mailto:mtam@pfc.cfs.nrcan.gc.ca]
Sent: Thursday, June 12, 2003 9:18 PM
To: 'Tomcat Users List'
Subject: RE: JNDI DataSource


You didn't mention about your jdbc jar file in your post and maybe you
should check where did you put the jar file.  In addition, you may want to
try a simple jsp to use driver manager to obtain a connection to see if your
jdbc lib is loaded.

Cheers,
Michael

-----Original Message-----
From: Tarek M. Nabil [mailto:Tarek.Nabil@itworx.com]
Sent: Thursday, June 12, 2003 10:57 AM
To: Phillip Qin; Tomcat Users List
Subject: RE: JNDI DataSource


Hi Philip,

I checked, and the URL thing is driver specific. For the driver I'm using,
the format is "jdbc:as400:machineName" and that's what I'm using.

The strange thing is the error message "Cannot load JDBC driver class
'null'". Why does Tomcat see the dirver as null, although I have specified
it in the ResourceParams.

Thanks,
Tarek Nabil


-----Original Message-----
From: Phillip Qin [mailto:pqin@shareowner.com]
Sent: Thursday, June 12, 2003 8:19 PM
To: 'Tomcat Users List'
Subject: RE: JNDI DataSource


Replace your url with fully qualified url, in Oracle I use
jdbc:oracle:thin:@myhost.myudomain.com:port:sid

-----Original Message-----
From: Tarek M. Nabil [mailto:Tarek.Nabil@itworx.com] 
Sent: June 12, 2003 1:09 PM
To: 'Tomcat Users List' (E-mail)
Subject: JNDI DataSource

Hi,

I'm trying to setup a JDBC DataSource on Tomcat 4.1.24.

I performed the steps in the documentation:

1- Added this part to the GlobalNamingResources section of the server.xml

    <Resource name="jdbc/as400" scope="Shareable"
type="javax.sql.DataSource" auth="Container"/>
    <Resource name="UserDatabase" scope="Shareable"
type="org.apache.catalina.UserDatabase" auth="Container" description="User
database that can be updated and saved"/>
    <ResourceParams name="jdbc/as400">
      <parameter>
        <name>maxWait</name>
        <value>5000</value>
      </parameter>
      <parameter>
        <name>maxActive</name>
        <value>8</value>
      </parameter>
      <parameter>
        <name>url</name>
        <value>jdbc:as400:AS400</value>
      </parameter>
      <parameter>
        <name>password</name>
        <value>access2k</value>
      </parameter>
      <parameter>
        <name>driverClassName</name>
        <value>com.ibm.as400.access.AS400JDBCDriver</value>
      </parameter>
      <parameter>
        <name>maxIdle</name>
        <value>4</value>
      </parameter>
      <parameter>
        <name>username</name>
        <value>DBA</value>
      </parameter>
    </ResourceParams>
    <ResourceParams name="UserDatabase">
      <parameter>
        <name>factory</name>
        <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
      </parameter>
      <parameter>
        <name>pathname</name>
        <value>conf/tomcat-users.xml</value>
      </parameter>
    </ResourceParams>

2- I added this to my web.xml

	<resource-ref>
		<description>
		    Resource reference to a factory for java.sql.Connection
			instances that talk to an AS400 database
		</description>
		<res-ref-name>
			jdbc/as400
		</res-ref-name>
		<res-type>
			javax.sql.DataSource
		</res-type>
		<res-auth>
			Container
		</res-auth>
	</resource-ref>

3- I put this in a JSP

<%@ page import="javax.naming.*, java.sql.*, javax.sql.*" %> 
<%
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)
  envCtx.lookup("jdbc/as400");

Connection conn = ds.getConnection();
conn.close();

%>


And Still, I get the following error when accessing the JSP

type Exception report

message 

description The server encountered an internal error () that prevented it
from fulfilling this request.

exception 

org.apache.jasper.JasperException: Cannot load JDBC driver class 'null'
	at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
54)
	at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:256)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:171)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:392)
	at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:619)
	at java.lang.Thread.run(Thread.java:484)


root cause 

javax.servlet.ServletException: Cannot load JDBC driver class 'null'
	at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:536)
	at org.apache.jsp.test_jsp._jspService(test_jsp.java:61)
	at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2
10)
	at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:256)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:171)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
	at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:392)
	at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:619)
	at java.lang.Thread.run(Thread.java:484)



----------------------------------------------------------------------------
----

Any help is appreciated.

Thanks,
Tarek M. Nabil

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message