You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brian Adams <ba...@AEM-TX.com> on 2002/02/12 14:24:42 UTC

RE: database connect to db overr mod_webapp - possible bug

can we see the errors?

-----Original Message-----
From: Chris Faulkner [mailto:christopher.faulkner@ntlworld.com]
Sent: Tuesday, February 12, 2002 7:26 AM
To: Tomcat Users List
Subject: database connect to db overr mod_webapp - possible bug


Hi

I have a JSP which,when called direct into Tomcat (4.0.1) on Linux works
fine. It connects to a database, retrieves results, fine.

http://host_a:8080/ism/JSP/file.jsp?param1=value&param2=value

"host_a" is a vrtual host defined in my apache config and in the DNS servers
on our LAN.

In the virtual host setting of Apache, I have 

WebAppConnection coni warp localhost:8008
WebAppDeploy ism   coni    /ism/

Static pages,servlets and JSP are fine across mod_webapp. However, when I
try my database JSP, I get errors. This code is in the JSP when I go through
8080 and it WORKS, it connects to the DB and all goes 
OK. So my configuration of the jdbc/IsmDB must be OK. I created the JDBC
datasources as outlined at the Tomcat website.

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
javax.sql.DataSource ds = (javax.sql.DataSource)envCtx.lookup("jdbc/IsmDB");
Connection conn = ds.getConnection();

However, when I connect to the page via Apache, the third line fails the
connection to the database fails. I replace those 4 lines with the following
and it works.

String sConn   = "jdbc:oracle:thin:@ip:port:sid"; // connnection string
DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver() );
Connection conn=DriverManager.getConnection( sConn, "user", "password" );
Statement stmt    = conn.createStatement();

So have I missed some configuration to make the database connection work
over mod_webapp or is this a bug ?

Thanks


Chris



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: RE: database connect to db overr mod_webapp - possible bug

Posted by Chris Faulkner <ch...@ntlworld.com>.
Hi

>can we see the errors?

Wow - fast response. Thank-you. Iactually just noticed that someone else found the exact same thing. He got no replies.

http://groups.google.com/groups?q=mod_webapp+JDBC&hl=en&selm=7774774d.0109191826.5240aa0%40posting.google.com&rnum=1

On the web page,I see this;

java.lang.NullPointerException
	at org.apache.jsp.ism$jsp._jspService(ism$jsp.java:123)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.connector.warp.WarpRequestHandler.handle(WarpRequestHandler.java:215)
	at org.apache.catalina.connector.warp.WarpConnection.run(WarpConnection.java:194)
	at java.lang.Thread.run(Thread.java:484)


The errors  in the apache log file in $CATALINA_HOME/logs are as follows:

2002-02-12 13:10:16 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp
 threw exception
java.lang.NullPointerException
        at org.apache.jsp.ismResult_0005fn$jsp._jspService(ismResult_0005fn$jsp.
java:124)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspSer
vlet.java:202)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
82)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:247)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:193)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:243)
        at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
.java:566)


Thanks


Chris

>
>-----Original Message-----
>From: Chris Faulkner [mailto:christopher.faulkner@ntlworld.com]
>Sent: Tuesday, February 12, 2002 7:26 AM
>To: Tomcat Users List
>Subject: database connect to db overr mod_webapp - possible bug
>
>
>Hi
>
>I have a JSP which,when called direct into Tomcat (4.0.1) on Linux works
>fine. It connects to a database, retrieves results, fine.
>
>http://host_a:8080/ism/JSP/file.jsp?param1=value&param2=value
>
>"host_a" is a vrtual host defined in my apache config and in the DNS servers
>on our LAN.
>
>In the virtual host setting of Apache, I have 
>
>WebAppConnection coni warp localhost:8008
>WebAppDeploy ism   coni    /ism/
>
>Static pages,servlets and JSP are fine across mod_webapp. However, when I
>try my database JSP, I get errors. This code is in the JSP when I go through
>8080 and it WORKS, it connects to the DB and all goes 
>OK. So my configuration of the jdbc/IsmDB must be OK. I created the JDBC
>datasources as outlined at the Tomcat website.
>
>Context initCtx = new InitialContext();
>Context envCtx = (Context) initCtx.lookup("java:comp/env");
>javax.sql.DataSource ds = (javax.sql.DataSource)envCtx.lookup("jdbc/IsmDB");
>Connection conn = ds.getConnection();
>
>However, when I connect to the page via Apache, the third line fails the
>connection to the database fails. I replace those 4 lines with the following
>and it works.
>
>String sConn   = "jdbc:oracle:thin:@ip:port:sid"; // connnection string
>DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver() );
>Connection conn=DriverManager.getConnection( sConn, "user", "password" );
>Statement stmt    = conn.createStatement();
>
>So have I missed some configuration to make the database connection work
>over mod_webapp or is this a bug ?
>
>Thanks
>
>
>Chris
>
>
>
>--
>To unsubscribe:   <ma...@jakarta.apache.org>
>For additional commands: <ma...@jakarta.apache.org>
>Troubles with the list: <ma...@jakarta.apache.org>
>
>--
>To unsubscribe:   <ma...@jakarta.apache.org>
>For additional commands: <ma...@jakarta.apache.org>
>Troubles with the list: <ma...@jakarta.apache.org>
>
>




--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>