0 Replies Latest reply on Aug 13, 2013 1:00 PM by Dennis Holden

    GWT + Guava + JBoss: Class loader exception while dispatching incoming RPC call

    Dennis Holden Newbie

      I have set up a GWT application that is deployed to a JBoss server (AS 7.1.1) and (usually) performs as required. It is Maven based and divided into a server and a web module. Since I was recently introduced to the Guava library and due to its GWT compatibility I decided to include it in my project.

      While trying to send an object of the Guava class Optional from the server to the web I unfortunately endure the following error message coming up on the jBoss console:

      Exception while dispatching incoming RPC call:

      com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.google.common.base.Optional com.company.project.client.rpc.ProjectService.getSearchWords(java.lang.String)' threw an unexpected exception:

      java.lang.LinkageError: loader constraint violation: when resolving interface method "com.company.project.service.ProjectController.getSearchWords(Ljava/lang/String;)Lcom/google/common/base/Optional;"

      the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, com/company/project/server/ProjectServlet, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for resolved class, com/company/project/service/ProjectController, have different Class objects for the type va/lang/String;)Lcom/google/common/base/Optional; used in the signature

      That's the line contained in the ProjectService.java file:

      Optional<Set<String>> getSearchWords( String token );

      And the analogue method signature in ProjectController.java (which is an interface for an ProjectControllerBean.java) looks the same.

      This problem happens only in conjunction with the Guava class "Optional". Any other RPC method works well.

      I assume that it might have something to do with the Guava library that is provided by JBoss. But when I add <scope>provided</scope> to the Guava library in my Maven's pom.xml suddenly a "Class not found" Exception occurs

      I've also tried to exclude the Guava module by placing a "jboss-deployment-structure.xml" with the exclusions in my EAR's src/main/application folder but unfortunately it wasn't helpful aswell Is there any possibility to see what modules were loaded and which ones were excluded?

      Does anybody have a clue what might be going on and how to fix that? I'd be really glad for any help!

      Thanks in advance.