Mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wayne Bragg" <wlbr...@cox.net>
Subject Re: install DBCP and mm.mysql 2.0.14 (JDBC Driver) and test app, get class compile error.
Date Mon, 05 Mar 2007 17:46:48 GMT
David, you can ignore the question about how to compile .java into .class. I 
just found out the jdk can do that.


Wayne

----- Original Message ----- 
From: "David Smith" <dns4@cornell.edu>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Monday, March 05, 2007 7:06 AM
Subject: Re: install DBCP and mm.mysql 2.0.14 (JDBC Driver) and test app, 
get class compile error.


>A few things to consider ...
>
> 1) What version of tomcat are you using?  What follows is based on using
> version 5.0.x.  The syntax for configuring JDBC resources in 5.5 is a
> little different.
>
> 2)  mm.mysql 2.0.14 is VERY old.  What version of MySQL Db server are
> you using?  You may want to take a look at the MySQL website for an
> updated driver .jar file.  I believe the current driver version is
> Connector/J 5.0.5
>
> 3) The mm.mysql driver file has to be in common/lib.  That's because the
> tomcat server itself has to be able to access the driver when setting up
> the db pool before your webapp even loads.
>
> 4) If using the tomcat internal database pooling, there is no need for
> adding commons-dbcp.jar or commons-pool.jar as tomcat has a slightly
> refactored version of commons-dbcp already.  The refactoring was only a
> package name change to avoid collisions with webapps that use
> commons-dbcp directly.  Only add those jars if you have some code of
> your own using classes in the packages org.apache.commons.dbcp or
> org.apache.commons.pool.
>
> 5) The stack trace cited below is in regards to your test jsp file.
> Class files need to be compiled before deployment as tomcat doesn't
> compile them itself -- it only compiles jsps.  To fix the error below,
> compile DbTest.java to DbTest.class and place it in WEB-INF/classes/foo
> or in a .jar archive in WEB-INF/lib.
>
> There's a start.  You might also want to review the tomcat docs
> regarding JNDI and JDBC resources -- how to configure, etc., ...
>
> --David
>
>
> Wayne Bragg wrote:
>
>>Sorry about the previous premature post.....
>>This is the full question/problem....
>>
>>I am trying to install DBCP and mm.mysql 2.0.14 (JDBC Driver) and a test 
>>app to see if it works.
>>I'm not sure I have all the correct steps and configuration, in other 
>>words I don't know what I am doing.. Here is what I know and my setup for 
>>this test example that I keep getting a class compile error on.
>>
>>You can probably tell I only have HALF a clue at best? Any ideas what's 
>>wrong?
>>
>>This is the error reported by browser -
>>
>>type Exception report
>>message
>> description The server encountered an internal error () that prevented it 
>> from fulfilling this request.
>>exception
>> org.apache.jasper.JasperException: Unable to compile class for JSP
>>An error occurred at line: 7 in the jsp file: /test.jsp
>>Generated servlet error:
>>foo.DBTest cannot be resolved to a type
>>An error occurred at line: 7 in the jsp file: /test.jsp
>>Generated servlet error:
>>foo.DBTest cannot be resolved to a type
>> org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
>> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>root cause
>> org.apache.jasper.JasperException: Unable to compile class for JSP
>>An error occurred at line: 7 in the jsp file: /test.jsp
>>Generated servlet error:
>>foo.DBTest cannot be resolved to a type
>>An error occurred at line: 7 in the jsp file: /test.jsp
>>Generated servlet error:
>>foo.DBTest cannot be resolved to a type
>> org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
>> org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
>> org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
>> org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
>> org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
>> org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
>> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
>> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>
>>This is the Tomcat log -
>>
>>Mar 5, 2007 12:13:30 AM org.apache.catalina.core.StandardWrapperValve 
>>invoke
>>SEVERE: Servlet.service() for servlet jsp threw exception
>>org.apache.jasper.JasperException: Unable to compile class for JSP
>>An error occurred at line: 7 in the jsp file: /test.jsp
>>Generated servlet error:
>>foo.DBTest cannot be resolved to a type
>>An error occurred at line: 7 in the jsp file: /test.jsp
>>Generated servlet error:
>>foo.DBTest cannot be resolved to a type
>> at 
>> org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
>> at 
>> org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
>> at 
>> org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
>> at org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
>> at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
>> at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
>> at 
>> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
>> at 
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
>> at 
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
>> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>> at 
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
>> at 
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
>> at 
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
>> at 
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
>> at 
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
>> at 
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
>> at 
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
>> at 
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
>> at 
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
>> at 
>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
>> at 
>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
>> at 
>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
>> at 
>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
>> at java.lang.Thread.run(Unknown Source)
>>
>>This is how I setup and config for the DBCP and mm.mysql 2.0.14 (JDBC 
>>Driver)
>>
>>Added to \www\tomcat5\common\lib
>>    commons-pool-1.3.jar
>>    commons-collections-3.2.jar
>>    commons-dbcp-1.2.1.jar
>>
>>Added to \www\webapps\DBTest\WEB-INF\lib
>>    mm.mysql-2.0.14-bin.jar
>>
>>.classpath
>>
>><?xml version="1.0" encoding="UTF-8"?>
>><classpath>
>> <classpathentry kind="src" path="WEB-INF/java">
>>  <attributes>
>>  </attributes>
>> </classpathentry>
>> <classpathentry kind="lib" path="WEB-INF/lib/mm.mysql-2.0.14-bin.jar">
>>  <attributes>
>>  </attributes>
>> </classpathentry>
>> <classpathentry kind="con" path="org.gjt.mm.mysql.Driver">
>>  <attributes>
>>  </attributes>
>> </classpathentry>
>> <classpathentry kind="output" path="WEB-INF/classes"/>
>></classpath>
>>
>>.project
>>
>><?xml version="1.0" encoding="UTF-8"?>
>><projectDescription>
>> <name>chat-demo-war</name>
>> <comment></comment>
>> <projects>
>> </projects>
>> <buildSpec>
>>  <buildCommand>
>>   <name>org.eclipse.jdt.core.javabuilder</name>
>>   <arguments>
>>   </arguments>
>>  </buildCommand>
>> </buildSpec>
>> <natures>
>>  <nature>org.eclipse.jdt.core.javanature</nature>
>> </natures>
>></projectDescription>
>>
>>\DBTest\WEB-INF\web.xml
>>
>><?xml version="1.0" encoding="ISO-8859-1"?>
>>    <!DOCTYPE web-app PUBLIC
>>    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
>>    "http://java.sun.com/dtd/web-app_2_3.dtd">
>><web-app>
>>  <description>MySQL Test App</description>
>>  <resource-ref>
>>      <description>DB Connection</description>
>>      <res-ref-name>jdbc/TestDB</res-ref-name>
>>      <res-type>javax.sql.DataSource</res-type>
>>      <res-auth>Container</res-auth>
>>  </resource-ref>
>></web-app>
>>
>>Added to server.xml
>>
>><Context path="/DBTest" docBase="DBTest"
>>   debug="5" reloadable="true" crossContext="true">
>>  <Logger className="org.apache.catalina.logger.FileLogger"
>>       prefix="localhost_DBTest_log." suffix=".txt"
>>       timestamp="true"/>
>>  <Resource name="jdbc/TestDB"
>>       auth="Container"
>>       type="javax.sql.DataSource"/>
>>  <ResourceParams name="jdbc/TestDB">
>>    <parameter>
>>       <name>factory</name>
>>       <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>>    </parameter>
>>    <parameter>
>>       <name>maxActive</name>
>>       <value>100</value>
>>    </parameter>
>>    <parameter>
>>       <name>maxIdle</name>
>>       <value>30</value>
>>    </parameter>
>>    <parameter>
>>       <name>maxWait</name>
>>       <value>10000</value>
>>    </parameter>
>>    <parameter>
>>       <name>username</name>
>>       <value>javauser</value>
>>    </parameter>
>>    <parameter>
>>      <name>password</name>
>>      <value>javadude</value>
>>    </parameter>
>>    <parameter>
>>      <name>driverClassName</name>
>>      <value>org.gjt.mm.mysql.Driver</value>
>>    </parameter>
>>    <parameter>
>>      <name>url</name>
>> 
>> <value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
>>    </parameter>
>>The example I was following wasn't clear about if these next three went 
>>here or not
>> <parameter>
>>      <name>removeAbandoned</name>
>>      <value>true</value>
>>    </parameter>
>>    <parameter>
>>      <name>removeAbandonedTimeout</name>
>>      <value>60</value>
>>    </parameter>
>>    <parameter>
>>      <name>logAbandoned</name>
>>      <value>true</value>
>>    </parameter>
>> </ResourceParams>
>></Context>
>>
>>The class I can't get to compile
>>
>>package foo;
>>
>>import javax.naming.*;
>>import javax.sql.*;
>>import java.sql.*;
>>
>>public class DBTest {
>>
>>  String foo = "Not Connected";
>>  int bar = -1;
>>
>>  public void init() {
>>    try{
>>      Context ctx = new InitialContext();
>>      if(ctx == null )
>>          throw new Exception("Boom - No Context");
>>
>>      DataSource ds =
>>            (DataSource)ctx.lookup(
>>               "java:comp/env/jdbc/TestDB");
>>
>>      if (ds != null) {
>>        Connection conn = ds.getConnection();
>>
>>        if(conn != null)  {
>>            foo = "Got Connection "+conn.toString();
>>            Statement stmt = conn.createStatement();
>>            ResultSet rst =
>>                stmt.executeQuery(
>>                  "select id, foo, bar from testdata");
>>            if(rst.next()) {
>>               foo=rst.getString(2);
>>               bar=rst.getInt(3);
>>            }
>>            conn.close();
>>        }
>>      }
>>    }catch(Exception e) {
>>      e.printStackTrace();
>>    }
>> }
>>
>> public String getFoo() { return foo; }
>> public int getBar() { return bar;}
>>}
>>
>>The test application
>>
>><html>
>>  <head>
>>    <title>DB Test</title>
>>  </head>
>>  <body>
>>
>>  <%
>>    foo.DBTest tst = new foo.DBTest();
>>    tst.init();
>>  %>
>>
>>  <h2>Results</h2>
>>    Foo <%= tst.getFoo() %><br/>
>>    Bar <%= tst.getBar() %>
>>
>>  </body>
>></html>
>>
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
> -- 
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.7/711 - Release Date: 3/5/2007 
> 9:41 AM
>
> 


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


Mime
View raw message