You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Mark Lundquist <lu...@gmail.com> on 2008/08/16 20:03:05 UTC

Cocoon EntityResolver + xerces

Hi, I've been debugging a problem with an older Cocoon (2.1.8)  
application.  There was a sporadic bug that turned out to be the  
consequence of a swallowed exception in a piece of code that some  
other guy wrote.  I also noticed that this piece of code, which parses  
some XML fragments, was horribly slow, and that there was no  
EntityResolver set on the parser.  So I fixed the swallowed exception,  
and while I was at it, I set the parser to use Cocoon catalog-based  
EntityResolver.

The result is that (a) this bottleneck runs about 3 times faster,  
although it's still slower than I'd like it to be, and (b) about every  
10-12 times that I ran it last night, it would still die with a (no  
longer swallowed!) java.net.ConnectException.  I think this is the  
exception that was getting buried before.

So anyway, the question is: why am I still getting network errors now  
that I'm using the Cocoon EntityResolver?  The stack trace looks like  
this:

Caused by: java.net.ConnectException: Connection refused
     at java.net.PlainSocketImpl.socketConnect(Native Method)
     at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
     at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java: 
195)
     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
     at java.net.Socket.connect(Socket.java:520)
     at java.net.Socket.connect(Socket.java:470)
     at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
     at sun.net.www.http.HttpClient.openServer(HttpClient.java:387)
     at sun.net.www.http.HttpClient.openServer(HttpClient.java:522)
     at sun.net.www.http.HttpClient.&lt;init&gt;(HttpClient.java:231)
     at sun.net.www.http.HttpClient.New(HttpClient.java:304)
     at sun.net.www.http.HttpClient.New(HttpClient.java:321)
     at  
sun 
.net 
.www 
.protocol 
.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:813)
     at  
sun 
.net 
.www 
.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java: 
765)
     at  
sun 
.net 
.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:690)
     at  
sun 
.net 
.www 
.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java: 
934)
     at  
org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown  
Source)
     at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown  
Source)
     at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown  
Source)
     at org.apache.xerces.impl.XMLDTDScannerImpl.startPE(Unknown Source)

My DTD looks like this:

<!DOCTYPE xhtml-fragment
[
  <!ENTITY % HTMLlat1 PUBLIC
    "-//W3C//ENTITIES Latin 1 for XHTML//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">
  %HTMLlat1;
  <!ENTITY % HTMLspecial PUBLIC
     "-//W3C//ENTITIES Special for XHTML//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent">
   %HTMLspecial;
]>

I looked at the Xerces source code and found that my EntityResolver is  
invoked by XMLEntityManager.resolveEntity(), but not by  
XMLEntityManager.startEntity() which is what is being called by  
XMLDTDScannerImpl.startPE(), which is what's trying to make the  
network connection... for whatever that's worth.

Any ideas?

thx-a-lot
—ml—



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon EntityResolver + xerces

Posted by Mark Lundquist <lu...@gmail.com>.
On Aug 16, 2008, at 11:03 AM, Mark Lundquist wrote:

>
> Hi, I've been debugging a problem with an older Cocoon (2.1.8)  
> application.  There was a sporadic bug that turned out to be the  
> consequence of a swallowed exception in a piece of code that some  
> other guy wrote.  I also noticed that this piece of code, which  
> parses some XML fragments, was horribly slow, and that there was no  
> EntityResolver set on the parser.  So I fixed the swallowed  
> exception, and while I was at it, I set the parser to use Cocoon  
> catalog-based EntityResolver.
> [snip...]

Actually,  I just now changed it to look up the SAXParser component  
(an Excalibur JaxpParser) which, as I figured out, automatically gets  
the entity resolver (instead of the XMLReaderFactory as it was using  
before).

Anyway, same result... every so often I get a network error thrown  
from the bowels of Xerces.

Any help gratefully appreciated!
—ml—


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org