2

from hibernate docs, we know that in certain case, for lazy-loading to work, we need build-time instrumentation:

How to stop Hibernate from eagerly fetching many-to-one associated object one-associated-object

so I did the following:

    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.3</version>
      <configuration>
      <tasks>
        <taskdef name="instrument" classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
          <classpath>
            <path refid="maven.runtime.classpath" />
            <path refid="maven.plugin.classpath" />
          </classpath>
        </taskdef>
        <instrument verbose="true">
          <fileset dir="target/classes">
            <include name="**/*.class" />
          </fileset>
        </instrument>
      </tasks>
      </configuration>
        <executions>
          <execution>
    <phase>process-classes</phase>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>

      </plugin>

but it gave errors

java.lang.VerifyError: (class: com/mycompany/dao/UserDaoHibernateImpl$2, method: signature: (Lcom/mycompany/dao/UserDaoHibernateImpl;II)V) Expecting to find object/array on stack

this is definitely due to the instrumentation above, since removing it fixes the problem; also websearches also show that this is somehow related to bugs in javaasist and conflicts between spring and hibernate versions.

I'm using hibernate 3.5.6-Final, Spring 3.0.6-RELEASE

I have tried all combinations of javassist versions, and tried changing javassist to asm, with various versions too, but the problem still exists.

Thanks Yang

Community
  • 1
  • 1
teddy teddy
  • 3,025
  • 6
  • 31
  • 48
  • I'm unfamiliar with how you are attempting to use Hibernate. I've never had to do any sort of manual instrumentation step as part of my build. Have you tried just annotating your classes and running? Also, have you tried using `FetchType.LAZY`, like `@ManyToOne(fetch=FetchType.LAZY)`, or whatever happens to be appropriate for your schema? – aroth Dec 12 '11 at 05:15
  • 1
    thanks, I found the issue, javassist and cglib seems to have difficulty properly instrumenting anonymous inner classes; so I simply avoided the problem by adding exludes= in the above ant tasks to avoid "*$*.class . then it worked. I'm not using annotation style, but did add lazy=true to my mapping file. – teddy teddy Dec 14 '11 at 16:49

0 Answers0