我使用的是基于 Eclipse 3.x 构建的 WID 6.1。
当尝试右键单击文件夹,“新建”->“类”,键入类的名称,然后单击“完成”时,出现错误
"Creation of element failed. org.xml.sax.SAXParseException: Premature end of file."
昨天发生这种情况时,我重新创建了工作区,但现在又发生了。重新安装 WID 是一个两三个小时的任务,所以我更愿意解决实际问题。
建议?
编辑:第二次重新启动 WID 后,我现在收到“初始化 Java 工具时出错。”,该消息比我原来的错误消息更易于搜索。得到。
编辑:查看 WID/Eclipse 日志,有一个异常,但它没有告诉我哪个项目或哪个文件。
Caused by: org.xml.sax.SAXParseException: Premature end of file.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at org.eclipse.wst.common.internal.emf.utilities.DOMUtilities.loadDocument(Unknown Source)
... 21 more
最佳答案
单击“窗口”、“显示 View ”、“错误日志”。
从工作区中删除所有项目。
将项目一一重新加载到工作区中,查看错误日志。
对于导致加载错误的项目,进入其 .settings 文件夹并看到其中的文件为空和/或 0 字节。把它们全部删除,它又起作用了。
关于 eclipse "Creation of Element Failed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2072913/