0
votes

When I deploy my app.war in websphere 7.0. The restful web service was successful initialized.
But after I upgrade to websphere 8.5 . It failed to deploy the restful web service class.
Below is my app.war's pom.xml for jersey.

    <!-- restful web service -->
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>jsr311-api</artifactId>
        <version>1.1.1</version>
        <optional>true</optional>
    </dependency>

    <dependency>
        <groupId>asm</groupId>
        <artifactId>asm-all</artifactId>
        <version>3.2</version>
        <optional>true</optional>
    </dependency>

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-core</artifactId>
        <version>1.17</version>
        <scope>compile</scope>
    </dependency>

     <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-servlet</artifactId>
        <version>1.17</version>
       <scope>compile</scope>
    </dependency>  

     <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.17</version>
       <scope>compile</scope>
    </dependency>  

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.17</version>
        <scope>compile</scope>
    </dependency>

Below is my web.xml

  <servlet>
    <servlet-name>Jersey REST Service</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
      <param-name>com.sun.jersey.config.property.packages</param-name>
      <param-value>com.tag.services.testrsws</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Jersey REST Service</servlet-name>
    <url-pattern>/rs/*</url-pattern>
  </servlet-mapping>
</web-app> 

Below is the websphere error log when start the app:

[13-3-1 13:22:44:103 CST] 000003b5 PackagesResou I Scanning for root resource and provider classes in the packages: com.tag.services.testrsws
[13-3-1 13:22:44:123 CST] 000003b5 servlet E com.ibm.ws.webcontainer.servlet.ServletWrapper init Uncaught.init.exception.thrown.by.servlet
[13-3-1 13:22:44:124 CST] 000003b5 webapp E com.ibm.ws.webcontainer.webapp.WebApp commonInitializationFinally SRVE0266E: init servlet error:{0} javax.servlet.ServletException: SRVE0207E: servlet create uncaught exception thrown by servlet at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:398)
...
...
Caused by: java.lang.IncompatibleClassChangeError: org.objectweb.asm.ClassVisitor at java.lang.ClassLoader.defineClassImpl(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:262) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:69) at com.ibm.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:852) at com.ibm.ws.classloader.CompoundClassLoader.localFindClass(CompoundClassLoader.java:762) at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:585) at java.lang.ClassLoader.loadClass(ClassLoader.java:627) at java.lang.J9VMInternals.verifyImpl(Native Method) at java.lang.J9VMInternals.verify(J9VMInternals.java:85) at java.lang.J9VMInternals.verify(J9VMInternals.java:83) at java.lang.J9VMInternals.initialize(J9VMInternals.java:162) at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79) at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104) at com.sun.jersey.api.core.PackagesResourceConfig.(PackagesResourceConfig.java:78) at com.sun.jersey.api.core.PackagesResourceConfig.(PackagesResourceConfig.java:89) at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:696) at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:674) at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203) at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374) at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557) at javax.servlet.GenericServlet.init(GenericServlet.java:161) at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:336)

After search by google , some one says it may be webshpere server already contain the asm. So I delete the asm.jar from my app.war WEB-INF/lib. But it still has the error.

2

2 Answers

1
votes

Except @Surge advice.
Have you try to create a shared library, and put your asm-all.jar jersery.jar into your library.And specify the shared library to your application.

1
votes

You should not delete your asm.jar from our WEB-INF/lib. On the contrary, you should instruct your websphere 8.5 to use the asm.jar in the WEB-INF/lib instead the asm.jar provided by the Websphere installation. Check out this link: Configure Web Module Classloader. You should choose Classes loaded with local class loader first.

Edit based on comments:

Looks like this is a bug in Websphere 8.5 PM63479; 8.5: earexpander throws java.lang.incompatibleclasschangeerror. Please download PM63479 to see if it fixes your issue.