我正試圖爲Maven項目中的實體啓用Hibernate檢測。對於只有由Java API(String,BigDecimal等)定義的標準類型字段的實體,Instrumentation似乎正常工作,但是當instrumentation任務試圖在我的項目中具有由其他類定義的類型字段的類上工作時,它失敗,出現以下錯誤:休眠儀表轉換失敗:找不到類(HHH000373)
[instrument] processing class : com.test.entity.EntityWithCustomTypes; file = C:\Project\Project-ejb\target\classes\com\test\entity\EntityWithCustomTypes.class
Mar 21, 2013 10:00:24 AM org.hibernate.bytecode.internal.javassist.JavassistClassTransformer doTransform
ERROR: HHH000373: Unable to transform class: cannot find com.test.bo.CustomType
我試過刻意插裝CustomType類(這不應該是必要的);該工具對它進行處理,但它仍然在EntityWithCustomTypes上出錯。
這是我在我的pom.xml中使用的插件;使用JBoss的7 Java EE的原型生成的項目,我試圖在EJB模塊POM執行儀表:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<configuration>
<tasks>
<taskdef name="instrument" classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
<classpath>
<path refid="maven.dependency.classpath" />
<path refid="maven.compile.classpath" />
<path refid="maven.runtime.classpath" />
<path refid="maven.plugin.classpath" />
<dirset dir="${project.build.outputDirectory}" />
</classpath>
</taskdef>
<instrument verbose="false">
<fileset dir="${project.build.outputDirectory}">
<include name="**/entity/*.class" />
</fileset>
</instrument>
</tasks>
</configuration>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.10.Final</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
</dependencies>
</plugin>
我可以確認編譯階段是產生問題的類(CustomType) ,所以我不明白爲什麼Hibernate的JavassistClassTransformer無法找到它。
你是對的;感謝您指點我的方向javassist。我正在使用一個更老的版本(3.12.1),因爲我錯誤地發現了**舊的** Maven倉庫。更新到3.17.1會清除構建錯誤,但是,正如您所指出的那樣,它會破壞工具;我所謂的懶惰加載的領域像以前一樣急切地加載。所以目的就被打敗了。我注意到,javassist-3.16.0仍然有任何錯誤導致了構建錯誤,所以一發不可收拾。 3.17.0編譯,但我懷疑它像3.17.1一樣打破了工具;將檢查,但。 – Sumitsu 2013-03-21 16:27:41
確認:3.17.0和3.17.1都允許檢測工具找到他們需要的類,但實際上並不允許它工作。在3.17.0之前的任何情況都會導致儀表失敗,並顯示我描述的錯誤。 – Sumitsu 2013-03-21 16:46:16