You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Meichun Li <li...@metalab.unc.edu> on 2002/07/10 23:50:49 UTC

DataSource Casting Problem

Hi, 

I have DataSource Casting problem while using DBCP. The server.xml and 
web.xml configuration should be fine.  

The error is:
java.lang.ClassCastException: org.apache.commons.dbcp.BasicDataSource

I searched the archive and it is said that the jar file jdbc2_0-stdext.jar 
should only be put in $CATALINA_HOME/common/lib. 

But If I don't put it in /WEB-INF/lib directory, there is another error:
javax.sql.* package cant' be found. 

The related codes are:

Context initCtx = new InitialContext();
Context envCtx=(Context)initCtx.lookup("java:comp/env");
DataSource ds =(DataSource)envCtx.lookup("jdbc/ospreyDb");

It works if I use this:
org.apache.commons.dbcp.BasicDataSource ds=
          (org.apache.commons.dbcp.BasicDataSource) 
envCtx.lookup("jdbc/ospreyDb");

Any ideas? Thanks a lot in advance!

-Meichun


-- 
Meichun Li
Ibiblio.org
919-962-5646


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: DataSource Casting Problem

Posted by Meichun Li <li...@metalab.unc.edu>.
I am using Tomcat 4.0.1 and JDK 1.3.

I changed the server.xml as you said and get the error message as 
followed. But I have no idea what it is.  What should I do if there is a 
class load issue?

Thanks!
-Meichun
---------------
org.apache.jasper.JasperException: Unable to compile class for JSP
/opt/jakarta/jakarta-tomcat-4.0.1/work/localhost/osrt_osprey_webapps/user/do_0005fauth$jsp.java:6: 
Package javax.sql not found in import.
import javax.sql.*;
       ^
1 error

        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
        at 
org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:546)
        at 
org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:177)
        at 
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:189)
        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.http.HttpProcessor.process(HttpProcessor.java:1011)
        at 
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
        at java.lang.Thread.run(Thread.java:498)

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

 On Thu, 11 Jul 2002, Andrew Conrad wrote:

> If the jdbc2_0-stdext.jar is in the common/lib and no where else, and
> you can't see it from your JSP code, you have a class loading issue that
> probably relates to your problem.  
> 
> What version of TC?  JDK?  
> 
> With TC 4.1.x (maybe older versions too...) you can see the class
> loading structure by turning on debugging for it in your Context.
> 
> <Context .... debug="9">
> 	<Loader debug="9"  />
> </Context>
> 
> 
> 
> - Andrew
> 
> 
> 
> -----Original Message-----
> From: Meichun Li [mailto:lim@metalab.unc.edu] 
> Sent: Wednesday, July 10, 2002 5:51 PM
> To: Tomcat Users List
> Subject: DataSource Casting Problem
> 
> 
> Hi, 
> 
> I have DataSource Casting problem while using DBCP. The server.xml and 
> web.xml configuration should be fine.  
> 
> The error is:
> java.lang.ClassCastException: org.apache.commons.dbcp.BasicDataSource
> 
> I searched the archive and it is said that the jar file
> jdbc2_0-stdext.jar 
> should only be put in $CATALINA_HOME/common/lib. 
> 
> But If I don't put it in /WEB-INF/lib directory, there is another error:
> javax.sql.* package cant' be found. 
> 
> The related codes are:
> 
> Context initCtx = new InitialContext();
> Context envCtx=(Context)initCtx.lookup("java:comp/env");
> DataSource ds =(DataSource)envCtx.lookup("jdbc/ospreyDb");
> 
> It works if I use this:
> org.apache.commons.dbcp.BasicDataSource ds=
>           (org.apache.commons.dbcp.BasicDataSource) 
> envCtx.lookup("jdbc/ospreyDb");
> 
> Any ideas? Thanks a lot in advance!
> 
> -Meichun
> 
> 
> 

-- 
Meichun Li
Ibiblio.org
919-962-5646


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: DataSource Casting Problem

Posted by Andrew Conrad <an...@msn.com>.
If the jdbc2_0-stdext.jar is in the common/lib and no where else, and
you can't see it from your JSP code, you have a class loading issue that
probably relates to your problem.  

What version of TC?  JDK?  

With TC 4.1.x (maybe older versions too...) you can see the class
loading structure by turning on debugging for it in your Context.

<Context .... debug="9">
	<Loader debug="9"  />
</Context>



- Andrew



-----Original Message-----
From: Meichun Li [mailto:lim@metalab.unc.edu] 
Sent: Wednesday, July 10, 2002 5:51 PM
To: Tomcat Users List
Subject: DataSource Casting Problem


Hi, 

I have DataSource Casting problem while using DBCP. The server.xml and 
web.xml configuration should be fine.  

The error is:
java.lang.ClassCastException: org.apache.commons.dbcp.BasicDataSource

I searched the archive and it is said that the jar file
jdbc2_0-stdext.jar 
should only be put in $CATALINA_HOME/common/lib. 

But If I don't put it in /WEB-INF/lib directory, there is another error:
javax.sql.* package cant' be found. 

The related codes are:

Context initCtx = new InitialContext();
Context envCtx=(Context)initCtx.lookup("java:comp/env");
DataSource ds =(DataSource)envCtx.lookup("jdbc/ospreyDb");

It works if I use this:
org.apache.commons.dbcp.BasicDataSource ds=
          (org.apache.commons.dbcp.BasicDataSource) 
envCtx.lookup("jdbc/ospreyDb");

Any ideas? Thanks a lot in advance!

-Meichun


-- 
Meichun Li
Ibiblio.org
919-962-5646


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>