문제

There is a Java Cocoon application that performs XSLT transformations using Saxon 8.7. One such xslt uses document function to inject the contents of the remote xml resource. So the invocation looks like the following: <xsl:apply-templates select="document(@href)/p-topic" mode="static-topic"/>

The remote document is accessible (tested with wget), no proxy is used for that remote host. However, I'm getting the following exception stack trace:

Caused by: org.apache.commons.lang.exception.NestableRuntimeException: net.sf.saxon.trans.DynamicError: net.sf.saxon.trans.DynamicError: java.net.ConnectException: Connection timed out
        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:519)
        at java.net.Socket.connect(Socket.java:469)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)

The time out happens after about 20 seconds.

Finally, the issue has appeared after moving the application to another server. On the initial server the same code works fine. So it depends on the environment.

Also I've analyzed netstat output. The following connections appear on XSLT transformation being run:

Proto Recv-Q Send-Q Local Address               Foreign Address             State       User       Inode      PID/Program name
tcp        0      1 ::ffff:134.27.100.67:37600  ::ffff:134.27.97.142:8510   SYN_SENT    22484/java
tcp     8559      0 ::ffff:134.27.100.67:55835  ::ffff:134.27.97.143:80     ESTABLISHED  22484/java

134.27.97.143:80 is the target remote xml resource location. I have no idea why SYN_SENT connection appears to another server.

After about 5 seconds the second connection changes to the following:

tcp     8560      0 ::ffff:134.27.100.67:55835  ::ffff:134.27.97.143:80     CLOSE_WAIT  22484/java

After about 15 seconds more (the browser times out now) the first connection disappears and the second connection changes to the following:

tcp     0      0 ::ffff:134.27.100.67:55835  ::ffff:134.27.97.143:80     CLOSE_WAIT  22484/java

After about 5 seconds more the second connection also disappears. I'm not a netstat expert but it seems suspicious that the Recv-Q value keeps non-zero value until the timeout happens. So it looks like the application hangs while reading the data from the TCP socket queue. I've tried different tomcats (5 and 6). Any ideas?

도움이 되었습니까?

해결책

Finally I've managed to identify the root cause. It's appeared that those remote documents have DOCTYPE declarations of DTD files. Those DTD files are not accessible from the new server while they are accessible from the old server. So it seems Saxon tries to download the DTDs for validation and fails to do it with "Connection timed out" exception.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top