File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes MalformedURLException not understood Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "MalformedURLException not understood" Watch "MalformedURLException not understood" New topic
Author

MalformedURLException not understood

Philip Grove
Ranch Hand

Joined: Aug 18, 2009
Posts: 68

I don't know if this right subforum to write in since the post going across different topics.

Wrapped in a javax.xml.stream.XMLStreamException I get a java.net.MalformedURLException. Why is a mystery to me as any MalformedURLException thrown by constructing an URL object in the same method, which is later passed on, is caught separately and never occur. The situation is further complicated by the fact that the stack trace doesn't contain references to line numbers in my code.

The stack trace for the MalformedURLException looks like this:


The class dk.lokus.server.QXLCollector is my own code, but it is executed by putting instances of it in a queue that is assigned to a ThreadPoolExecutor. Along with the stack trace the URL is logged, and entering it in a browser just a few minutes after the exception happens leads to the file loading just fine. I have almost identical code (the code for opening the connection is identical, the URL and processing code is not) in other parts of the application and this code is the only that exhibits this behavior which leads me to suspect that it is somehow related to the combination of code and server.

I thought that I would ask for input here since I'm completely lost in regards to this situation but I need to figure it out as it threatens the stability of the entire application.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

The problem is caused by the XML reading part, in particular the entity handling (com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity). That method tries to create a URL but can't. I think you will have a bit more success in our XML forum. Moving there.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18712
    
    8

So the problem is not caused by a URL which you are creating, but by a URL which is in the XML document you are parsing. Accordingly you should look at that document and see if there are malformed URLs in it. The stack trace suggests the parser is processing "entities".
Philip Grove
Ranch Hand

Joined: Aug 18, 2009
Posts: 68

I suspect that the root of the problem is the behavior of the XMLStreamReader. Since the XMLStreamReader is created through the XMLInputFactory I have tried to set properties to stop it from resolving and replacing external entities. I have added these two lines to my code (of course before creating the XMLStreamReader) but it makes no difference at all:


I am completely new to StAX so if anybody could point me in the direction of a good source of information I would appreciate it.
alvaro saa
Greenhorn

Joined: Jun 12, 2011
Posts: 1
Rob Spoor wrote:The problem is caused by the XML reading part, in particular the entity handling (com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity). That method tries to create a URL but can't. I think you will have a bit more success in our XML forum. Moving there.



I made a crawer using StAX. The thing is that I didnĀ“t install JSR-173, You can download in softonic.com. So before I got this message:
Exception in thread "main" java.lang.NoSuchMethodError: com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.getNamespaceContext()Lcom/sun/org/apache/xerces/internal/xni/NamespaceContext;
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.<init>(XMLStreamReaderImpl.java:100)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.getXMLStreamReaderImpl(XMLInputFactoryImpl.java:264)
at com.sun.xml.internal.stream.XMLInputFactoryImpl.createXMLStreamReader(XMLInputFactoryImpl.java:131)

By alvaro.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: MalformedURLException not understood