2

XML over XSD スキーマの検証中に TimeoutException が発生し、チェッカーに関連付けられたスレッドがハングします。

なぜそうなのですか?これを回避する方法は?

スタックトレース:

TimeoutManage I   WTRN0124I: When the timeout occurred the thread with which the transaction is, or was most recently, associated was Thread[WebContainer : 3,5,main].  The stack trace of this thread when the timeout occurred was:
        java.net.SocketInputStream.socketRead0(Native Method)
        java.net.SocketInputStream.read(SocketInputStream.java:140)
        java.io.BufferedInputStream.fill(BufferedInputStream.java:229)
        java.io.BufferedInputStream.read1(BufferedInputStream.java:269)
        java.io.BufferedInputStream.read(BufferedInputStream.java:328)
        sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:700)
        sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:645)
        sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1205)
        org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
        org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
        org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
        org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
        org.apache.xerces.impl.xs.opti.SchemaDOMParser.parse(Unknown Source)
        org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source)
        org.apache.xerces.impl.xs.traversers.XSDHandler.resolveSchema(Unknown Source)
        org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source)
        org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
        org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
        org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
        org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
        org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source)
        javax.xml.validation.SchemaFactory.newSchema(Unknown Source)
        my.utils.XmlUtils.validate(XmlUtils.java:38)

検証に使用されるコード スニペット:

SchemaFactory schemaFactory = 
    SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
try {
    Schema schema = schemaFactory.newSchema(new StreamSource(new StringReader(xsd)));
    Validator validator = schema.newValidator();
...

次の行で例外が発生します。

Schema schema = schemaFactory.newSchema(new StreamSource(new StringReader(xsd)));
4

2 に答える 2

4

実際の XSD を見ないとわかりませんが、ほとんどの場合、スキーマは自己完結型ではなく、外部 URL を参照する 1 つ以上のincludeステートメントを含んでいます。schemaFactory は、完全な XSD を構築するためにそれらを取得しようとする場合があります。

これを示しているのは、とりわけ、渡した xsdgetSchemaDocument()で実行中に HTTP 経由でスキーマ ドキュメントを取得しようとしているスタック トレース内の への呼び出しです。parseSchema()

于 2012-09-16T13:23:12.893 に答える
1

XML名前空間のスキーマなど、スキーマがW3CWebサイト上のドキュメントを参照している場合に特定の問題が発生します。W3Cは、過度の使用を思いとどまらせるために、そのような要求への応答を意図的に遅らせます。アイデアは、ファイルのローカルコピーを使用するようにそのような参照をリダイレクトする必要があるということです。

于 2012-09-16T21:56:21.310 に答える