我在各种网站上发现了一些似乎涉及这个问题的线程,但我没有运气。似乎它根本无法完成。我得到了
Caused by: java.lang.IncompatibleClassChangeError: Found interface org.hibernate.cfg.Mappings, but class was expected
错误。查看此线程中显示的兼容性矩阵。除非我降级,否则我似乎无法使用 reveng。但这似乎不对。
当我开始升级一切正常时,现在我遇到了同样的错误。我确保在我的类路径上没有两个同名的不同 jar。我有以下罐子:
commons-logging-1.0.4.jar
dom4j-1.6.1.jar
hibernate3.jar
hibernate-tools.jar
slf4j-api-1.6.6.jar
slf4j-log4j12-1.6.6.jar
sqljdbc4.jar
other various jars not dealing with hibernate..
这是完整的堆栈跟踪:
...
hibernatetool
Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
1. task: hbm2hbmxml (Generates a set of hbm.xml files) java.lang.IncompatibleClassChangeError: Found interface org.hibernate.cfg.Mappings, but class was expected
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
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:809)
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)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:29)
Caused by: java.lang.IncompatibleClassChangeError: Found interface org.hibernate.cfg.Mappings, but class was expected
at org.hibernate.cfg.reveng.MappingsDatabaseCollector.getTable(MappingsDatabaseCollector.java:25)
at org.hibernate.cfg.reveng.JDBCReader.processTables(JDBCReader.java:535)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:74)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:860)
at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:121)
at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:94)
...
蚂蚁:
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="classpath" />
...
<hibernatetool>
<jdbcconfiguration configurationfile="${conf.dir}/${dbName}_hibernate-template.cfg.xml" packagename="myPackageName" revengfile="${conf.dir}/hibernate.reveng.xml" reversestrategy="com.capitaliq.loader.dev.codegen.HibernateReverseStrategy" detectmanytomany="false" />
<hbm2hbmxml destdir="${srcGen.dir}" />
<!-- Generate new hibernate.cfg.xml including new POJOs-->
<!--'destdir' is relative to 'packagename' configuration-->
<hbm2cfgxml ejb3="false" destdir="${conf.dir}" />
</hibernatetool>
<!-- Generate java POJOs from mapping files-->
<hibernatetool> <!--Line 384-->
<configuration configurationfile="${conf.dir}/${dbName}_hibernate-template.cfg.xml">
<fileset dir="${orm.pkg.dir}">
<include name="**/*.hbm.xml" />
</fileset>
</configuration>
<!--'destdir' is relative to 'packagename' configuration-->
<hbm2java jdk5="true" ejb3="false" destdir="${srcGen.dir}" />
</hibernatetool>
任何帮助都会很棒;这台电脑即将被扔掉。多谢你们。