This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Tomcat and the fly likes xml parser in tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "xml parser in tomcat" Watch "xml parser in tomcat" New topic
Author

xml parser in tomcat

pingkan paula
Ranch Hand

Joined: Sep 03, 2004
Posts: 117
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

Joined: Oct 14, 2004
Posts: 21
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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Sep 03, 2004
Posts: 117
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

Joined: Oct 14, 2004
Posts: 21
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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Sep 03, 2004
Posts: 117
Yes,i'm using jdk 1.4.1 ,could you briefly explain the configuration?

thanx
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Sep 03, 2004
Posts: 117
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

Joined: Sep 03, 2004
Posts: 117
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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Feb 20, 2001
Posts: 3695

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

Joined: Sep 03, 2004
Posts: 117
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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Jun 17, 2004
Posts: 9
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.


Live, learn and do!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: xml parser in tomcat
 
Similar Threads
Problem with tomcat 5.0.24 + j2sdk1.4.1_02
how web server(tomcat) can reponse to request coming from cell phone simulator
how web server(tomcat) can reponse to request coming from cell phone simulator
how web server(tomcat) can reponse to request coming from cell phone simulator
Doing JSP for Cell Phone Web Site - What Protocol? WAP? XHTML?