The servlet spec was designed around webapps being completely self-contained packages of pages and logic. I'm sure there are people on this list who what you are looking for ... I haven't. Maybe they can chime in here.

As an alternative to storing webapps in tomcat's webapps directory, you could place a <Context ... > ... </Context> xml fragment in a file in conf/Catalina/localhost with docBase and path properly set. Then the user deploy their own webapp in the folder pointed to by the docBase attribute.

--David

Tim Potter wrote:

David,
Thanks for your input,  I can test that out, but that would be a different
direction than I think I want to go.

I have running an apache web server that users access home directories
(mod_user) in order to run thier primarily php scripted web pages, but some
would like the option of jsp.

So currently I have tomcat running with mod_jk, and jkmount setup in apache
awaiting /*.jsp to interpret, and i'm able to successfully run a test.jsp
page which gets interpreted.

On that note, should I just as easily create a
~user/public_html/WEB-INF/web.xml ...    or do I need to modify things to
the DBCP to function.

Thanks and I appreciate the instructions!

Tim Potter

On Wed, Oct 15, 2008 at 6:00 PM, David Smith <[EMAIL PROTECTED]> wrote:

I think I see your problem.  Don't modify the default web.xml file or the
default context.xml file unless you really have good reason to.  Instead,
your webapp should be layed out similar to this, per the servlet spec:

DBTest
 - test.jsp
 - WEB-INF
     - web.xml
     - lib
         - standard.jar
         - jstl.jar
 - META-INF
    - context.xml

All this goes under tomcat's webapps directory.  Separately, put your mysql
driver jar in tomcat's /lib directory for tomcat 6.0.x, /common/lib for most
previous versions of tomcat.

All the additional stuff you put in tomcat's /conf/web.xml and
/conf/context.xml should be put in the web.xml and context.xml files shown
above under DBTest.  I've included standard.jar and jstl.jar above because
your test.jsp is using the sql jstl taglib.

--David


Tim Potter wrote:

These are my web.xml, context.xml, and test.jsp files (truncated).
Let me know if there are any other files you would like to see.

[EMAIL PROTECTED]:~$ cat  /usr/local/tomcat/conf/web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
 version="2.5">

<!-- ======================== Introduction ==============================
-->

<!--   There is a bunch of stuff not included as its not relevant to this
-->

<!-- ==================== Default Welcome File List =====================
-->
<!-- When a request URI refers to a directory, the default servlet looks
-->
<!-- for a "welcome file" within that directory and, if present,
-->
<!-- to the corresponding resource URI for display.  If no welcome file
-->
<!-- is present, the default servlet either serves a directory listing,
-->
<!-- or returns a 404 status, depending on how it is configured.
-->
<!--
-->
<!-- If you define welcome files in your own application's web.xml
-->
<!-- deployment descriptor, that list *replaces* the list configured
-->
<!-- here, so be sure that you include any of the default values that
-->
<!-- you wish to include.
-->

 <welcome-file-list>
     <welcome-file>index.html</welcome-file>
     <welcome-file>index.htm</welcome-file>
     <welcome-file>index.jsp</welcome-file>
 </welcome-file-list>

<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>


[EMAIL PROTECTED]:~$ cat  /usr/local/tomcat/conf/context.xml
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context>

 <!-- Default set of monitored resources -->
 <WatchedResource>WEB-INF/web.xml</WatchedResource>

</Context>
<Context path="/DBTest" docBase="DBTest"
debug="5" reloadable="true" crossContext="true">

 <!-- maxActive: Maximum number of dB connections in pool. Make sure you
      configure your mysqld max_connections large enough to handle
      all of your db connections. Set to -1 for no limit.
      -->

 <!-- maxIdle: Maximum number of idle dB connections to retain in pool.
      Set to -1 for no limit.  See also the DBCP documentation on this
      and the minEvictableIdleTimeMillis configuration parameter.
      -->

 <!-- maxWait: Maximum time to wait for a dB connection to become
available
      in ms, in this example 10 seconds. An Exception is thrown if
      this timeout is exceeded.  Set to -1 to wait indefinitely.
      -->

 <!-- username and password: MySQL dB username and password for dB
connections  -->

 <!-- driverClassName: Class name for the old mm.mysql JDBC driver is
      org.gjt.mm.mysql.Driver - we recommend using Connector/J though.
      Class name for the official MySQL Connector/J driver is
com.mysql.jdbc.Driver.
      -->

 <!-- url: The JDBC connection url for connecting to your MySQL dB.
      The autoReconnect=true argument to the url makes sure that the
      mm.mysql JDBC Driver will automatically reconnect if mysqld closed
the
      connection.  mysqld by default closes idle connections after 8
hours.
      -->

<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
            maxActive="100" maxIdle="30" maxWait="10000"
            username="javauser" password="thetestpasswordcreated"
driverClassName="com.mysql.jdbc.Driver"

url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>

</Context>


[EMAIL PROTECTED]:~$ cat  /usr/local/tomcat/webapps/ROOT/test.jsp
[sudo] password for tpotter:
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql"; prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>

<sql:query var="rs" dataSource="jdbc/TestDB">
select id, foo, bar from testdata
</sql:query>

<html>
<head>
 <title>DB Test</title>
</head>
<body>

<h2>Results</h2>

<c:forEach var="row" items="${rs.rows}">
 Foo ${row.foo}<br/>
 Bar ${row.bar}<br/>
</c:forEach>

</body>
</html>



On Wed, Oct 15, 2008 at 2:11 PM, David Smith <[EMAIL PROTECTED]> wrote:



It'd be helpful if you could post that file.  Sanitize it for db
usernames
and passwords, but post it so we can see what it looks like.  Also, run
it
through an XML validator to see if there's any issues.  Netbeans has one
built-in.

--David


Tim Potter wrote:



I am attempting to setup a tomcat mysql connection in order to allow
users
to write jsp webapps that can use a mysql database backend.

I have understood that this page seems to be a "walkthrough" on how to
set
this up, and I'm running into problems in the MySQL DBCP Example
section.



http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html

I have followed the steps verbatim (except the javauser account password
in
mysql, I'm using something different)

In step 2, I put the <context...> entry separate of the existing context
entry located in $CATALINA_ROOT/conf/context.xml

In step 3, I put the <description> and <resource-ref> at the end of the
web.xml file (right before </web-app>

and I have created a testfile in $CATALINA_ROOT/webapps/ROOT/test.jsp

When I restart tomcat, logs/catalina.out has some lines like the
following
(where line 36 is the new <Context ...> entry):


Oct 15, 2008 1:55:02 PM org.apache.tomcat.util.digester.Digester
fatalError
SEVERE: Parse Fatal Error at line 36 column 2: The markup in the
document
following the root element must be well-formed.
org.xml.sax.SAXParseException: The markup in the document following the
root
element must be well-formed.
    at


com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    at


com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
    at


com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
    at


com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1411)
    at


com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$TrailingMiscDriver.next(XMLDocumentScannerImpl.java:1394)
    at


com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:645)
    at


com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:508)
    at


com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
    at


com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    at


com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
    at


com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
    at


com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at
org.apache.tomcat.util.digester.Digester.parse(Digester.java:1644)
    at


org.apache.catalina.startup.ContextConfig.processContextConfig(ContextConfig.java:789)
    at


org.apache.catalina.startup.ContextConfig.contextConfig(ContextConfig.java:728)
    at
org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:1009)
    at


org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)
    at


org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at
org.apache.catalina.core.StandardContext.init(StandardContext.java:5338)
    at

org.apache.catalina.core.StandardContext.start(StandardContext.java:4086)
    at


org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at


org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
    at


org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
    at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
    at

org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at


org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at
org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at
org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at


sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at


sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

Oct 15, 2008 1:55:02 PM org.apache.catalina.startup.ContextConfig
processContextConfig
SEVERE: Parse error in context.xml for /examples
org.xml.sax.SAXParseException: The markup in the document following the
root
element must be well-formed.
    at


com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1231)
    at


com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at
org.apache.tomcat.util.digester.Digester.parse(Digester.java:1644)
    at


org.apache.catalina.startup.ContextConfig.processContextConfig(ContextConfig.java:789)
    at


org.apache.catalina.startup.ContextConfig.contextConfig(ContextConfig.java:728)
    at
org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:1009)
    at


org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)
    at


org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at
org.apache.catalina.core.StandardContext.init(StandardContext.java:5338)
    at

org.apache.catalina.core.StandardContext.start(StandardContext.java:4086)
    at


org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at


org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
    at


org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
    at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
    at

org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at


org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at
org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at
org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at


sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at


sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)





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





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





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

Reply via email to