web.xml 运行 glassfish 服务器中的项目时出现 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&useSSL=false&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
returns 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
我将验证 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
当我 运行 我在 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&useSSL=false&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
returns 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
我将验证 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