gpt4 book ai didi

java - 我在 [row,col] :[1, 2] 处收到 XMLStreamException

转载 作者:行者123 更新时间:2023-11-30 05:35:08 27 4
gpt4 key购买 nike

我突然开始在我的项目中遇到 XMLStreamException。昨天它工作得很好,今天我做了一些小改动,它就坏了。我尝试重新设置为以前的版本,但没有任何改变。

这是我的 xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5433/logistica</property>
<property name="hibernate.connection.username">testUser</property>
<property name="hibernate.connection.password">pass</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL9Dialect</property>

<mapping class="com.log.iei.logistica.data.entities.ClientEntity" />
<mapping class="com.log.iei.logistica.data.entities.ContractEntity" />
<mapping class="com.log.iei.logistica.data.entities.ContainerEntity" />
<mapping class="com.log.iei.logistica.data.entities.VehicleEntity" />
<mapping class="com.log.iei.logistica.data.entities.TransactionEntity" />

</session-factory>
</hibernate-configuration>

还有异常(exception):

org.hibernate.HibernateException: Error accessing stax stream
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:107)
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:65)
at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57)
at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:165)
at org.hibernate.cfg.Configuration.configure(Configuration.java:258)
at org.hibernate.cfg.Configuration.configure(Configuration.java:244)
at com.log.iei.logistica.managers.HibernateSessionManager.getSessionFactory(HibernateSessionManager.java:18)
at com.log.iei.logistica.data.controllers.Services.GenericDao.getSession(GenericDao.java:78)
at com.log.iei.logistica.data.controllers.Services.GenericDao.findAll(GenericDao.java:58)
at com.log.iei.logistica.data.controllers.Services.VehicleService.findAll(VehicleService.java:50)
at com.log.iei.logistica.gui.cargo.CargoPage.init(CargoPage.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.........
.......
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,2]
Message: The markup declarations contained or pointed to by the document type declaration must be well-formed.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:604)
at com.sun.xml.internal.stream.XMLEventReaderImpl.peek(XMLEventReaderImpl.java:276)
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:103)
... 36 more

最佳答案

我开始遇到同样的问题。我没有更新任何东西,但是重新启动 tomcat 失败并出现很多新的异常。我注意到下面的文件今天更新了,想知道它是否是源(它在我的每个实体映射中引用):

http://hibernate.org/dtd/hibernate-mapping-3.0.dtd

所以我更新了我的映射以使用这里的 DTD:“hibernate.sourceforge.net/hibernate-mapping-3.0.dtd” - 这很有效。所以这似乎是由 Hibernate 更新的 DTD 文件引起的。

我猜你的选择是:

  1. 弄清楚 hibernate 在更新的 dtd 中想要什么
  2. 使用来自其他来源(例如 sourceforge)的 dtd
  3. 使用 hibernate jar 中的 dtd,如下所示:“classpath://org/hibernate/hibernate-mapping-3.0.dtd”

关于java - 我在 [row,col] :[1, 2] 处收到 XMLStreamException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56792434/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com