Java – Jersey 2 on JBoss 7

Has anyone successfully deployed Jersey 2 X and JBoss 7 x? I try to use JBoss 7.1 1. Deploy Jersey 2.5, but encounter errors, such as:

"java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;"

I believe this problem is because JBoss is bundled with resteasy, which is a jax-rs 1.0 implementation, while Jersey is a jax-rs 2.0 implementation So I took the following steps to disable resteasy:

1) Add the following to my web In XML:

<context-param>
    <param-name>resteasy.scan</param-name>
    <param-value>false</param-value>
</context-param>
<context-param>
    <param-name>resteasy.scan.providers</param-name>
    <param-value>false</param-value>
</context-param>
<context-param>
    <param-name>resteasy.scan.resources</param-name>
    <param-value>false</param-value>
</context-param>

2) According to the discussion here, I modified JBoss's standalone xml,module. XML and domain XML to delete the 1 / all references to resteasy

3) This leads to another error: "Java. Lang. NoClassDefFoundError: org / objectweb / ASM / classvisitor", I added the following to my POM XML:

<dependency>
    <groupId>asm</groupId>
    <artifactId>asm</artifactId>
    <version>3.3.1</version>
</dependency>

So finally my application was deployed without errors, but now I seem unable to access my jersey resources However, wharf 8 works normally I can also run Jersey 1 X without having to take steps #2 and #3, but if possible, I prefer to use Jersey 2 x.

In addition, I tried to create a JBoss deployment structure XML file, but I still encounter previous errors, such as "Java. Lang. nosuchmethoderror: javax. WS. Rs.core. Application. Getproperties() ljava / util / map;"

<?xml version="1.0" encoding="UTF-8"?>  
<jboss-deployment-structure>
  <deployment>
    <exclusions>
            <module name="org.jboss.resteasy.resteasy-atom-provider"/>  
            <module name="org.jboss.resteasy.resteasy-cdi"/>  
            <module name="org.jboss.resteasy.resteasy-jackson-provider"/>  
            <module name="org.jboss.resteasy.resteasy-jaxb-provider"/>  
            <module name="org.jboss.resteasy.resteasy-jaxrs"/>  
            <module name="org.jboss.resteasy.resteasy-jettison-provider"/>  
            <module name="org.jboss.resteasy.resteasy-jsapi"/>  
            <module name="org.jboss.resteasy.resteasy-multipart-provider"/>  
            <module name="org.jboss.resteasy.resteasy-yaml-provider"/>  
            <module name="org.apache.log4j"/>  
            <module name="org.apache.commons.pool"/>  
            <module name="javax.ws.rs.api"/>
    </exclusions>
  </deployment>
</jboss-deployment-structure>

Does anyone have JBoss and Jersey 2 X's luck? Any help would be appreciated

Solution

You can use Jersey 2 to configure your JBoss deployment structure on JBoss 7 XML is similar to:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>

<exclude-subsystems>
  <subsystem name="resteasy" />
</exclude-subsystems>

<exclusions>
  <module name="javaee.api" />
  <module name="javax.ws.rs.api"/>
  <module name="org.jboss.resteasy.resteasy-jaxrs" />
</exclusions>

<local-last value="true" />

</deployment>
</jboss-deployment-structure>

Because JBoss 7 contains module dependencies, excluding the resteasy module itself is not enough to exclude the entire Java EE API module Also make sure that too many modules are not excluded This can also damage your application – the above example is enough to disable resteasy

You have found that you still need to be on the web The XML contains the following lines

<context-param>
   <param-name>resteasy.scan</param-name>
   <param-value>false</param-value>
  </context-param>
  <context-param> 
   <param-name>resteasy.scan.providers</param-name>
   <param-value>false</param-value>
  </context-param>
  <context-param>
   <param-name>resteasy.scan.resources</param-name>
   <param-value>false</param-value>
  </context-param>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>