Details
-
Type:
Wish
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Labels:None
-
Environment:Java 1.5, Weblogic 9.2, wstx-asl-3.2.4.jar
-
Number of attachments :0
Description
Please add an option (e.g. system property) to suppress the dtd download. See also: http://www.nabble.com/IOException-when-reading-external-dtd%27s-tt10716015.html#a10716015
<01.10.2008 0.00 Uhr MEST> <Warning> <HTTP> <BEA-101196> <[weblogic.servlet.internal.WebAppServletContext@11bee48 - appName: 'myapp', name: '/myapp', context-path: '/myapp', version: 2.9.35rc1]: Error while parsing the Tag Library Descriptor
at "/bea9.2.0/user_projects/domains/myappprod7001/servers/AdminServer/tmp/_WL_user/myapp_2.9.35rc1/3gk64f/war/WEB-INF/struts-html.tld".
com.ctc.wstx.exc.WstxIOException: Tried all: '1' addresses, but could not connect over HTTP to server: 'java.sun.com', port: '80'
at com.ctc.wstx.sr.StreamScanner.throwFromIOE(StreamScanner.java:683)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1086)
at weblogic.servlet.internal.WebAppHelper.addListenerElements(WebAppHelper.java:252)
at weblogic.servlet.internal.WebAppHelper$IOHelperImpl.parseXML(WebAppHelper.java:224)
at weblogic.descriptor.DescriptorCache.parseXML(DescriptorCache.java:324)
Truncated. see log file for complete stacktrace
java.net.ConnectException: Tried all: '1' addresses, but could not connect over HTTP to server: 'java.sun.com', port: '80'
at weblogic.net.http.HttpClient.openServer(HttpClient.java:320)
at weblogic.net.http.HttpClient.openServer(HttpClient.java:375)
at weblogic.net.http.HttpClient.<init>(HttpClient.java:149)
at weblogic.net.http.HttpClient.New(HttpClient.java:245)
at weblogic.net.http.HttpURLConnection.connect(HttpURLConnection.java:160)
Truncated. see log file for complete stacktrace
>
Activity
As mentioned in the mailinglist thread this is not possible, if you have no control over the XMLInputFactory. In my case I'm using Woodstox indirectly through CXF.
The issue is known at BEA Systems but they have no solution for it. So the easiest way seems to deactivate the DTD-Download through a system property.
https://support.bea.com/utils/viewClarifyDoc/ViewClarifyDocController.jpf?answerpage=bug&page=wls/CR367909.htm
DESCRIPTION:
When Filtering ClassLoader is configured on application and a Stream Parser's Impl is included in application, it seems the Stream Parser's Impl is used for parsing TLD files.
WLS' default Stream Parser does not use DTD for parsing XML. However, if the Stream Parser's Impl validates TLD files by using DTD, the Stream Parser's Impl tries to download DTD file from java.sun.com. So, if WLS cannot access to Internet by network policy, WLS fails to parse TLD files as follows:
IMPACT:
If OS' TCP timeout value is large, deployment takes long time until the parse error.
CONFIGURATION:
WebLogic Server 9.2 with Maintenance Pack 1
WORKAROUND:
BEA is currently unaware of any satisfactory workaround for this issue.
Ok. Apologies for not reading through the referenced resource.
Now, I think it may be possible to make this work with Woodstox anyway, but I will have to check details.
Internally Woodstox does create copy of factory's config object to be used by reader (so that any further changes to factory settings do not affect instances). But it may also give access to per-reader configuration.
If you want to have a look, check out BasicStreamReader (and if nothing there, its super-class, StreamScanner). I do know there is 'getProperty' call, part of Stax API. But whether there is either a set method (which is not part of Stax API), or accessor that gives you Woodstox ReaderConfig (which does have mutators to allow you chaneg values) I do not remember.
Apologies for not having more details – I will provide more when I have time to look into this.
And yes, it does seem like a use case that should be supported: while there may be properties that can not be changed once stream reader/writer instance is constructed (for example because different impl class is chosen), this depends on property-by-property basis, as well as implementation.
Checked out the code from svn and found out that ReaderConfig is a member variable (mConfig) of StreamScanner. Anyway I'm not sure where to do the check for the system property.
We are in luck here: Stax2 API has XMLStreamReader2.setProperty() method, see:
This should work as long as you can either rely on Woodstox (well, technically any stax2 implementation, but the only other one I know of is Aalto), or at least dynamically check that stream reader is of type XMLStreamReader2 (stax2 type).
Anyway, setProperty() of reader recognizes the same set of properties as factory's method: the only caveat is that not all of them can be effectively changed (as in, trying to change value having any effect once instance is created).
So: of 2 obvious choices (SUPPORT_DTD, RESOLVER), I'm pretty sure setting of RESOLVER works for reader instance. I am not sure if SUPPORT_DTD can currently be changed dynamically; but if not, it should be easy to change it. So if you could try them out and let me know what works and what doesn't, that would be awesome.
Dennis, any chance you could try XMLStreamReader2.setProperty()? It should resolve your problem I think.
Weblogic is doing the xml stuff, so I have no chance to do the call in my application.
The suggestion was to set the SUPPORT_DTD or RESOLVER thing in woodstox depending on a system property or something else. Where would be the right place to do this in woodstox? I'll try to provide a patch then.
Ok. I thought the problem was that you didn't have access to the factory, but did have access to XMLStreamReader.
This would have been resolved by modifiers in reader instance.
At this point I am beginning to wonder if the problem really needs to be tackled by WebLogic proper, if it is in full control of situation, and application has very limited options.
As to system properties: in my opinion, global settings such as system properties are best avoided, since their use often leads to problems which are hard to diagnose: in multi-threaded systems one thread modifies value temporarily, observed by other threads.
This is why Woodstox does not use system properties, and I do not intend to add support for them in the core code.
But I would not be against contributions that add such capabilities: for example, one possibility would be to have sub-classes of default Woodstox input/output factories. It could be added to Woodstox home page as a useful extension.
Now, one immediate problem with this that I noticed is that as of 3.2.7, WstxInputFactory and WstxOutputFactory are defined as final. I opened another Jira entry (WSTX-172) to address this, and checked in the fix.
Created a support case at BEA Systems/ Oracle refering to this jira issue. I'd like to know their opinion because the weblogic implementation seems to be the root cause of the problem.
Got a reply from BEA:
I have tested your application and I am able to reproduce the error. I went through http://jira.codehaus.org/browse/WSTX-168 and I agree about what has been discussed. Also I agree to say that system properties should be avoided in this case. So it will be difficult to fix it programatically.
I have checked the java code in WLS and there is no option to avoid the dtd checking. It will be difficult to integrate such option because it means we will disable all dtds for all applications.
In WebAppHelper.addListenerElements we have the following code:
XMLInputFactory _factory = XMLInputFactory.newInstance();
XMLStreamReader parser = _factory.createXMLStreamReader(is);
Now we are facing this issue because the following jar contains this entry com.ctc.wstx.stax.WstxInputFactory. So it will use this factory instead of WLS one (weblogic.xml.stax.XMLStreamInputFactory).
wstx-asl-3.2.4.jar contains META-INF/services/javax.xml.stream.XMLInputFactory
We have the following solutions
1- Of course, if we are sure the tld is correctly build, remove the dtd declaration
2- specify a physical file
<!DOCTYPE taglib SYSTEM "file:///C:/tmp/Cases/Cases/web-jsptaglibrary_1_1.dtd">
<!DOCTYPE taglib SYSTEM "web-jsptaglibrary_1_1.dtd"> it will look for the file in the domain directory
3- specify a local url destination
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://localhost:7001/MyDtdWebApp/web-jsptaglibrary_1_1.dtd">
4- specify -Djavax.xml.stream.XMLInputFactory=weblogic.xml.stax.XMLStreamInputFactory . It will not check the dtds at deployment. But I am consious it requires new tests to avoid unexpedted behaviors.
5- you can also specify -Dhttp.proxyHost=<host> -Dhttp.proxyPort=<port> if this is just a proxy issue
Thank you for following up on this. Yes, it is a tricky problem. None of solutions offered seems particularly tempting.
One thing that BEA might consider though would be to specify XMLResolver for the stream reader. That could be used to basically suppress use of DTD – resolver could just return dummy reader/stream that returns no content. This is valid empty DTD subset, and given that it sounds like they have no use for DTD, should not have any adverse effect.
I think this should work quite well – they can set it for that instance of factory, it's not Woodstox-specific (XMLInputFactory.XML_REPORTER is defined by Stax 1.0), and should be supported (even if ignored) by all Stax implementations.
I've just got into similar problem with being unable to start Tomcat application. Currently XML configuration files are often used and they often contains link to external DTD/XSL resources. And users don't expect for server to download some external files on startup and fail if the file is not accessible.
Here is my stack trace for the record:
19 квіт 2011 15:06:08 org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
19 квіт 2011 15:06:29 org.apache.tomcat.util.digester.Digester fatalError
SEVERE: Parse Fatal Error at line 18 column 1: Время ожидания соединения истекло
com.ctc.wstx.exc.WstxIOException: Время ожидания соединения истекло
at com.ctc.wstx.sax.WstxSAXParser.throwSaxException(WstxSAXParser.java:1094)
at com.ctc.wstx.sax.WstxSAXParser.parse(WstxSAXParser.java:456)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1543)
at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:553)
at org.apache.catalina.startup.TldConfig.tldScanWebXml(TldConfig.java:383)
at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:299)
at org.apache.catalina.startup.TldConfig.lifecycleEvent(TldConfig.java:585)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4900)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:570)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1010)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:933)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:468)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1267)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:308)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:328)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:308)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1043)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:738)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1035)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:289)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:442)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:674)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.startup.Catalina.start(Catalina.java:596)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
Caused by: com.ctc.wstx.exc.WstxIOException: Время ожидания соединения истекло
at com.ctc.wstx.sr.StreamScanner.throwFromIOE(StreamScanner.java:672)
at com.ctc.wstx.sr.ValidatingStreamReader.findDtdExtSubset(ValidatingStreamReader.java:460)
at com.ctc.wstx.sr.ValidatingStreamReader.finishDTD(ValidatingStreamReader.java:336)
at com.ctc.wstx.sr.BasicStreamReader.finishToken(BasicStreamReader.java:3691)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2044)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1106)
at com.ctc.wstx.sax.WstxSAXParser.fireEvents(WstxSAXParser.java:515)
at com.ctc.wstx.sax.WstxSAXParser.parse(WstxSAXParser.java:452)
... 38 more
Caused by: java.net.ConnectException: Время ожидания соединения истекло
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
at java.net.URL.openStream(URL.java:1010)
at com.ctc.wstx.util.URLUtil.inputStreamFromURL(URLUtil.java:111)
at com.ctc.wstx.io.DefaultInputResolver.sourceFromURL(DefaultInputResolver.java:254)
at com.ctc.wstx.io.DefaultInputResolver.resolveEntity(DefaultInputResolver.java:92)
at com.ctc.wstx.sr.ValidatingStreamReader.findDtdExtSubset(ValidatingStreamReader.java:451)
... 44 more
19 квіт 2011 15:06:29 org.apache.catalina.startup.TldConfig tldScanWebXml
WARNING: Failed to process TLD with path http://tomcat.apache.org/example-taglib and URI [/WEB-INF/jsp/example-taglib.tld]
java.io.IOException: com.ctc.wstx.exc.WstxIOException: Время ожидания соединения истекло
at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:556)
at org.apache.catalina.startup.TldConfig.tldScanWebXml(TldConfig.java:383)
at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:299)
at org.apache.catalina.startup.TldConfig.lifecycleEvent(TldConfig.java:585)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4900)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:570)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1010)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:933)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:468)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1267)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:308)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:328)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:308)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1043)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:738)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1035)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:289)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:442)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:674)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.startup.Catalina.start(Catalina.java:596)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
Caused by: com.ctc.wstx.exc.WstxIOException: Время ожидания соединения истекло
at com.ctc.wstx.sax.WstxSAXParser.throwSaxException(WstxSAXParser.java:1094)
at com.ctc.wstx.sax.WstxSAXParser.parse(WstxSAXParser.java:456)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1543)
at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:553)
... 36 more
Caused by: com.ctc.wstx.exc.WstxIOException: Время ожидания соединения истекло
at com.ctc.wstx.sr.StreamScanner.throwFromIOE(StreamScanner.java:672)
at com.ctc.wstx.sr.ValidatingStreamReader.findDtdExtSubset(ValidatingStreamReader.java:460)
at com.ctc.wstx.sr.ValidatingStreamReader.finishDTD(ValidatingStreamReader.java:336)
at com.ctc.wstx.sr.BasicStreamReader.finishToken(BasicStreamReader.java:3691)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2044)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1106)
at com.ctc.wstx.sax.WstxSAXParser.fireEvents(WstxSAXParser.java:515)
at com.ctc.wstx.sax.WstxSAXParser.parse(WstxSAXParser.java:452)
... 38 more
Caused by: java.net.ConnectException: Время ожидания соединения истекло
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
at java.net.URL.openStream(URL.java:1010)
at com.ctc.wstx.util.URLUtil.inputStreamFromURL(URLUtil.java:111)
at com.ctc.wstx.io.DefaultInputResolver.sourceFromURL(DefaultInputResolver.java:254)
at com.ctc.wstx.io.DefaultInputResolver.resolveEntity(DefaultInputResolver.java:92)
at com.ctc.wstx.sr.ValidatingStreamReader.findDtdExtSubset(ValidatingStreamReader.java:451)
... 44 more
Vitalii, did you read the earlier discussion? There are multiple ways to suppress DTD download, so hopefully you can use them.
Specifically easy way is to configure factory:
xmlInputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE)
The problem is not in my code. It's container that can't pick up libraries because woodstox become default XML parser for the system and it won't allow to read any configuration file that contains meta-data (e.g. DTD) references to external URIs.
Then you need to file a bug report for container. Woodstox has to resolve DTD reference as per XML specification, unless DTD processing is disabled.
Sorry, it is about StAX, while I am about SAX. I still can fill another issue.
By default validation should be disabled, as per setValidating javadoc:
"Specifies that the parser produced by this code will validate documents as they are parsed. By default the value of this is set to false."
And it says it is disabled, but it still tries to fetch it:
public class WstxTest {
private WstxSAXParserFactory factory = new WstxSAXParserFactory();
@Test
public void testDefaultFlagValues() throws SAXNotSupportedException, SAXNotRecognizedException
@Test
public void testDtdRef() throws IOException, SAXException
}
This code gives OK for testDefaultFlagValues, but gives:
Resolve called, -> org.xml.sax.helpers.DefaultHandler@1d80e6d
com.ctc.wstx.exc.WstxIOException: somewhere.ccc
at com.ctc.wstx.sax.WstxSAXParser.throwSaxException(WstxSAXParser.java:1173)
at com.ctc.wstx.sax.WstxSAXParser.parse(WstxSAXParser.java:541)
at com.ctc.wstx.sax.WstxSAXParser.parse(WstxSAXParser.java:307)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:198)
at ttt.WstxTest.testDtdRef(WstxTest.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:44)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.junit.runner.JUnitCore.run(JUnitCore.java:159)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:94)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:192)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
Caused by: com.ctc.wstx.exc.WstxIOException: somewhere.ccc
at com.ctc.wstx.sr.StreamScanner.throwFromIOE(StreamScanner.java:699)
at com.ctc.wstx.sr.ValidatingStreamReader.findDtdExtSubset(ValidatingStreamReader.java:480)
at com.ctc.wstx.sr.ValidatingStreamReader.finishDTD(ValidatingStreamReader.java:341)
at com.ctc.wstx.sr.BasicStreamReader.skipToken(BasicStreamReader.java:3341)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:1958)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1102)
at com.ctc.wstx.sax.WstxSAXParser.fireEvents(WstxSAXParser.java:600)
at com.ctc.wstx.sax.WstxSAXParser.parse(WstxSAXParser.java:537)
... 30 more
Caused by: java.net.UnknownHostException: somewhere.ccc
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
at java.net.URL.openStream(URL.java:1010)
at com.ctc.wstx.util.URLUtil.inputStreamFromURL(URLUtil.java:146)
at com.ctc.wstx.io.DefaultInputResolver.sourceFromURL(DefaultInputResolver.java:254)
at com.ctc.wstx.io.DefaultInputResolver.resolveEntity(DefaultInputResolver.java:92)
at com.ctc.wstx.sr.ValidatingStreamReader.findDtdExtSubset(ValidatingStreamReader.java:471)
... 36 more
for second test. It uses ValidatingStream reader, while validation is disabled. Tested on 4.1.1
Yes, it would make sense to have another issue if you could create one?
There is still one problem however: DTDs are actually needed for entity expansion as well, so just disabling validation (which should be disabled by default for both SAX and Stax) is not enough.
However, there needs to be a way to have equivalent of turning SUPPORT_DTD false.
BTW: Stax default value for javax.xml.stream.isValidating is also false.
It seems that there are two properties for Stax: javax.xml.stream.supportDTD and isValidating. While it's not perfectly clear the difference, there is a paragraph inside XMLStreamReader javadoc:
For XML 1.0 compliance an XML processor must pass the identifiers of declared unparsed entities, notation declarations and their associated identifiers to the application. This information is provided through the property API on this interface. The following two properties allow access to this information: javax.xml.stream.notations and javax.xml.stream.entities. When the current event is a DTD the following call will return a list of Notations List l = (List) getProperty("javax.xml.stream.notations"); The following call will return a list of entity declarations: List l = (List) getProperty("javax.xml.stream.entities"); These properties can only be accessed during a DTD event and are defined to return null if the information is not available.
As for me, supportDTD option should define if this getProperty calls are available, but parser by default (validating=false, supportDTD=true) must not fetch DTDs, or at least it must not use it for validation and fail if DTD is not available.
This also makes sence since it will prevent external fetches by default in many many many frameworks.
Created http://jira.codehaus.org/browse/WSTX-265
Did not know about entity expansion. It makes the whole my previous comment rather questionable.
Right, IS_VALIDATING is false by default as mandated by specification. SUPPORT_DTD on the other hand is mandated to be set to true by Stax specification (see XMLInputFactory javadocs). This is mostly since disabling this feature basically makes parser non-compliant with XML specification. XML specs actually allows skipping of reading of external DTD only in case where 'standalone' property is set to 'true'. This would be possible to do; the main challenge is that other XML parsers actually still read external DTD subset (Xerces, specifically), so to maximize compatibility Woodstox does not skip fetching unless SUPPORT_DTD is explicitly disabled.
I've also had problems with connection to java.sun.com while DTD parsing by weblogic.
Solution is quick and dirty, but works. Because you don't have control on weblogic deployment behaviour, you have to change XMLInputFactory service in woodstox.jar.
1. Subclass WstxInputFactory:
public class MyWstxInputFactory extends WstxInputFactory {
public SSTWstxInputFactory()
}
2. Change service definition to MyWstxInputFactory in:woodstox-core-asl-4.1.1.jar\META-INF\services\javax.xml.stream.XMLInputFactory
Don't know what potential impact that would have in the future, but for now most important is that weblogic is able to properly deploy application without spamming with WstxIOExceptions.
You can already do this by disabling property XMLInputFactory.SUPPORT_DTD, which prevents DTD (internal and external subsets) from being processed: dtd stuff will essentially just be skipped.
Alternatively you could add a XLMInputFactory.RESOLVER (instance of XMLResolver), to return empty String (that is, resolve to dummy external DTD). Latter may be needed if you still want to use internal DTD subset.
I hope one of approaches solves your problem; please let me know if this is not the case.