2

我在 Windows 7 上设置 java_opts -Xmx512M; 该文件大约 15Mb 并且在 XMLParsing 中失败 - 我从命令终端执行(它也在 groovyConsole 中超时)同一文件的短版本在 W 7 上正确执行

顺便说一句,未更改的 XML 代码在 24 秒内在 SunOS 64Bit 上正确执行。

  • 你能告诉我在Windows 7上我能做什么吗?

代码片段:

import groovy.util.XmlParser
import javax.xml.xpath.*
import groovy.time.*

inpXMLFile='c:/EnvFiles/CCC.xml'

entry=new File("$inpXMLFile")
assert   entry.exists()
println " ... file existence validated"

...

def node= new XmlParser().parse( new File( inpXMLFile ) ) // Line 23 

// .... the rest of the script

完整的跟踪包括在内:

... file existence validated

    Caught: java.net.ConnectException: Connection timed out: connect
      java.net.ConnectException: Connection timed out: connect
        at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:629)
        at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1291)
        at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:1258)
        at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:260)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1151)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1047)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:960)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
        at compCurrent.run(compCurrent.groovy:23)
4

1 回答 1

0

Looks like the error is accessing a DTD element and not related to large file size.

java.net.ConnectException: Connection timed out: connect
com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity

You have two options: 1. You can remove or comment out DTD reference and entities in your XML file, or 2. Disable parsing DTD and external entities on the XMLParser.

def parser = new XmlParser()
parser.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false)
parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
于 2012-12-13T03:25:55.627 回答