如何在websphere 8.5中使用jersey部署JAX-RS应用程序

时间:2013-03-01 04:59:13

标签: jersey websphere jax-rs websphere-8

在websphere 7.0中部署app.war时。宁静的Web服务已成功初始化。
但在升级到websphere 8.5之后。它无法部署restful Web服务类。
以下是我的app.war的针对球衣的pom.xml。

    <!-- 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>

下面是我的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> 

以下是启动应用时的websphere错误日志:

  

[13-3-1 13:22:44:03 CST] 000003b5 PackagesResou I扫描包中的根资源和提供程序类:     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创建servlet抛出的未捕获异常       在com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:398)   
...   
...   
引起: 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)       在com.ibm.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:852)       在com.ibm.ws.classloader.CompoundClassLoader.localFindClass(CompoundClassLoader.java:762)       在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)       在java.lang.J9VMInternals.initialize(J9VMInternals.java:162)       在com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79)       在com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)       在com.sun.jersey.api.core.PackagesResourceConfig。(PackagesResourceConfig.java:78)       在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)       在com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203)       在com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374)       在com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557)       在javax.servlet.GenericServlet.init(GenericServlet.java:161)       在com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:336)

经谷歌搜索后,有人说可能是webshpere服务器已经包含了asm。所以我从app.war WEB-INF / lib中删除了asm.jar。但它仍有错误。

2 个答案:

答案 0 :(得分:1)

您不应该从我们的WEB-INF / lib中删除您的asm.jar。相反,您应该指示您的websphere 8.5使用WEB-INF / lib中的asm.jar而不是Websphere安装提供的asm.jar。看看这个链接:Configure Web Module Classloader。您应该选择首先使用本地类加载器加载的类

根据评论进行修改:

看起来这是Websphere 8.5 PM63479; 8.5: earexpander throws java.lang.incompatibleclasschangeerror中的一个错误。请下载PM63479以查看它是否解决了您的问题。

答案 1 :(得分:1)

@Surge建议除外 您是否尝试创建共享库,并将asm-all.jar jersery.jar放入库中。并为您的应用程序指定共享库。