You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Terje Hopsø <te...@online.no> on 2003/05/29 13:44:45 UTC
Database setup?
Hi,
I am trying to setup Tomcat according to the book "JavaServer Pages" page
157. But all I get when starting up tomcat is errors. I also tried JNDI but
that was less understandable so I will first try this simple setup, which I
cant understand why failes.
Anyone got a hint on what I have to to?
I have a standard Tomcat 4.1.18 and JSTL installed.
- Terje
Here is my setup in web.xml:
-------------------------
<context-param>
<param-name>
javax.servlet.jsp.jstl.sql.DataSource
</param-name>
<param-value>
jdbc:mysql://db.server.no:3306/myuser,com.mysql.jdbc.Driver,myusername,mypas
sword
</param-value>
</context-param>
-------------------------
The error when starting tomcat is:
Starting service Tomcat-Standalone
Apache Tomcat/4.1.18
29.mai.2003 13:28:37 org.apache.commons.digester.Digester error
SEVERE: Parse Error at line 28 column 11: The content of element type
"web-app" must match
"(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
l-ref
*)".
org.xml.sax.SAXParseException: The content of element type "web-app" must
match
"(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
l-ref*)".
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
lerWrapper.java:232)
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
lerWrapper.java:232)
at
org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:17
3)
at
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:37
1)
....
----------------------------------
In my jsp-file this works fine but I want to put the datasource parameters
into web.xml instead of each jsp-file where I access a database.
---
<sql:setDataSource var="ex" scope="application"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://db.server.no:3306/myuser"
user="myusername"
password="mypassword"
/>
<sql:query var="init"
dataSource="${ex}"
sql="select name from adress"
/>
<c:forEach items="${init.rows}" var="row">
<c:out value="${row.name}" /><br>
</c:forEach>
---
RE: Database setup?
Posted by Jan Behrens <ja...@diekleinedomain.de>.
hi terje,
haven't got your book at hand, but as tim stated before, the parser doesn't
like your web.xml, hence the error. i would suggest following the example
given here
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-how
to.html to setup a connection pool and use the example given there for your
code. it is really well documented and easy to follow (even i could :)
hth, jan
> -----Original Message-----
> From: Terje Hopsø [mailto:tehosubs@online.no]
> Sent: Thursday, May 29, 2003 2:04 PM
> To: 'Tomcat Users List'
> Subject: RE: Database setup?
>
>
> A correction: the web.xml example is on page 155.
>
> I tried to setup my web.xml according to the page you are
> refering to but I
> get the same error! Do I need to install anything else than what
> comes with
> the standard installation?
>
> - Terje
>
>
> -----Original Message-----
> From: Tim Funk [mailto:funkman@joedog.org]
> Sent: 29. mai 2003 13:49
> To: Tomcat Users List
> Subject: Re: Database setup?
>
>
> http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-ex
> amples-how
> to.html
>
> But, the particular error you are currently getting is your
> web.xml is not
> valid with respect to the dtd.
>
> -Tim
>
> Terje Hopsø wrote:
> > Hi,
> >
> > I am trying to setup Tomcat according to the book "JavaServer
> Pages" page
> > 157. But all I get when starting up tomcat is errors. I also tried JNDI
> but
> > that was less understandable so I will first try this simple
> setup, which
> I
> > cant understand why failes.
> >
> > Anyone got a hint on what I have to to?
> >
> > I have a standard Tomcat 4.1.18 and JSTL installed.
> >
> > - Terje
> >
> >
> > Here is my setup in web.xml:
> > -------------------------
> > <context-param>
> > <param-name>
> > javax.servlet.jsp.jstl.sql.DataSource
> > </param-name>
> > <param-value>
> >
> >
> jdbc:mysql://db.server.no:3306/myuser,com.mysql.jdbc.Driver,myuser
> name,mypas
> > sword
> > </param-value>
> > </context-param>
> > -------------------------
> > The error when starting tomcat is:
> > Starting service Tomcat-Standalone
> > Apache Tomcat/4.1.18
> > 29.mai.2003 13:28:37 org.apache.commons.digester.Digester error
> > SEVERE: Parse Error at line 28 column 11: The content of element type
> > "web-app" must match
> >
> "(icon?,display-name?,description?,distributable?,context-param*,f
> ilter*,fil
> >
> ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,m
> ime-mappin
> >
> g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resour
> ce-ref*,se
> >
> curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref
> *,ejb-loca
> > l-ref
> > *)".
> > org.xml.sax.SAXParseException: The content of element type
> "web-app" must
> > match
> >
> "(icon?,display-name?,description?,distributable?,context-param*,f
> ilter*,fil
> >
> ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,m
> ime-mappin
> >
> g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resour
> ce-ref*,se
> >
> curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref
> *,ejb-loca
> > l-ref*)".
> > at
> >
> org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException
> (ErrorHand
> > lerWrapper.java:232)
> > at
> >
> org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException
> (ErrorHand
> > lerWrapper.java:232)
> > at
> >
> org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapp
> er.java:17
> > 3)
> > at
> >
> org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReport
> er.java:37
> > 1)
> > ....
> > ----------------------------------
> >
> > In my jsp-file this works fine but I want to put the datasource
> parameters
> > into web.xml instead of each jsp-file where I access a database.
> > ---
> > <sql:setDataSource var="ex" scope="application"
> > driver="com.mysql.jdbc.Driver"
> > url="jdbc:mysql://db.server.no:3306/myuser"
> > user="myusername"
> > password="mypassword"
> > />
> > <sql:query var="init"
> > dataSource="${ex}"
> > sql="select name from adress"
> > />
> >
> > <c:forEach items="${init.rows}" var="row">
> > <c:out value="${row.name}" /><br>
> > </c:forEach>
> > ---
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Database setup?
Posted by Terje Hopsø <te...@online.no>.
A correction: the web.xml example is on page 155.
I tried to setup my web.xml according to the page you are refering to but I
get the same error! Do I need to install anything else than what comes with
the standard installation?
- Terje
-----Original Message-----
From: Tim Funk [mailto:funkman@joedog.org]
Sent: 29. mai 2003 13:49
To: Tomcat Users List
Subject: Re: Database setup?
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-how
to.html
But, the particular error you are currently getting is your web.xml is not
valid with respect to the dtd.
-Tim
Terje Hopsø wrote:
> Hi,
>
> I am trying to setup Tomcat according to the book "JavaServer Pages" page
> 157. But all I get when starting up tomcat is errors. I also tried JNDI
but
> that was less understandable so I will first try this simple setup, which
I
> cant understand why failes.
>
> Anyone got a hint on what I have to to?
>
> I have a standard Tomcat 4.1.18 and JSTL installed.
>
> - Terje
>
>
> Here is my setup in web.xml:
> -------------------------
> <context-param>
> <param-name>
> javax.servlet.jsp.jstl.sql.DataSource
> </param-name>
> <param-value>
>
>
jdbc:mysql://db.server.no:3306/myuser,com.mysql.jdbc.Driver,myusername,mypas
> sword
> </param-value>
> </context-param>
> -------------------------
> The error when starting tomcat is:
> Starting service Tomcat-Standalone
> Apache Tomcat/4.1.18
> 29.mai.2003 13:28:37 org.apache.commons.digester.Digester error
> SEVERE: Parse Error at line 28 column 11: The content of element type
> "web-app" must match
>
"(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
>
ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
>
g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
>
curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
> l-ref
> *)".
> org.xml.sax.SAXParseException: The content of element type "web-app" must
> match
>
"(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
>
ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
>
g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
>
curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
> l-ref*)".
> at
>
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
> lerWrapper.java:232)
> at
>
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
> lerWrapper.java:232)
> at
>
org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:17
> 3)
> at
>
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:37
> 1)
> ....
> ----------------------------------
>
> In my jsp-file this works fine but I want to put the datasource parameters
> into web.xml instead of each jsp-file where I access a database.
> ---
> <sql:setDataSource var="ex" scope="application"
> driver="com.mysql.jdbc.Driver"
> url="jdbc:mysql://db.server.no:3306/myuser"
> user="myusername"
> password="mypassword"
> />
> <sql:query var="init"
> dataSource="${ex}"
> sql="select name from adress"
> />
>
> <c:forEach items="${init.rows}" var="row">
> <c:out value="${row.name}" /><br>
> </c:forEach>
> ---
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Database setup?
Posted by Tim Funk <fu...@joedog.org>.
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
But, the particular error you are currently getting is your web.xml is not
valid with respect to the dtd.
-Tim
Terje Hopsø wrote:
> Hi,
>
> I am trying to setup Tomcat according to the book "JavaServer Pages" page
> 157. But all I get when starting up tomcat is errors. I also tried JNDI but
> that was less understandable so I will first try this simple setup, which I
> cant understand why failes.
>
> Anyone got a hint on what I have to to?
>
> I have a standard Tomcat 4.1.18 and JSTL installed.
>
> - Terje
>
>
> Here is my setup in web.xml:
> -------------------------
> <context-param>
> <param-name>
> javax.servlet.jsp.jstl.sql.DataSource
> </param-name>
> <param-value>
>
> jdbc:mysql://db.server.no:3306/myuser,com.mysql.jdbc.Driver,myusername,mypas
> sword
> </param-value>
> </context-param>
> -------------------------
> The error when starting tomcat is:
> Starting service Tomcat-Standalone
> Apache Tomcat/4.1.18
> 29.mai.2003 13:28:37 org.apache.commons.digester.Digester error
> SEVERE: Parse Error at line 28 column 11: The content of element type
> "web-app" must match
> "(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
> ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
> g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
> curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
> l-ref
> *)".
> org.xml.sax.SAXParseException: The content of element type "web-app" must
> match
> "(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
> ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
> g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
> curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
> l-ref*)".
> at
> org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
> lerWrapper.java:232)
> at
> org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
> lerWrapper.java:232)
> at
> org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:17
> 3)
> at
> org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:37
> 1)
> ....
> ----------------------------------
>
> In my jsp-file this works fine but I want to put the datasource parameters
> into web.xml instead of each jsp-file where I access a database.
> ---
> <sql:setDataSource var="ex" scope="application"
> driver="com.mysql.jdbc.Driver"
> url="jdbc:mysql://db.server.no:3306/myuser"
> user="myusername"
> password="mypassword"
> />
> <sql:query var="init"
> dataSource="${ex}"
> sql="select name from adress"
> />
>
> <c:forEach items="${init.rows}" var="row">
> <c:out value="${row.name}" /><br>
> </c:forEach>
> ---
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Database setup? - SOLVED
Posted by Kwok Peng Tuck <pe...@makmal.net>.
Yes it does have to be in order :) . Check the dtd that it references.
Terje Hopsø wrote:
>Thanks!!
>
>It was out of order. Now it start without errors. I was not aware of that it
>had to be in a spesific order.
>
>- Terje
>
>
>-----Original Message-----
>From: Brian Buchanan [mailto:brianbuchanan@interfast.ca]
>Sent: 29. mai 2003 14:15
>To: Tomcat Users List
>Subject: RE: Database setup?
>
>
>
>The order of the elements in the web.xml file must be in a specific order.
>
>As the error message states, they must appear in this order:
>(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
>ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
>g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
>curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
>l-ref
>
>You probably just have your nested elements out of order. Perhaps you have
>a <servlet> or <servlet-mapping> before your <context-param> which is
>invalid.
>
>If you want to know more about the format of the web.xml file, you can
>download the servlet specification from Sun here:
>
>http://java.sun.com/products/servlet/download.html
>
>Here's a link to the 2.3 specification
>http://www.jcp.org/aboutJava/communityprocess/final/jsr053/
>
>and refer to chapter 13 - Deployment Descriptor
>
>Once you have that sorted out you can see what next falls out.
>
>I would also recommend that you learn on the latest version of Tomcat
>available which is 4.1.24 right now.
>
>http://jakarta.apache.org/tomcat/
>
>http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.24/
>
>FYI, If you happen to be using Windows I'd also like to offer this advice:
>
>I used to download the .exe version and install it, but I would now
>recommend the .ZIP version as it doesn't "fiddle" with your configuration.
>Sure, getting it to run as a service is a bit trickier, but for development
>the less fiddling the better.
>
>As a zip file I start tomcat from the command line with
>
>SET JAVA_HOME=(whichever jvm I want to use)
>SET CATALINA_HOME=(Whever I unzipped tomcat to)
>%CATALINA_HOME%\bin\startup.bat
>
>Example:
>SET JAVA_HOME=C:\j2sdk1.4.1_02
>SET CATALINA_HOME=C:\jakarta-tomcat-4.1.24
>%CATALINA_HOME%\bin\startup.bat
>
>This way you can also try different JVM's and different tomcat installs
>easily.
>
>Good luck.
>
>._. Brian Buchanan
>
>-----Original Message-----
>From: Terje Hopsø [mailto:tehosubs@online.no]
>Sent: Thursday, May 29, 2003 7:45 AM
>To: 'Tomcat Users List'
>Subject: Database setup?
>
>
>Hi,
>
>I am trying to setup Tomcat according to the book "JavaServer Pages" page
>157. But all I get when starting up tomcat is errors. I also tried JNDI but
>that was less understandable so I will first try this simple setup, which I
>cant understand why failes.
>
>Anyone got a hint on what I have to to?
>
>I have a standard Tomcat 4.1.18 and JSTL installed.
>
>- Terje
>
>
>Here is my setup in web.xml:
>-------------------------
> <context-param>
> <param-name>
> javax.servlet.jsp.jstl.sql.DataSource
> </param-name>
> <param-value>
>
>jdbc:mysql://db.server.no:3306/myuser,com.mysql.jdbc.Driver,myusername,mypas
>sword
> </param-value>
> </context-param>
>-------------------------
>The error when starting tomcat is:
>Starting service Tomcat-Standalone
>Apache Tomcat/4.1.18
>29.mai.2003 13:28:37 org.apache.commons.digester.Digester error
>SEVERE: Parse Error at line 28 column 11: The content of element type
>"web-app" must match
>"(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
>ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
>g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
>curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
>l-ref
>*)".
>org.xml.sax.SAXParseException: The content of element type "web-app" must
>match
>"(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
>ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
>g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
>curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
>l-ref*)".
> at
>org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
>lerWrapper.java:232)
> at
>org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
>lerWrapper.java:232)
> at
>org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:17
>3)
> at
>org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:37
>1)
>....
>----------------------------------
>
>In my jsp-file this works fine but I want to put the datasource parameters
>into web.xml instead of each jsp-file where I access a database.
>---
><sql:setDataSource var="ex" scope="application"
> driver="com.mysql.jdbc.Driver"
> url="jdbc:mysql://db.server.no:3306/myuser"
> user="myusername"
> password="mypassword"
>/>
><sql:query var="init"
> dataSource="${ex}"
> sql="select name from adress"
>/>
>
><c:forEach items="${init.rows}" var="row">
> <c:out value="${row.name}" /><br>
></c:forEach>
>---
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Database setup? - SOLVED
Posted by Terje Hopsø <te...@online.no>.
Thanks!!
It was out of order. Now it start without errors. I was not aware of that it
had to be in a spesific order.
- Terje
-----Original Message-----
From: Brian Buchanan [mailto:brianbuchanan@interfast.ca]
Sent: 29. mai 2003 14:15
To: Tomcat Users List
Subject: RE: Database setup?
The order of the elements in the web.xml file must be in a specific order.
As the error message states, they must appear in this order:
(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
l-ref
You probably just have your nested elements out of order. Perhaps you have
a <servlet> or <servlet-mapping> before your <context-param> which is
invalid.
If you want to know more about the format of the web.xml file, you can
download the servlet specification from Sun here:
http://java.sun.com/products/servlet/download.html
Here's a link to the 2.3 specification
http://www.jcp.org/aboutJava/communityprocess/final/jsr053/
and refer to chapter 13 - Deployment Descriptor
Once you have that sorted out you can see what next falls out.
I would also recommend that you learn on the latest version of Tomcat
available which is 4.1.24 right now.
http://jakarta.apache.org/tomcat/
http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.24/
FYI, If you happen to be using Windows I'd also like to offer this advice:
I used to download the .exe version and install it, but I would now
recommend the .ZIP version as it doesn't "fiddle" with your configuration.
Sure, getting it to run as a service is a bit trickier, but for development
the less fiddling the better.
As a zip file I start tomcat from the command line with
SET JAVA_HOME=(whichever jvm I want to use)
SET CATALINA_HOME=(Whever I unzipped tomcat to)
%CATALINA_HOME%\bin\startup.bat
Example:
SET JAVA_HOME=C:\j2sdk1.4.1_02
SET CATALINA_HOME=C:\jakarta-tomcat-4.1.24
%CATALINA_HOME%\bin\startup.bat
This way you can also try different JVM's and different tomcat installs
easily.
Good luck.
._. Brian Buchanan
-----Original Message-----
From: Terje Hopsø [mailto:tehosubs@online.no]
Sent: Thursday, May 29, 2003 7:45 AM
To: 'Tomcat Users List'
Subject: Database setup?
Hi,
I am trying to setup Tomcat according to the book "JavaServer Pages" page
157. But all I get when starting up tomcat is errors. I also tried JNDI but
that was less understandable so I will first try this simple setup, which I
cant understand why failes.
Anyone got a hint on what I have to to?
I have a standard Tomcat 4.1.18 and JSTL installed.
- Terje
Here is my setup in web.xml:
-------------------------
<context-param>
<param-name>
javax.servlet.jsp.jstl.sql.DataSource
</param-name>
<param-value>
jdbc:mysql://db.server.no:3306/myuser,com.mysql.jdbc.Driver,myusername,mypas
sword
</param-value>
</context-param>
-------------------------
The error when starting tomcat is:
Starting service Tomcat-Standalone
Apache Tomcat/4.1.18
29.mai.2003 13:28:37 org.apache.commons.digester.Digester error
SEVERE: Parse Error at line 28 column 11: The content of element type
"web-app" must match
"(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
l-ref
*)".
org.xml.sax.SAXParseException: The content of element type "web-app" must
match
"(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
l-ref*)".
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
lerWrapper.java:232)
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
lerWrapper.java:232)
at
org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:17
3)
at
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:37
1)
....
----------------------------------
In my jsp-file this works fine but I want to put the datasource parameters
into web.xml instead of each jsp-file where I access a database.
---
<sql:setDataSource var="ex" scope="application"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://db.server.no:3306/myuser"
user="myusername"
password="mypassword"
/>
<sql:query var="init"
dataSource="${ex}"
sql="select name from adress"
/>
<c:forEach items="${init.rows}" var="row">
<c:out value="${row.name}" /><br>
</c:forEach>
---
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Database setup?
Posted by Brian Buchanan <br...@interfast.ca>.
The order of the elements in the web.xml file must be in a specific order.
As the error message states, they must appear in this order:
(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
l-ref
You probably just have your nested elements out of order. Perhaps you have
a <servlet> or <servlet-mapping> before your <context-param> which is
invalid.
If you want to know more about the format of the web.xml file, you can
download the servlet specification from Sun here:
http://java.sun.com/products/servlet/download.html
Here's a link to the 2.3 specification
http://www.jcp.org/aboutJava/communityprocess/final/jsr053/
and refer to chapter 13 - Deployment Descriptor
Once you have that sorted out you can see what next falls out.
I would also recommend that you learn on the latest version of Tomcat
available which is 4.1.24 right now.
http://jakarta.apache.org/tomcat/
http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.1.24/
FYI, If you happen to be using Windows I'd also like to offer this advice:
I used to download the .exe version and install it, but I would now
recommend the .ZIP version as it doesn't "fiddle" with your configuration.
Sure, getting it to run as a service is a bit trickier, but for development
the less fiddling the better.
As a zip file I start tomcat from the command line with
SET JAVA_HOME=(whichever jvm I want to use)
SET CATALINA_HOME=(Whever I unzipped tomcat to)
%CATALINA_HOME%\bin\startup.bat
Example:
SET JAVA_HOME=C:\j2sdk1.4.1_02
SET CATALINA_HOME=C:\jakarta-tomcat-4.1.24
%CATALINA_HOME%\bin\startup.bat
This way you can also try different JVM's and different tomcat installs
easily.
Good luck.
._. Brian Buchanan
-----Original Message-----
From: Terje Hopsø [mailto:tehosubs@online.no]
Sent: Thursday, May 29, 2003 7:45 AM
To: 'Tomcat Users List'
Subject: Database setup?
Hi,
I am trying to setup Tomcat according to the book "JavaServer Pages" page
157. But all I get when starting up tomcat is errors. I also tried JNDI but
that was less understandable so I will first try this simple setup, which I
cant understand why failes.
Anyone got a hint on what I have to to?
I have a standard Tomcat 4.1.18 and JSTL installed.
- Terje
Here is my setup in web.xml:
-------------------------
<context-param>
<param-name>
javax.servlet.jsp.jstl.sql.DataSource
</param-name>
<param-value>
jdbc:mysql://db.server.no:3306/myuser,com.mysql.jdbc.Driver,myusername,mypas
sword
</param-value>
</context-param>
-------------------------
The error when starting tomcat is:
Starting service Tomcat-Standalone
Apache Tomcat/4.1.18
29.mai.2003 13:28:37 org.apache.commons.digester.Digester error
SEVERE: Parse Error at line 28 column 11: The content of element type
"web-app" must match
"(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
l-ref
*)".
org.xml.sax.SAXParseException: The content of element type "web-app" must
match
"(icon?,display-name?,description?,distributable?,context-param*,filter*,fil
ter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mappin
g*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-loca
l-ref*)".
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
lerWrapper.java:232)
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHand
lerWrapper.java:232)
at
org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:17
3)
at
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:37
1)
....
----------------------------------
In my jsp-file this works fine but I want to put the datasource parameters
into web.xml instead of each jsp-file where I access a database.
---
<sql:setDataSource var="ex" scope="application"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://db.server.no:3306/myuser"
user="myusername"
password="mypassword"
/>
<sql:query var="init"
dataSource="${ex}"
sql="select name from adress"
/>
<c:forEach items="${init.rows}" var="row">
<c:out value="${row.name}" /><br>
</c:forEach>
---
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org