12

Hi I am running a maven test using maven 3.0.3 with hibernate 4.0.0 Final release and spring 3.1 on jdk7 update 2.

I get the following error.

Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 63 in method ${myDomainClass}.equals(Ljava/lang/Object;)Z at offset 24
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
    at java.lang.Class.getDeclaredMethods(Class.java:1808)
    at org.hibernate.property.BasicPropertyAccessor.getterMethod(BasicPropertyAccessor.java:352)
    at org.hibernate.property.BasicPropertyAccessor.getGetterOrNull(BasicPropertyAccessor.java:331)
    at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:314)
    at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:310)
    at org.hibernate.internal.util.ReflectHelper.getter(ReflectHelper.java:250)
    at org.hibernate.internal.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:229)
    at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:314)
    at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:447)
    at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:380)
    at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:320)
    at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:171)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3377)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3369)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3357)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1334)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1724)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:184)
    at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:314)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)

My Equals method is using EqualsBuilder from commons-lang 2.6. I set the following maven opts

SET MAVEN_OPTS=%MAVEN_OPTS% -XX:-UseSplitVerifier

after reading this Java 7 JVM verifyError

Note: My test works under jdk 1.6 update 29.

How do I fix this? It seems setting -XX:-UseSplitVerifier still causes the error.

Community
  • 1
  • 1
Chun ping Wang
  • 3,879
  • 12
  • 42
  • 53
  • I would clean and build all project again and try other commons-lang lib. Seems a bit like this issue: http://stackoverflow.com/a/8617057/1064325 – falsarella Jan 20 '12 at 12:38
  • Hibernate uses cglib and dependending upon how you have set up spring, it might also be using similar libraries, maybe they might be to blame. Try using a more recent version of cglib in you classpath and see if that satisfies. – Ustaman Sangat Jan 21 '12 at 02:02

2 Answers2

14

According to surefire plugin documentation MAVEN_OPTS are not inherited by a spawned JVM, so you need to specify argLine config parameter with -XX:-UseSplitVerifier in maven-surefire-plugin configuration element.

Eugene Kuleshov
  • 31,461
  • 5
  • 66
  • 67
-1

You appear to be running afoul of the "improved" bytecode verifier (which is actually dumbed-down such that it demands a lot more verifier info be supplied by the compiler). You need to either get your code processed by a compiler string that produces the "improved" bytecode format or else have the version of the class file set to the "old" version (which I'm thinking would be something less than 50.0).

Hot Licks
  • 47,103
  • 17
  • 93
  • 151
  • The problem is actually not in the user code, but in the tools/libraries, such as Hibernate and CGLIB. Those tools are not aware of the new bytecode requirements and obviously don't work well with classes compiled to target Java 7. – Eugene Kuleshov Feb 14 '12 at 15:11
  • @EugeneKuleshov -- So what solution do you propose other than one of the two I suggested? – Hot Licks Feb 14 '12 at 15:32
  • Here is the thing. You didn't really offer a solution to the original poster problem, yet made few offensive remarks about bytecode verifier. – Eugene Kuleshov Feb 15 '12 at 15:56
  • I offered two solutions -- adjust the compiler string to produce the "new" format, or target an "old" version. Apparently the fix that was adopted uses the first of those two. What I said about the verifier is nothing but the truth. – Hot Licks Feb 15 '12 at 16:07