Answers inline below. --David
Wayne Bragg wrote: > Thank you David, > > I was suspicious about the .java needing to be compiled and the > commons-dbcp.jar and commons-pool.jar being unnecessary. What about > commons-collections-3.2.jar is that necessary or does commons-el.jar > have what is needed? Commons-el.jar is all that was in there to start > with. You've given me enough to go on to fix this and make this work. > I thank you again.. > If commons-el.jar was all that was in common/lib, only add the mysql driver jar. commons-collections shouldn't be needed except by your project if you use it. > Do you think it's better to allow Tomcat to handle the MySql or have > PHP and MySql handled by httpd and pass the java related calls on to > Tomcat? I just finished reading an article that explains how to set it > up this second way and have to admit it would be better for me in the > SHORT run as I have pre-existing code that wouldn't require rewriting > other than adding NEW java code which is the reason I'm doing this in > the first place. > IMHO it's a cleaner solution if you can get this all in tomcat or php. Having part in one and part in the other just makes things complicated and hard to work with. > Also 97 and Visual J but it doesn't appear to be able to save .class > files. It looks like it just puts the class code into the .exe at > compile time. I also installed just installed MS Visual Web Developer > Express, do you know if this will compile and save a .class file? > A lot of people on this list seem to like Eclipse as an IDE. I personally am a fan of Netbeans. Don't use any of Microsoft's developer tools except for those rare moments when I have to help a co-worker out with .net stuff. > Thanks for the help.. > > > > ----- Original Message ----- From: "David Smith" <[EMAIL PROTECTED]> > 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: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> -- >> 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]