Deploying a Jersey webapp on Jboss AS 7

后端 未结 11 1135
既然无缘
既然无缘 2020-12-01 06:13

Currently running some webapps on Jboss AS 4/5 and I am testing migration to jboss7. When I try to deploy a jersey based webapp on JBoss AS 7 (full profile with standalone-p

相关标签:
11条回答
  • 2020-12-01 06:59

    it has already been mentioned in this post : https://community.jboss.org/message/744530#744530 , you can just ask the resteasy module to not scan for other JAX RS implementations in your webapp; just add this to your web.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>
    

    worked fine for me

    0 讨论(0)
  • 2020-12-01 07:00

    Besides removing the entire jaxrs subsystem in standalone.xml as mentioned in the other posts excluding the RESTEasy modules in jboss-deployment-structure.xml may also work.

    <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
      <deployment>
        <exclusions>
          <module name="org.jboss.resteasy.resteasy-atom-provider" />
          <module name="org.jboss.resteasy.resteasy-cdi" />
          <module name="org.jboss.resteasy.resteasy-jaxrs" />
          <module name="org.jboss.resteasy.resteasy-jaxb-provider" />
          <module name="org.jboss.resteasy.resteasy-jackson-provider" />
          <module name="org.jboss.resteasy.resteasy-jsapi" />
          <module name="org.jboss.resteasy.resteasy-multipart-provider" />
          <module name="org.jboss.resteasy.async-http-servlet-30" />
        </exclusions>
      </deployment>
    </jboss-deployment-structure>
    

    Also check out

    • JBoss Deployment Structure File
    • Implicit module dependencies for deployments
    0 讨论(0)
  • 2020-12-01 07:00

    I managed to run Jersey WS on my JBOSS AS7.

    What i do for JBOSS is just remove everything related to jax-rs in standalone.xml

    My jersey sample code got from: http://www.ibm.com/developerworks/web/library/wa-aj-tomcat/

    The only thing i do for the jersey is remove the init-param from web.xml and copy jersey lib to WebContent/WEB-INF/lib.

      <!--<init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>sample.hello.resources</param-value>
      </init-param>-->
    
    0 讨论(0)
  • 2020-12-01 07:02
    In web.xml file add the files
    
            <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>
    
     and comment out the init-param
            <!-- <init-param>
                      <param-name>com.sun.jersey.config.property.packages</param-name>
                      <param-value></param-value>
            </init-param> -->
    
    This worked out for me in jboss-as-7.1.1.Final and i did not do any changes in standalone.xml.
    
    0 讨论(0)
  • 2020-12-01 07:03

    I believe the correct approach is to use app server agnostic JAX-RS application deployment. No need to mess with any JBoss configuration. All you need is, extend javax.ws.rs.core.Application in your JAX-RS web application. You can find an example here. Then, you need to put this in your web.xml.

    <servlet>
      <servlet-name>Jersey Web Application</servlet-name>
      <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
      <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>jersey.MyApplication</param-value>
      </init-param>
      <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>
    
      <load-on-startup>1</load-on-startup>
    </servlet>
    

    Package scanning mechanism does not work correctly on JBoss 7.x. I have tested this approach successfully in JBoss 7.0.2.Final and JBoss 7.1.1.Final.

    0 讨论(0)
提交回复
热议问题