解决异常:Parser has reached the entity expansion limit "64,000" set by the Application

异常:分析器已达到由应用程序设置的实体扩展限制"64,000"

用JDOM分析一个超大的xml文件,大概20M,估计有很多Elements:

  SAXBuilder saxbuilder = null;
  Document doc_all=null;

  saxbuilder = new SAXBuilder(); // 新建立构造器
  
  try {
   FileInputStream xmlfile=new FileInputStream("verybig.xml");
   doc_all=saxbuilder.build(xmlfile); // 读入文件
  } catch (FileNotFoundException e) {
   System.err.println("缺少文件!请检查");
   System.exit(-1);
  } catch (JDOMException e) {
   System.err.println("解析XML模板文件出错!请检查");
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }

抛出异常:
reached the entity expansion limit "64,000" set by the Application.
        at TErrorHandler.fatalError(XMLError.java:198)
        at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3342)
        at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3333)
        at org.apache.crimson.parser.Parser2.expandEntityInContent(Parser2.java:2667)
        at org.apache.crimson.parser.Parser2.maybeReferenceInContent(Parser2.java:2569)
        at org.apache.crimson.parser.Parser2.content(Parser2.java:1980)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
        at org.apache.crimson.parser.Parser2.content(Parser2.java:1926)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1654)
        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:634)
        at org.apache.crimson.parser.Parser2.parse(Parser2.java:333)
        at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
        at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:185)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:76)
        at XMLError.DOMRead(XMLError.java:101)
        at XMLError.main(XMLError.java:30)

中文翻译是:分析器已达到由应用程序设置的实体扩展限制"64,000"

原来是JAXP的bug,换JDK1.5解决!

你可能感兴趣的:(java,apache,xml)