Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat problem while reading Data from Xml file

 
Harish Tiruvile
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to invoke a servlet which extract data from xml file.
I am facing one problem while invoking servlet..After entering url if i press "ENTER" button tomcat will shutdowm immediatly without showing error message..so i am not able to find where i made mistake..

While starting tomcat i noticed

***************************************************************************
Sep 6, 2006 2:09:18 PM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Sep 6, 2006 2:09:18 PM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8009
Starting service Tomcat-Standalone
Apache Tomcat/4.1.32
Sep 6, 2006 2:09:19 PM org.apache.commons.digester.Digester error
SEVERE: Parse Error at line 345 column 11: The content of element type "web-app"
must match "(icon?,display-name?,description?,distributable?,context-param*,fil
ter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-ma
pping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-re
f*)".
org.xml.sax.SAXParseException: The content of element type "web-app" must match
"(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-
mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welco
me-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-const
raint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Un
known Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown S
ource)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)

at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(
Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContent
Dispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
known Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Sour
ce)
at org.apache.commons.digester.Digester.parse(Digester.java:1647)
at org.apache.catalina.startup.ContextConfig.applicationConfig(ContextCo
nfig.java:220)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:57
9)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi
g.java:181)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:119)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3
643)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1147)

at org.apache.catalina.core.StandardHost.start(StandardHost.java:696)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1147)

at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:310
)
at org.apache.catalina.core.StandardService.start(StandardService.java:4
49)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:221
2)
at org.apache.catalina.startup.Catalina.start(Catalina.java:458)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:345)
at org.apache.catalina.startup.Catalina.process(Catalina.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:150)
Sep 6, 2006 2:09:26 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Sep 6, 2006 2:09:26 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8009

***************************************************************************

If any one knows where i made mistake please assist me
[ September 06, 2006: Message edited by: harish thrivile ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

SEVERE: Parse Error at line 345 column 11: The content of element type "web-app"
must match "(icon?,display-name?,description?,distributable?,context-param*,fil
ter*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-ma
pping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,se
curity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-re
f*)".

Looks like you have not defined your web.xml file as per the DTD. When xerces parses this file it is checking that each element is as it should be based on the DTD. Hava a look at the DTD and check you have defined web.xml as it is required.
 
Harish Tiruvile
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Paul Sturrock for replying

But in this example i am not validating data...

I am pasting complete code here if anyone knows the where i made mistake please guide me to resolve that error

Main sevlet class



Utility class used for extracting data from XMl file placed inside class folder inside WEB-INF



I am storing this two class files and EventLog.xml files in webapps\examples\WEB-INF\classes

After writing URL-Mapping i web.xml..i tryed to invoke servlet by entering URL in Browser http://localhost:8080/examples/readXML

But immediatly tomcat gets shutdown....If anyone trace out where i made mistake from above code then please guide me in resolving this issue...or else if you know any tutorials link for "SERVLET & reading XML" please post that here

[ September 06, 2006: Message edited by: harish thrivile ]
[ September 06, 2006: Message edited by: harish thrivile ]
 
Paul Clapham
Sheriff
Posts: 21318
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you make your mistake? It was assuming that the code you posted had anything to do with the problem. If you look at the stack trace you posted, you don't see ReadCompleteErrorReport anywhere in it, do you? So ReadCompleteErrorReport has nothing to do with the problem.

If you look a little closer you see methods with names like "ContextConfig.start" and "ContainerBase.start" and "Catalina.start". It's pretty clear that Tomcat is just starting up, and failing to parse your web.xml file because (as Paul Sturrock already said) it isn't valid according to the DTD.
 
Harish Tiruvile
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Paul Sturrock ,and Paul Clapham for replying

Now i resolved the issue...problem is with PrintWriter object....
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic