Question

In my project, I'm using both glassfish-embedded 3.1.1 and the guava lib... The problem is that glassfish comes with the old implementation of guava (ie google-collections)...

This results in NoSuchMethodError at runtime, for example when using Lists.reverse(), or Sets.newIdentityHashSet() which were introduced later in guava.

I don't find any solution to solve this... (the only one is to manually trash the com/google classes directory in the glassfish jar...)

Was it helpful?

Solution

Glassfish should never have included com.google classes in their own jar. That was an error.

UPDATE[@sly7_7]: It seems like glassfish does not include guava in their own jar anymore, but it depends on the guava artifact instead. This should resolve the problem. Thanks to @JagWire for pointing this.

OTHER TIPS

You can overcome this be specifying the below. Read the Delegation section of the Class Loaders chapter.

<class-loader delegate="false" />

Check this SO post for class loading in Java EE apps in general: Java EE class loading standard

I was able to make the error go away by using the following Glassfish v4 build:

http://grepcode.com/snapshot/maven.java.net/content/groups/promoted/org.glassfish.main.extras/glassfish-embedded-all/4.0.1-b01

Might be worth taking a look.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top