Classloading issue implementing REST client

I have a web application running on Tomcat 8 (Windows 10, JRE 1.8.0_111) that implements a REST client for communication with a 3rd part REST service (ADLNET xAPI LRS)

When I recently deployed that WAR file on a different server (CentOS, Tomcat 8, Java 1.8.0.11) the application gives a ClassNotFound exception:

java.lang.ClassNotFoundException: org.glassfish.hk2.utilities.reflection.Logger

I have the following JARs in the WEB-INF/lib folder

*jxapi-1.0.3.jar (provided by the ADLNET xAPI project) *hk2-api-2.4.0.jar *cxf-bundle-jaxrs-2.7.18.jar *jaxrs-ri-2.25.1.jar *jersey-guava-2.25.1.jar

On running the application with "-verbose:class" I found that the class loading order is different in the two cases. In the error situation, the 'cxf-bundle-jaxrs-2.7.18.jar' is not being used at all.

catalina.out (OK case)

...... [Loaded org.glassfish.jersey.client.JerseyWebTarget from file:/C:/Users/Diptendu/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/LearnITyLMSv9/WEB-INF/lib/jaxrs-ri-2.25.1.jar] [Loaded javax.ws.rs.core.UriBuilder from file:/C:/Users/Diptendu/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/LearnITyLMSv9/WEB-INF/lib/jaxrs-ri-2.25.1.jar] [Loaded javax.ws.rs.ext.RuntimeDelegate from file:/C:/Users/Diptendu/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/LearnITyLMSv9/WEB-INF/lib/jaxrs-ri-2.25.1.jar] [Loaded javax.ws.rs.ext.FactoryFinder from file:/C:/Users/Diptendu/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/LearnITyLMSv9/WEB-INF/lib/jaxrs-ri-2.25.1.jar] [Loaded javax.ws.rs.ext.FactoryFinder$1 from file:/C:/Users/Diptendu/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/LearnITyLMSv9/WEB-INF/lib/jaxrs-ri-2.25.1.jar] [Loaded org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl from file:/C:/Users/Diptendu/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/LearnITyLMSv9/WEB-INF/lib/cxf-bundle-jaxrs-2.7.18.jar] [Loaded javax.ws.rs.core.Variant$VariantListBuilder from file:/C:/Users/Diptendu/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/LearnITyLMSv9/WEB-INF/lib/jaxrs-ri-2.25.1.jar] [Loaded org.apache.cxf.jaxrs.impl.VariantListBuilderImpl from file:/C:/Users/Diptendu/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/LearnITyLMSv9/WEB-INF/lib/cxf-bundle-jaxrs-2.7.18.jar] [Loaded javax.ws.rs.core.Response$ResponseBuilder from file:/C:/Users/Diptendu/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/LearnITyLMSv9/WEB-INF/lib/jaxrs-ri-2.25.1.jar] ......

catalina.out (Error case)

...... [Loaded org.glassfish.jersey.client.JerseyWebTarget from file:/opt/tomcat8/webapps/LearnITyAcademy/WEB-INF/lib/jaxrs-ri-2.25.1.jar] INFO | jvm 1 | 2017/06/17 17:56:50 | [Loaded javax.ws.rs.core.UriBuilder from file:/opt/tomcat8/webapps/LearnITyAcademy/WEB-INF/lib/jaxrs-ri-2.25.1.jar] INFO | jvm 1 | 2017/06/17 17:56:50 | [Loaded javax.ws.rs.ext.RuntimeDelegate from file:/opt/tomcat8/webapps/LearnITyAcademy/WEB-INF/lib/jaxrs-ri-2.25.1.jar] INFO | jvm 1 | 2017/06/17 17:56:50 | [Loaded javax.ws.rs.ext.FactoryFinder from file:/opt/tomcat8/webapps/LearnITyAcademy/WEB-INF/lib/jaxrs-ri-2.25.1.jar] INFO | jvm 1 | 2017/06/17 17:56:50 | [Loaded javax.ws.rs.ext.FactoryFinder$1 from file:/opt/tomcat8/webapps/LearnITyAcademy/WEB-INF/lib/jaxrs-ri-2.25.1.jar] INFO | jvm 1 | 2017/06/17 17:56:50 | [Loaded org.glassfish.jersey.internal.AbstractRuntimeDelegate from file:/opt/tomcat8/webapps/LearnITyAcademy/WEB-INF/lib/jaxrs-ri-2.25.1.jar] INFO | jvm 1 | 2017/06/17 17:56:50 | [Loaded org.glassfish.jersey.server.internal.RuntimeDelegateImpl from file:/opt/tomcat8/webapps/LearnITyAcademy/WEB-INF/lib/jaxrs-ri-2.25.1.jar] INFO | jvm 1 | 2017/06/17 17:56:50 | [Loaded org.glassfish.jersey.uri.internal.JerseyUriBuilder from file:/opt/tomcat8/webapps/LearnITyAcademy/WEB-INF/lib/jaxrs-ri-2.25.1.jar] INFO | jvm 1 | 2017/06/17 17:56:50 | [Loaded javax.ws.rs.core.Response$ResponseBuilder from file:/opt/tomcat8/webapps/LearnITyAcademy/WEB-INF/lib/jaxrs-ri-2.25.1.jar] INFO | jvm 1 | 2017/06/17 17:56:50 | [Loaded org.glassfish.jersey.message.internal.OutboundJaxrsResponse$Builder from file:/opt/tomcat8/webapps/LearnITyAcademy/WEB-INF/lib/jaxrs-ri-2.25.1.jar] INFO | jvm 1 | 2017/06/17 17:56:50 |

What could be going wrong here?

1 answer

  • answered 2017-06-17 18:05 Mayank Sharma

    may be jar file in WEB-INF is corrupted, so update dependencies with new version and add new dependency :-

    <dependency>
        <groupId>org.glassfish.hk2</groupId>
        <artifactId>hk2-utils</artifactId>
        <version>2.5.0-b35</version>
    </dependency>
    

    and update the project and export WAR file.