(xpert is a package for all my classes)
I put in attachements the differents files who are responsibles of this
error.
The error appears in the method LoadXML in the DocXML.java file
the line wich is the cause of this problem is :
myReader.setErrorHandler(exh);
Thank you very much for your help
----- Original Message -----
From: "Shapira, Yoav" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Wednesday, November 05, 2003 2:50 PM
Subject: RE: Problem with JSP to access XML files
>
> Howdy,
> Post the relevant part of Users.java and DocXML.java.
>
> Yoav Shapira
> Millennium ChemInformatics
>
>
> >-----Original Message-----
> >From: Nicolas Fabry [mailto:[EMAIL PROTECTED]
> >Sent: Wednesday, November 05, 2003 2:34 PM
> >To: Tomcat Users List
> >Subject: Problem with JSP to access XML files
> >
> >Hello,
> >I have a problem since one week.
> >I have to upgrade an existing system working with JSP and XML files.
> >There is a login page written in .jsp and the login/password are
> written in
> >a XML file.
> >Any time I try tu access the system (by loggin), a compilation error
> >appear.
> >I'm using TOMCAT 4.1.29 and J2SDK 1.4.1_05.
> >It's a little bit long, but you can have a look just to the firsts
> lines of
> >the ROOT CAUSE (and the exception)
> >
> >
> >
> >
> >HTTP Status 500 -
> >
> >-----------------------------------------------------------------------
> ----
> >-
> >----
> >
> >type Exception report
> >
> >message
> >
> >description The server encountered an internal error () that prevented
> it
> >from fulfilling this request.
> >
> >exception
> >
> >org.apache.jasper.JasperException
> > at
> >org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.j
> ava:
> >2
> >54)
> > 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(Applic
> atio
> >n
> >FilterChain.java:247)
> > at
> >org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil
> terC
> >h
> >ain.java:193)
> > at
> >org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal
> ve.j
> >a
> >va:256)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(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(StandardContextVal
> ve.j
> >a
> >va:191)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(StandardPipeline.java:643)
> > at
> >org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticato
> rBas
> >e
> >.java:494)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(StandardPipeline.java:641)
> > 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.StandardContext.invoke(StandardContext.java:24
> 17)
> > at
> >org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav
> a:18
> >0
> >)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(StandardPipeline.java:643)
> > at
> >org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherV
> alve
> >.
> >java:171)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(StandardPipeline.java:641)
> > at
> >org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav
> a:17
> >2
> >)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(StandardPipeline.java:641)
> > 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.StandardEngineValve.invoke(StandardEngineValve
> .jav
> >a
> >:174)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(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.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)
> > at
> >org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:7
> 81)
> > at
> >org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process
> Conn
> >e
> >ction(Http11Protocol.java:549)
> > at
> >org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:5
> 89)
> > at
> >org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPoo
> l.ja
> >v
> >a:666)
> > at java.lang.Thread.run(Thread.java:536)
> >
> >
> >root cause
> >
> >java.lang.NullPointerException
> > at org.apache.xerces.parsers.AbstractSAXParser.setErrorHandler(Unknown
> >Source)
> > at xpert.DocXML.loadXML(DocXML.java:80)
> > at xpert.Users.checkLogin(Users.java:39)
> > at org.apache.jsp.measurer_jsp._jspService(measurer_jsp.java:57)
> > 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.j
> ava:
> >2
> >10)
> > 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(Applic
> atio
> >n
> >FilterChain.java:247)
> > at
> >org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil
> terC
> >h
> >ain.java:193)
> > at
> >org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal
> ve.j
> >a
> >va:256)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(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(StandardContextVal
> ve.j
> >a
> >va:191)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(StandardPipeline.java:643)
> > at
> >org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticato
> rBas
> >e
> >.java:494)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(StandardPipeline.java:641)
> > 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.StandardContext.invoke(StandardContext.java:24
> 17)
> > at
> >org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav
> a:18
> >0
> >)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(StandardPipeline.java:643)
> > at
> >org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherV
> alve
> >.
> >java:171)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(StandardPipeline.java:641)
> > at
> >org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav
> a:17
> >2
> >)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(StandardPipeline.java:641)
> > 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.StandardEngineValve.invoke(StandardEngineValve
> .jav
> >a
> >:174)
> > at
> >org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.
> invo
> >k
> >eNext(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.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)
> > at
> >org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:7
> 81)
> > at
> >org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process
> Conn
> >e
> >ction(Http11Protocol.java:549)
> > at
> >org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:5
> 89)
> > at
> >org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPoo
> l.ja
> >v
> >a:666)
> > at java.lang.Thread.run(Thread.java:536)
> >
> >
> >
> >-----------------------------------------------------------------------
> ----
> >-
> >----
> >
> >Apache Tomcat/4.1.29
> >
> >
> >It's maybe cause of the reference of the XML file. Have I to put
> >c:\path_to_wath_I_want or file://c:/path_to_wath_I_want? Have I to use
> >relatives links or not?
> >The XML file is like this :
> >
> > <?xml version="1.0" encoding="UTF-8" ?>
> >- <!-- edited with XMLSPY v5 U (http://www.xmlspy.com) by Alexandre
> >(Alexandre)
> > -->
> >- <users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >xsi:noNamespaceSchemaLocation="./Xsd/users.xsd">
> > <user login="nicolas" pswd="nicolas" status="admin" />
> > </users>
> >
> >
> >
> >Really thanks to help me resolve this problem
> >
> >Nicolas Fabry
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged. This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else. If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender. Thank you.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
package xpert;
import java.util.*;
import java.text.SimpleDateFormat;
import org.xml.sax.*;
public class Users extends DocXML {
private String login=null;
private String pswd=null;
private String dt=null;
private String status=null;
private String usersFile;
/** Creates a new instance of Users */
public Users() {
}
public Users(String url) {
usersFile=url;
}
public String checkLogin(String login, String pswd){
try{
this.login=login;
this.pswd=pswd;
loadXML(usersFile);
if(dt!=null) {
Date d=new SimpleDateFormat("yyyy-MM-dd").parse(dt);
if(d.compareTo(new Date())>=0){
return status;
}
else return null;
}
else return status;
} catch(java.text.ParseException p){
return null;
} catch(SAXException se){
return null;
} catch(javax.xml.parsers.ParserConfigurationException pe){
return null;
} catch(java.io.IOException io){
return null;
}
}
}
/*
* ErrorXMLHandler.java
*
* Created on 13 d�cembre 2002, 12:16
*/
package xpert;
import org.xml.sax.*;
import java.io.Writer;
/** Gestionnaire d'erreur permettant d'afficher les erreurs de v�rification
* des XML lus � travers une page HTML
* @author jvilz
*/
public class ErrorXMLHandler implements ErrorHandler {
private java.io.Writer out;
/** Creates a new instance of ErrorXMLHandler */
public ErrorXMLHandler() {
}
/**
* @param o l'objet de sortie des erreurs
*/
public ErrorXMLHandler(Writer o) {
out=o;
}
/** assigne l'objet de sortie des erreurs
*/
public void setWriter(Writer o){
out=o;
}
public void error(org.xml.sax.SAXParseException sAXParseException) throws org.xml.sax.SAXException {
try{
out.write("<P class=\"error\"> An error occurs in the file : " + sAXParseException.getSystemId()+"</P>");
out.write("<P class=\"error\">"+sAXParseException.getMessage()+"</P>");
}catch(java.io.IOException e){
e.printStackTrace(System.err);
}
}
public void fatalError(org.xml.sax.SAXParseException sAXParseException) throws org.xml.sax.SAXException {
try{
out.write("<P class=\"error\"> A fatal error occurs in the file : " + sAXParseException.getSystemId()+"</P>");
out.write("<P class=\"error\">"+sAXParseException.getMessage()+"</P>");
}catch(java.io.IOException e){
e.printStackTrace(System.err);
}
}
public void warning(org.xml.sax.SAXParseException sAXParseException) throws org.xml.sax.SAXException {
try{
out.write("<P class=\"error\"> A warning occurs in the file : " + sAXParseException.getSystemId()+"</P>");
out.write("<P class=\"error\">"+sAXParseException.getMessage()+"</P>");
}catch(java.io.IOException e){
e.printStackTrace(System.err);
}
}
}
/*
* DocXML.java
*
* Created on 26 novembre 2002, 09:56
*/
package xpert;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
/** Classe reprenant les m�thodes g�n�rales concernant les documents XML
* @author jvilz
*/
abstract public class DocXML extends DefaultHandler {
/** Nom de la propri�t� du parser XML concernant le type de validation
*/
final private String JAXP_SCHEMA_LANGUAGE ="http://java.sun.com/xml/jaxp/properties/schemaLanguage";
/** Type de validation pour le parser
*/
final private String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
/** lecteur de fichier XML
*/
protected XMLReader myReader;
/** le chemin et le nom du fichier XML ouvert
*/
protected String XMLFile;
/** Transformateur de fichier XML � partir d'un XSL
*/
protected Transformer transformer;
protected TransformerFactory tFactory;
/** error handler
*/
protected ErrorXMLHandler exh;
/** Creates a new instance of DocXML */
public DocXML() {
}
/** retourne le chemin du fichier XML ouvert
*/
public String getXMLFile(){
return XMLFile;
}
/** Attribue le gestionnaire d'erreur pour la lecture du fichier
* @param eh gestionnaire d'erreur
*/
public void setErrorHandler(ErrorXMLHandler eh){
exh=eh;
}
/** Charge un fichier XML
* @param xmlFile le chemin vers le fichier XML
* @param eh le gestionnaire d'erreur pour la lecture du fichier
*/
public void loadXML(String xmlFile, ErrorXMLHandler eh)throws SAXException,ParserConfigurationException,java.io.IOException {
exh=eh;
loadXML(xmlFile);
}
/** Charge un fichier XML
* @param xmlFile le chemin vers le fichier XML
*/
public void loadXML(String xmlFile) throws SAXException,ParserConfigurationException,java.io.IOException {
XMLFile=xmlFile;
//try {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
SAXParser saxParser = factory.newSAXParser();
saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
myReader = saxParser.getXMLReader();
myReader.setContentHandler(this);
myReader.setErrorHandler(exh);
myReader.parse(xmlFile);
/* } catch (SAXException e) {
System.err.println(e.getMessage());
}
catch (javax.xml.parsers.ParserConfigurationException z) {
System.err.println(z.getMessage());
}
catch (java.io.IOException y) {
System.err.println(y.getMessage());
}*/
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]