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.
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.
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".
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.
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;