Question

I can't figure out what is causing this error.

I am using Intuit's Java v3 SDK for QuickBooks Online (QBO), and I'm attempting to run a query for TimeActivity objects. To do this, I must generate a query entity.

My code fails on this line:

TimeActivity queryTimeActivity = GenerateQuery.createQueryEntity(TimeActivity.class);

The stack trace proceeds from that line as follows:

java.lang.VerifyError: class net.sf.cglib.core.DebuggingClassWriter overrides final method visit.(IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V
    at com.google.appengine.runtime.Request.process-4da1515b5814ac28(Request.java)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:795)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:360)
    at net.sf.cglib.core.AbstractClassGenerator.<init>(AbstractClassGenerator.java:38)
    at net.sf.cglib.core.KeyFactory$Generator.<init>(KeyFactory.java:127)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:112)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
    at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
    at com.intuit.ipp.query.GenerateQuery.createQueryEntity(GenerateQuery.java:56)

I should mention that this code is in a Google App Engine app. I did some Google searches for this error, and found that many people suggest removing the libraries "cglib" and "asm" from the build path. I could not find "cglib", but I tried removing "asm-4.0.jar", but Google App Engine complained when I tried that. More specifically, the app deployed, but the line in question never ran when I removed asm.jar.

Does anyone have any ideas? I can't get my code to proceed beyond the aforementioned line.

Was it helpful?

Solution

Note that the exception is thrown during a call of the static initializer (<clinit>) of cglib's Enhancer class. Cglib uses ASM internally and it seems as if you have mismatching versions of cglib and ASM on your classpath.

From the error, I assmue that Intuit is using cglib 2.2 which relies on ASM 3.1. In this version, the ClassWriter did not declare its methods as final. This changed in ASM 4 such that cglib cannot be loaded because it overrides these now final methods.

What you could do is either

  1. Remove ASM 4 from the class path but add ASM 3. See the POM for the fact that cglib 2.2.2 requires ASM 3.1.1.
  2. Explictly add cglib 3.1 to the class path which works with ASM 4. This might however break the application using cglib.

Usually, libraries using ASM should pack the latter under a different package to avoid zhis problem as documented in ASM's FAQ. It seems as if the authors of Intuit missed that.

Finally, note it mentions here that cglib 2.2 is only partially supported by GAE.

OTHER TIPS

I tried the following and it worked fine.

TimeActivity timeActivity = GenerateQuery.createQueryEntity(TimeActivity.class);
String query   = select($(timeActivity.getId()),$(timeActivity.getSyncToken())).generate();
System.out.println("Generated Query - " + query);
QueryResult queryResult = service.executeQuery(query);

Can you check if it is working in your local system.

Thanks

As raphw explains above, option 2 fixed it for me. In my case I was using another artifact that included ASM 4. I added the following dependency to my POM file and I no longer get the error:

<dependency>
    <groupId>cglib</groupId>
    <artifactId>cglib</artifactId>
    <version>3.1</version>
</dependency>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top