org.xml.sax.SAXParseExceptionpublicId:http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd [英] org.xml.sax.SAXParseExceptionpublicId: http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd

查看:193
本文介绍了org.xml.sax.SAXParseExceptionpublicId:http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行时突然抛出错误:

org.xml.sax.SAXParseExceptionpublicId: 
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd; lineNumber: 
1; columnNumber: 1; Deployment descriptor file META-INF/persistence.xml 
in archive [classes].  Premature end of file.



curl -v http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd
*   Trying 2600:1402:f000:392::f6b...
* TCP_NODELAY set
* Connected to xmlns.jcp.org (2600:1402:f000:392::f6b) port 80 (#0)
> GET /xml/ns/persistence/persistence_2_1.xsd HTTP/1.1
> Host: xmlns.jcp.org
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: AkamaiGHost
< Content-Length: 0
< Location: https://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd
< Cache-Control: max-age=0
< Expires: Sun, 23 Jun 2019 23:21:20 GMT
< Date: Sun, 23 Jun 2019 23:21:20 GMT
< Connection: keep-alive
<
 * Connection #0 to host xmlns.jcp.org left intact

直到今天,这一直不是问题,并且似乎该文件不再可用,但是它是JPA持久性xml文件的标准参考:

This has not been a problem until today, and it appears this file is no longer available, but it is the standard reference for JPA persistence xml files:

HTTP/1.1 301 Moved Permanently

其他任何人突然都有这个问题吗?我无法跟踪到任何更改,并且在本地和服务器上都遇到了这种情况.

Does anyone else have this problem all the sudden. I cannot trace this to any change and I am experiencing this locally and on the server.

推荐答案

问题的根源似乎在于Oracle和对安全性的关注,这促使人们最近转向了HTTPS协议.
org.apache.openjpa.lib.meta中的XMLMetaDataParser使用SaxParser读取parseNewResource方法中的xml文件,这会导致文件错误提早结束.错误文本不是特别有用.但是,请使用XML复制编辑器 [ 并且在解决方案下,这是OpenEdge客户端内部使用的Apache Xerces解析器中的一个限制.它仅具有有限的URL支持,因此解析器无法处理URL重定向或类似于Web浏览器的HTTPS URL."
因此,在错误消息中标识为"systemId"的xml文本的重要部分是http协议语句,该语句现在在Oracle网站上重定向到https,从而导致解析错误.这解释了为什么一天运行得很好的代码在第二天早晨突然停止工作.应该很快就知道有多少ORM实现有此限制.

The root of the problem seems to lie with Oracle and a concern for security, prompting a recent switch to the HTTPS protocol.
XMLMetaDataParser in org.apache.openjpa.lib.meta uses the SaxParser to read xml files in the parseNewResource method, which throws a premature end of file error. The error text is not particularly informative. However, resorting to XML Copy Editor [http://xml-copy-editor.sourceforge.net] to validate the schema reveals the error actually involved:
Fatal Error at line 0, column 0: unsupported protocol in URL. That information ultimately led me to this post, involving OpenEdge, dated 11/6/2018: [https://knowledgebase.progress.com/articles/Article/Unsupported-protocol-in-URL-reading-XML-from-a-URI].
Under Cause, it states, "The URL used before with HTTP is now redirecting to HTTPS."
And under Resolution, "This is a limitation within the Apache Xerces parser that the OpenEdge client is using internally. It only has limited URL support, so the parser is unable to process the URL redirection or an HTTPS URL similar to a webbrowser."
So the significant portion of the xml text identified in the error message as "systemId" is the http protocol statement, which is now redirected to https at Oracle's web site, causing the parsing error. This explains why code that ran just fine one day suddenly stopped working the following morning. Just how many ORM implementations have this limitation should be known fairly quickly.

问题解决了.我更换了
https://xmlns.jcp.org/xml/ns/persistence/persistence_2_1. xsd

https://www.oracle.com/webfolder/technetwork/jsc/xml/ns/persistence/persistence_2_1.xsd
并且程序现在可以正常构建.

Problem solved. I replaced
https://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd
with
https://www.oracle.com/webfolder/technetwork/jsc/xml/ns/persistence/persistence_2_1.xsd
and the program now builds normally.

这篇关于org.xml.sax.SAXParseExceptionpublicId:http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆