Reputation: 1511
I'm attempting to enable Hibernate instrumentation for the entities in a Maven project. Instrumentation seems to work normally on entities with only fields of standard types defined by the Java API (String, BigDecimal, etc.), but when the instrumentation task attempts to work on classes which have fields of types defined by other classes in my project, it fails with the following error:
[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
I've tried deliberately instrumenting the CustomType class (which shouldn't be necessary); the instrumentation processes it, but it still errors out on EntityWithCustomTypes.
Here is the plugin I'm using in my pom.xml; the project was generated using a JBoss 7 Java EE archetype, and I'm attempting to execute the instrumentation in the EJB module 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>
I can verify that the compile phase is generating the class in question (CustomType), so I cannot understand why Hibernate's JavassistClassTransformer is unable to find it.
Upvotes: 2
Views: 1915
Reputation: 21
Latest Hibernate 4.2.7 SP1 uses Javassist 3.18.0 which finally solves the discussed issue.
Upvotes: 1
Reputation: 21
My current approach is to use the javassist 3.17.1 for instrumentation and deploying javassist 3.15.0 in the application war file. Hope this works conveniently...
UPDATE: seems to work so far, but this is a really ugly workaround...
Upvotes: 0
Reputation: 11
This seems to be related to javassist-3.15.0. For us, a later version has worked (3.17.1), but this version seriously breaks proxying (https://hibernate.atlassian.net/browse/HHH-7884), so the Hibernate team decided to go back to 3.15.0.
So in the end we have the same problem here...
Upvotes: 1