[jdom-interest] Newbie can't parse document!
Matthew MacKenzie
matt at xmlglobal.com
Wed Mar 7 09:23:12 PST 2001
Alex,
Well, the reality is that many customers have proxy servers...so it probably
makes sense to use a properties file containing this and other info that you
can set in your constructor. I know that its a pain in the butt just for
this reason though.
What parser are you using, and can anyone else suggest a way to make this
parser not resolve external entities? The only time I ever disabled the
resolution of external entities was in Perl (XML::Parser/expat).
--
Matthew MacKenzie
VP Research & Development
XML Global Technologies, Inc.
-----Original Message-----
From: Alex Colic [mailto:alex.colic at pop-ware.com]
Sent: March 7, 2001 9:15 AM
To: Matthew MacKenzie
Subject: Re: [jdom-interest] Newbie can't parse document!
Well, well, that was the solution.
But, I was hopping that builder(false) or builder.setValidation(false)
would bypass the dtd.
I can't distribute a class to customers if I have to worry about setting
up the properties for a proxyserver and host.
Is there a way to get around this?
Alex
----- Original Message -----
From: Matthew MacKenzie
To: Alex Colic
Sent: Wednesday, March 07, 2001 12:03 PM
Subject: RE: [jdom-interest] Newbie can't parse document!
Okay, do you have a HTTP proxy? If so, try doing this at the start of
your class:
Properties props = System.getProperties();
props.put("http.proxyHost", "my.proxyhost.com");
props.put("http.proxyPort", "8080");
(make sure you customize the values).
--Matthew MacKenzieVP Research & DevelopmentXML Global Technologies, Inc.
-----Original Message-----
From: Alex Colic [mailto:alex.colic at pop-ware.com]
Sent: March 7, 2001 9:04 AM
To: Matthew MacKenzie
Subject: Re: [jdom-interest] Newbie can't parse document!
Hi,
you are right. I took the:
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
out of the web.xml file and it parsed correctly.
This works but this does not seem correct. Is this a bug in the
parser?
Alex
----- Original Message -----
From: Matthew MacKenzie
To: Alex Colic
Sent: Wednesday, March 07, 2001 11:55 AM
Subject: RE: [jdom-interest] Newbie can't parse document!
I am not sure if that is the problem, because I was able to connect
to the URL below. Why not try commenting out the DTD reference and see is
the problem persists before blaming validation :-) I don't know what else
would be trying to connect, unless you are connecting somewhere in your
file. It is possible that the underlying parser is trying to grab the DTD
unsuccessfully because of your proxy server.
--
Matthew MacKenzie
VP Research & Development
XML Global Technologies, Inc.
-----Original Message-----
From: Alex Colic [mailto:alex.colic at pop-ware.com]
Sent: March 7, 2001 8:50 AM
To: Matthew MacKenzie
Subject: Re: [jdom-interest] Newbie can't parse document!
Hi, thanks for the reply.
The file I am using is the standard web.xml file used by Tomcat.
It does have a DTD:
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
I thought if I created the builder with the (false) constructor it
would bypass the above. Is my thinking incorrect?
I tried to ping java.sun.com but that failed do to our use of a
proxy server.
Is the above my problem?
Alex
----- Original Message -----
From: Matthew MacKenzie
To: Alex Colic ; jdom-interest at jdom.org
Sent: Wednesday, March 07, 2001 11:39 AM
Subject: RE: [jdom-interest] Newbie can't parse document!
Does the XML file in question contain a reference to a DTD or
Schema that is located on a server that does not resolve to an IP (aka does
not exist)??
--
Matthew MacKenzie
VP Research & Development
XML Global Technologies, Inc.
-----Original Message-----
From: jdom-interest-admin at jdom.org
[mailto:jdom-interest-admin at jdom.org]On Behalf Of Alex Colic
Sent: March 7, 2001 8:16 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] Newbie can't parse document!
Hi, I am new to using JDOM. I think I have done everything
correctly to create a SAXBuilder but I am getting an exception. I created a
FileInputStream and passing a File object, the same that I am passing to the
SAXBuilder, I can read and print the file to the screen.
My code is as follows:
String
directory="C:\\JBuilder4\\Projects\\pwWorkRequest\\src\\WEB-INF\\";
String file="web.xml";
File f=new File(directory + file);
FileInputStream fis=new FileInputStream(f);
int n;
while ((n=fis.available()) >0)
{
byte[] b=new byte[n];
int results=fis.read(b);
if(results==-1) break;
String s=new String(b);
System.out.print(s);
}
This works OK.
But this causes an exception:
SAXBuilder builder=new SAXBuilder(false);
Document doc=builder.build(f);
The exception message is:
java.sun.com: java.sun.com
The printstack trace:
org.jdom.JDOMException: java.sun.com: java.sun.com
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:320)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:373)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
at test.main(test.java:52)
Root cause: java.net.UnknownHostException: java.sun.com
at java.net.InetAddress.getAllByName0(InetAddress.java:571)
at java.net.InetAddress.getAllByName0(InetAddress.java:540)
at java.net.InetAddress.getByName(InetAddress.java:449)
at java.net.Socket.<init>(Socket.java:100)
at sun.net.NetworkClient.doConnect(NetworkClient.java:50)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:331)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:517)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:277)
at sun.net.www.http.HttpClient.New(HttpClient.java:289)
at
sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:3
79)
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection
.java:472)
at java.net.URL.openStream(URL.java:798)
at
org.apache.xerces.readers.DefaultReaderFactory.createReader(DefaultReaderFac
tory.java:149)
at
org.apache.xerces.readers.DefaultEntityHandler.startReadingFromExternalEntit
y(DefaultEntityHandler.java:747)
at
org.apache.xerces.readers.DefaultEntityHandler.startReadingFromExternalSubse
t(DefaultEntityHandler.java:566)
at
org.apache.xerces.framework.XMLDTDScanner.scanDoctypeDecl(XMLDTDScanner.java
:1131)
at
org.apache.xerces.framework.XMLDocumentScanner.scanDoctypeDecl(XMLDocumentSc
anner.java:2177)
at
org.apache.xerces.framework.XMLDocumentScanner.access$0(XMLDocumentScanner.j
ava:2133)
at
org.apache.xerces.framework.XMLDocumentScanner$PrologDispatcher.dispatch(XML
DocumentScanner.java:882)
at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java:380)
at
org.apache.xerces.framework.XMLParser.parse(XMLParser.java:861)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:302)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:373)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
at test.main(test.java:52)
Any help in figuring out what is going on is appreciated.
Regards
Alex Colic
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20010307/2b78b04b/attachment.htm
More information about the jdom-interest
mailing list