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

xml parser in tomcat

 
pingkan paula
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone, i'm still a newbie in JSP and XML and i'm currently using apache-tomcat 4.1 stand alone.
I've been developing application in cell-phone that can access the back-end database by using JSP as the middleware.
I have download open-source xml parser and place the jar file in common\lib and classes in common\endorsed.
When i run the jsp program ,the errors pointed that the xml parser package not exist.
Until now ,my application in cell-phone still failed to make a connection to jsp programs which i put in webapp\examples.

can anyone help me with this problem?

cheers
paula
 
Guido Schoepp
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pingkan paula:
I've been developing application in cell-phone that can access the back-end database by using JSP as the middleware.
I have download open-source xml parser and place the jar file in common\lib and classes in common\endorsed.
When i run the jsp program ,the errors pointed that the xml parser package not exist.
Until now ,my application in cell-phone still failed to make a connection to jsp programs which i put in webapp\examples.


Placing the jar file in common\lib should work. But you should put jar and class files belonging to your app in your app's WEB-INF directory:
%TOMCAT_HOME%\webapps\examples\WEB-INF\lib and %TOMCAT_HOME%\webapps\examples\WEB-INF\classes

Maybe your open source xml parser depends on other packages.

Guido
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Java version 1.4 - there is already a set of XML parser related packages that will come first in your classpath. Any particular reason not to use them?
Bill
 
pingkan paula
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just found that there is no lib directory when i go to
webapp\examples\WEB_INF , do i have to make a further setting?
I use kxml from kxml.org because it's recomended for wireless
development.I also check in common\lib there is no jar for xml parser
except the one i just added.
 
Guido Schoepp
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pingkan paula:
webapp\examples\WEB_INF


It is not WEB_INF but WEB-INF.

Guido
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You still didn't say which version of Java you are using.
If you are using Java 1.4 you may have to specify the system property javax.xml.parsers.DocumentBuilderFactory to point to the kxml parser rather than the default.
Yes you will need a WEB-INF/lib directory for the jar file.
Bill
[ November 14, 2004: Message edited by: William Brogden ]
 
pingkan paula
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes,i'm using jdk 1.4.1 ,could you briefly explain the configuration?

thanx
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes,i'm using jdk 1.4.1 ,could you briefly explain the configuration?

I have never tried to switch to using another parser package so you will have to explore the documentaton and do some experimenting.
You can define properties for tomcat as JAVA_OPTS in the catalina.bat file like this example - it is the first executable line in catalina.bat.


Bill
 
pingkan paula
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've set Djava.endorsed.dirs="$CATALINA_HOME"/common/endorsed \
in catalina.bat according to the documentation , but still no joy
This is the errors displayed,

org.apache.jasper.JasperException: org/kxml/parser/AbstractXmlParser
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

javax.servlet.ServletException: org/kxml/parser/AbstractXmlParser
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
at org.apache.jsp.updateSession_jsp._jspService(updateSession_jsp.java:96)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)


anyone knows about the errors?

paula
 
pingkan paula
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyway , is it possible to set the catalina-policy in conf to enable
other xml parser to run in tomcat?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
catalina.policy only sets security policy and has nothing to do with what you need.
Try to extract more exception information closer to the point where the parser is configured. Here is an example of what I use:

Bill
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the release notes (always a pleasure to find those!) it talks about XML parsers and Tomcat (and more generally, in Java).

http://apache.sunsite.ualberta.ca/jakarta/tomcat-4/v4.1.31/RELEASE-NOTES

Search for the 3rd occurence of the word "Parsers" in that document.
 
pingkan paula
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank's , i just put the classes and jar in common/shared
and i got this error ,is this mean i have a wrong xml configuration?

org.apache.jasper.JasperException: Document has no root element!
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

cheers


paula
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It appears that your program is getting as far as trying to parse an XML document and is getting the "Document has no root element" exception from the parser. It is time for you to look carefully at the text you are trying to parse.
Bill
 
Carl Wilburn
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could test/validate your xml by going to one of the web sites that do that sort of thing: http://www.stg.brown.edu/service/xmlvalid/

this would at least let you know if your xml is well foremd.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic