破解Hibernate逆向工程任务,隐藏错误消息

时间:2012-08-10 23:26:43

标签: hibernate reverse-engineering hibernate-tools

我们有一个项目,它使用独立的Hibernate Tools Ant任务来构建hbm.xml文件和POJO。当我们需要添加或更新POJO时,我们只运行Ant任务,它有自己的build.xml文件,而不是每次我们构建项目时。

其他人更新了项目,现在Ant任务(未更改)无法解析构建文件(也没有更改)。我无法知道变化是什么或者多长时间没有工作,所以我要求社区帮我诊断。这是消息:

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

这是无法解析的配置文件:

<?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>

1 个答案:

答案 0 :(得分:0)

这似乎就是答案:reveng.xml和reveng.cfg.xml文件由我们的一个常驻天才更新,将一个工作的XML DTD定义替换为与安装在其中的Hibernate jar不匹配的定义。项目。这是为reveng.cfg.xml文件工作的那个:

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

以下是为reveng.xml文件工作的那个:

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

以下是那些被破坏但无效的内容:

<!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">

这是针对Hibernate逆向工程3.3.1罐。

我希望这有助于某人!