【问题标题】:web.xml SAXParseException error when running a project in glassfish server在 glassfish 服务器中运行项目时出现 web.xml SAXParseException 错误
【发布时间】:2019-06-24 12:31:33
【问题描述】:

当我在 IntelliJ 上运行我的项目时,它给了我一个 java.io.IOException: org.xml.sax.SAXParseException 错误。

我找不到问题。有人可以帮我解决这个错误吗?

web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
</web-app>

Persistence.xml

<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
             http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
             version="2.1">

    <persistence-unit name="aquadinePU" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/aquadine?autoReconnect=true&amp;useSSL=false&amp;allowPublicKeyRetrieval=true" />
            <property name="hibernate.hbm2ddl.auto" value="update"/>
            <property name="javax.persistence.jdbc.user" value="root" />
            <property name="javax.persistence.jdbc.password" value="ruta" />
            <property name="hibernate.show_sql" value="true"/>
        </properties>
    </persistence-unit>

</persistence>

web.xml的错误如下:

java.io.IOException: org.xml.sax.SAXParseExceptionpublicId: http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd; lineNumber: 1; columnNumber: 1; Deployment descriptor file WEB-INF/web.xml in archive [aquadine-jee].  Premature end of file.

persistence.xml的错误如下:

java.io.IOException: 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.

【问题讨论】:

标签: java intellij-idea glassfish web.xml payara


【解决方案1】:

几天后我们也开始收到此错误。 URI:

 http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd 

返回 SAX 解析器无法处理的状态码 301。

我们的修补程序是将 web.xml 中的架构位置更改为新文件:

xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/web-app_3_1.xsd

【讨论】:

  • 非常感谢,我遇到了同样的持久性问题,我用你的修补程序修复了它。
  • 我敦促任何遇到此问题的人向他们的 ORM 供应商提交错误报告。这个解决方案对我有用,除非 Oracle 再次移动文件,否则应该继续工作。 OpenJPA 已经解决了这个问题OpenJPA-2791
【解决方案2】:

我将验证 URL 更改为 https,因此问题所在的重定向不会发生。

<? xml version = "1.0" encoding = "UTF-8"?>
<persistence version = "2.1"
xmlns = "https://xmlns.jcp.org/xml/ns/persistence" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi: schemaLocation = "https://xmlns.jcp.org/xml/ns/persistence https://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

注意:我在使用 java 7 和 glassfish 3 时遇到了这个问题,使用 java 8 和 glassfish 4 时,它可以工作。

另一件事,在 glassfish 3 中,我需要禁用焊接 xml 验证,在 glassfish 中添加参数

-Dorg.jboss.weld.xml.disableValidating = true

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-07-24
  • 2018-06-23
  • 1970-01-01
  • 1970-01-01
  • 2015-09-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多