簡體   English   中英

在glassfish服務器中運行項目時出現web.xml SAXParseException錯誤

[英]web.xml SAXParseException error when running a project in glassfish server

當我在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.

從幾天開始,我們也開始收到此錯誤。 uri:

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

返回SAX Parser無法處理的狀態碼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

我將驗證網址更改為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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM