質問

We have a project which uses the standalone Hibernate Tools Ant task to build the hbm.xml files and POJOs. We only run the Ant task, which has its own build.xml file, when we need to add or update POJOs, not every time we build the project.

Someone else updated the project and now the Ant task (which hasn't changed) can't parse the build file (which also hasn't changed). I have no way of knowing what the change was or how long this hasn't been working, so I'm asking the community to help me diagnose it. Here's the message:

build.xml:34: org.hibernate.HibernateException: Could not parse configuration: src\main\config\hibernate\datawhse.reveng.cfg.xml
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1494)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
        at org.hibernate.tool.ant.ConfigurationTask.doConfiguration(ConfigurationTask.java:96)
        at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:50)
        at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
        at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
        at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:318)
        at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
        at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
        at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:392)
        at org.apache.tools.ant.Target.performTasks(Target.java:413)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
        at org.apache.tools.ant.Main.runBuild(Main.java:811)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: org.dom4j.DocumentException: Connection refused: connect Nested exception: Connection refused: connect
        at org.dom4j.io.SAXReader.read(SAXReader.java:484)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1484)
        ... 26 more

Here's the configuration file that it can't parse:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
    <property name="show_sql">false</property>
    <property name="hibernate.connection.pool_size">0</property>
    <property name="connection.url">jdbc:as400://system;libraries=XXX YYY ZZZ;dateformat=iso;timeformat=iso;prompt=false;naming=system;transaction isolation=none</property>
    <property name="connection.driver_class">com.ibm.as400.access.AS400JDBCDriver</property>
    <property name="connection.username">username</property>
    <property name="connection.password">password</property>
    <property name="dialect">org.hibernate.dialect.DB2Dialect</property>
</session-factory>
</hibernate-configuration>
役に立ちましたか?

解決

This seems to be the answer: The reveng.xml and reveng.cfg.xml files were updated by one of our resident geniuses, replacing the working XML DTD definition with one that was mis-matched with the Hibernate jars installed in the project. Here is the one that was working for the reveng.cfg.xml file:

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

Here is the one that was working for the reveng.xml file:

<!DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">

Here are the ones that were broken and did not work:

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<!DOCTYPE hibernate-reverse-engineering SYSTEM "http://www.hibernate.org/dtd/hibernate-reverse-engineering-3.0.dtd">

This was for Hibernate reverse engineering 3.3.1 jars.

I hope this helps somebody!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top