我正在尝试为 Maven 项目中的实体启用 Hibernate 检测。Instrumentation 似乎在只有 Java API 定义的标准类型字段(String、BigDecimal 等)的实体上正常工作,但是当检测任务尝试处理具有我项目中其他类定义的类型字段的类时,它失败并出现以下错误:
[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 找不到它。