I have created a new Maven web application in eclipse, and it gave me a Hello World example written in a file named index.jsp located in src/main/webapp.
Let's say I have created a facelet (login.xhtml) and I want my application to run it as default page, instead of the index.jsp page.
I would like to know how and where to change the default value of the file which is lanched.
Thanks in advance.
First of all, you need add support to JSF (maybe not) and facelets in your project if you.
<!-- JSF -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${jsf.version}</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${jsf.version}</version>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>${facelets.version}</version>
</dependency>
You can just add a facelets library, such as Prime Faces.
Config your web.xml, add something like this:
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<!-- Use Documents Saved as *.xhtml -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<!-- Special Debug Output for Development -->
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
After this, you'll need change welcome-file-list in your web.xml:
<welcome-file-list>
<welcome-file>login.jsf</welcome-file>
</welcome-file-list>
If you are using facelets, so you'll need to create a faces-config.xml file, like this:
<faces-config>
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>
</faces-config>
Read more about here.
Related
i'm trying to develop a basic RESTFULL application, i found some tutorials but i don't know what is going on because everything looks right. I'm launching the app with the maven tomcat plugin (if it helps).
Here are the web.xml and the controller.
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>
com.servicios.ws.controller
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
and the controller
#Path("/ws/test")
public class UsuarioController {
#GET
#Path("/login")
public final String findUsuarioById() {
return "TEST OK";
}
}
Finally, here you have the pom versions
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.25</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.25</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-spring3</artifactId>
<version>2.25</version>
</dependency>
It should work, but when i try to access the /ws/test/login, i get the 404.
Thanks in advance
Change #Path("/ws/test") to #Path("/test"). The ws in
<url-pattern>/ws/*</url-pattern>
gets prepended, so in its current state, you would need to access /ws/ws/test/login
RESTEAsy WADL generator was included in our application referring How to generate wadl file for resteasy in jboss.
Deployment done in JBoss EAP 6.4 is successful. But on accessing the WADL generation URL http://host:8080/rest-serviceapp/application.xml, it is generating the following error -
java.lang.NullPointerException
org.jboss.resteasy.wadl.ResteasyWadlWriter.getStringWriter(ResteasyWadlWriter.java:36)
org.jboss.resteasy.wadl.ResteasyWadlWriter.getBytes(ResteasyWadlWriter.java:26)
org.jboss.resteasy.wadl.ResteasyWadlServletWriter.writeWadl(ResteasyWadlServletWriter.java:32)
org.jboss.resteasy.wadl.ResteasyWadlServletWriter.writeWadl(ResteasyWadlServletWriter.java:45)
org.jboss.resteasy.wadl.ResteasyWadlServlet.service(ResteasyWadlServlet.java:55)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
The web.xml we use is -
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>Restapp_Service</display-name>
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/resteasy</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan.providers</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan.resources</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet>
<servlet-name>RESTEasy WADL</servlet-name>
<servlet-class>org.jboss.resteasy.wadl.ResteasyWadlServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/resteasy/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RESTEasy WADL</servlet-name>
<url-pattern>/application.xml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
The resteasy-wadl dependency is -
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-wadl</artifactId>
<version>3.1.0</version>
</dependency>
REST service comsumes/produces JSON.
Why is the WADL/xml generation ending up in nullpointer exception? What could be the mistake(s) we are making?
I had the same issue on Wildfly 10.1.0.
I fixed it by using resteasy-wadl 3.0.19 as all other resteasy libraries have this version on Wildfly 10.1.0.
I also had to exclude the resteasy-jaxrs library in the pom, else the resteasy-jaxrs library was included in my war, causing the issue:
<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-wadl -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-wadl</artifactId>
<version>3.0.19.Final</version>
<exclusions>
<exclusion>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
</exclusion>
</exclusions>
</dependency>
Also, if you use another version than the version of the resteasy libraries already installed in your JBoss, these resteasy libraries (resteasy-jaxrs...) will be installed a second time as dependency of the resteasy-wadl library. These duplicate libraries seem to cause lots of conflicts.
After deploying my war file, Weblogic changes the url-pattern, which i've defined in web.xml for my Jersey RESTful. As you can see, I want to access my service under /rest/* but weblogic changes it to /resources/*. Where can I configure it for WebLogic?
<servlet>
<servlet-name>jersey-serlvet</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>ch.ni.service</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
p.s it works with tomcat, as desired
I ran into a similar problem moving an application from Glassfish 3 to Weblogic 12.2.1. I finally caved in and followed the Jersey tutorial here.
I used the web.xml that was generated in the example to fix the code I was working on.
Short answer is I had to change the web.xml servlet definition to look like:
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>your.package.with.JAXRS.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webservices/*</url-pattern>
</servlet-mapping>
I also took the dependencies from the POM in the example and used them in my POM.
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.24</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.24</version>
</dependency>
Hope it helps.
I am trying swagger for the first time with Jersey and Maven, and I am wondering if I am going down the right path. I have jersey, maven, and swagger working on my local computer. Soon, I want to deploy it to different environments and include swagger-ui.
If I configure my web.xml file to <param-value>http://localhost:8080/api</param-value> then I see that swagger works on my local computer. But will I need to change this address every time I want to deploy my code to different environments (for example going from a Dev environment, to QA environment, to Production environment), and if so how would I go about doing that or is it not possible/not what swagger is meant for?
I want to incorporate swagger-ui with my project. I see online suggestions of downloading the file manually from git and placing it in my project. But what I am wondering is if there is a maven dependency that I can use instead so that I can use maven to get the necessary code to use swagger-ui and configure it to work with jersey. If so what is the dependency and how do I use it to deploy the code through multiple environments?
Please give guidance and links to tutorials if possible seeing as I am new to this technology. Also if I am way off in my thought process of using jersey/swagger/swagger-ui/maven without manually downloading code from git and being able to deploy the code through multiple environments please let me know so I can look for another way to use REST in my application.
Thank you for your help.
pom.xml:
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<properties>
<jersey2.version>2.19</jersey2.version>
<jaxrs.version>2.0.1</jaxrs.version>
</properties>
<!-- Dependencies -->
<dependencies>
<!-- JAX-RS -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${jaxrs.version}</version>
</dependency>
<!-- Jersey 2.19 -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey2.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey2.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey2.version}</version>
</dependency>
<!-- Servlet Library -->
<!-- http://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- Spring dependencies -->
<!-- http://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.4.RELEASE</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.4.RELEASE</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.4.RELEASE</version>
</dependency>
<!-- Junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
<version>1.5.0</version>
</dependency>
</dependencies>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>HelloWorldSpring</display-name>
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>
io.swagger.jaxrs.listing,
com.jer.rest
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Jersey2Config</servlet-name>
<servlet-class>io.swagger.jersey.config.JerseyJaxrsConfig</servlet-class>
<init-param>
<param-name>api.version</param-name>
<param-value>1.0.0</param-value>
</init-param>
<init-param>
<param-name>swagger.api.basepath</param-name>
<param-value>http://localhost:8080/HealthTracker/rest</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Other XML Configuration -->
<!-- Load by Spring ContextLoaderListener -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/root-context.xml</param-value>
</context-param>
<!-- Spring ContextLoaderListener -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
Check out the link https://github.com/swagger-api/swagger-samples/tree/2.0/java
It has excellent examples on how to configure Swagger 3.0 in your project (see java-jersey2-webxml example). For earlier versions check the branches
As far as the ui is concerned, you can download required files or you can just add the below dependency in pom.xml.
<dependency>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>3.6.1</version>
</dependency>
It will download necessary ui files. You can copy the downloaded index.html in your project and edit the url.
Here's what I think would answer your questions:
To be able to configure swagger as per different environments, then these are the steps you can follow:
i) Create a Bootstrap class to configure swagger bean (ref: https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5 and Setting the Api Version with Swagger UI)
ii) Set the values in the above bean using values from a properties file, which you can easily configure outside your code in any environment.
Swagger dist consists of html/css/image/js files. It cannot be added as a Maven jar dependency.
Hope this helps!
Here a solution with java doclets (no swagger annotations are required). Use the maven-javadoc-plugin and configure the swagger-doclet as an alternate doclet. With maven profiles it is possible to manage different environments:
<profile>
<id>dev</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>generate-service-docs</id>
<phase>generate-resources</phase>
<configuration>
<doclet>com.carma.swagger.doclet.ServiceDoclet</doclet>
<docletArtifact>
<groupId>com.carma</groupId>
<artifactId>swagger-doclet</artifactId>
<version>1.0.3</version>
</docletArtifact>
<reportOutputDirectory>${project.build.outputDirectory}</reportOutputDirectory>
<useStandardDocletOptions>false</useStandardDocletOptions>
<additionalparam>-apiVersion 1 -docBasePath
https://example.com/apidocs -apiBasePath
https://example.com/api -swaggerUiPath
../../../src/main/resources/swagger-ui/
</additionalparam>
</configuration>
<goals>
<goal>javadoc</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
I put the swagger resources directly into my project. So it was easy to customize the css and html.
Or, if you do not want to put swagger into your repository, you could use the frotend-maven-plugin to manage your js/css dependencies (like: swagger-ui) with bower.
I deliver swagger as static resources from the embedded server directly (in my case I used grizzly) :
String apiDocs = Env.getApiDocs();
server.getServerConfiguration().addHttpHandler(
new CLStaticHttpHandler(GrizzlyStarter.class.getClassLoader(), apiDocs), apiDocs);
I was faced with the same problem and created a library that if included into a Jersey project will add swagger 3.0 UI. Please take a look code and blog post The idea is that all swagger UI static content is packaged withing the library and extracted at runtime. In addition, library will take care of creating web context for swagger UI and adjust reference to the openapi.json file. You will need to add 2 properties and this code to your project:
SwaggerContext.addSwaggerServlet(tomcat, context,
ConfigBuilder.builder(ConfigType.TYPE_SAFE)
.build()
.getConfig("swagger"),
EmailApplication.class);
and properties:
swagger.package="com.itzap"
swagger.apiBaseUrl="http://{application url}"
If all other configuration is left at defaults swagger UI can be accessed over this URL:
http://{application base URL}/api/v1/swagger
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-preview config file), I get:
org.jboss.as.server.deployment.DeploymentUnitProcessingException: Only one JAX-RS Application Class allowed.
I've done a bit of hunting around on it and found that RestEasy is the default JAX-RS implementation embedded into Application Server. Posts like http://community.jboss.org/message/579996 and https://issues.jboss.org/browse/JBAS-8830) mention that the RestEasy deployer takes over.
In AS 6, it seems easier to remove the deployer whereas I have not seen any solutions for AS 7.
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
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
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.
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclude-subsystems>
<subsystem name="jaxrs" />
</exclude-subsystems>
</deployment>
</jboss-deployment-structure>
Will do the trick, works great with 7.3AS.ctomc just missed a tiny slash in the end to terminate the section.:-)
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>-->
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.
Ahother option:
Edit standalone/configuration/standalone.xml and comments out all jaxrs entries. This will configure Jersey instead of RESTEasy.
Remove jboss-web.xml from WEB-INF/web.xml. This file no longers works with JBoss 7
Edit web.xml, add an init-param com.sun.jersey.config.property.packages configured to your resource's package, like:
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>org.foo</param-value>
</init-param>
https://github.com/Atmosphere/atmosphere/wiki/Deploying-Atmosphere-Jersey-in-JBoss-7.1.x
You can get past this in the standalone configuration by modifying configuration/standalone.xml and removing references to jaxrs in the extensions and profile section. Note, even though I commented those portions out in my standalone.xml, JBoss will automagically remove those references altogether on next startup...
Here is what worked for me for JBoss 7.1.1 and Jersey 1.17.1. No need to modify standalone.xml or domain.xml. Besides filtering restEasy in web.xml instruct Jersey to use Jackson. You can read about this configuration here.
To save time in configuration guesses, I am posting web.xml and pom.xml from test project.
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>TestJerseyonJBoss</display-name>
<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.test.rest</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<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>
</web-app>
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestJerseyOnJBoss</groupId>
<artifactId>TestJerseyOnJBoss</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.3.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
You should exclude jaxrs subsystem from being activated for your deployment
add this into META-INF/jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclude-subsystems>
<subsystem name="jaxrs" />
</exclude-subsystems>
<deployment>
</jboss-deployment-structure>
or you can go to standalone.xml and remove subsystem there.
To do so, you need to remove
<subsystem xmlns="urn:jboss:domain:jaxrs:1.0">
...
...
<subsystem>
part of configuration, extension part of on top can stay it wont hurt either way.
or you can connect to server with CLI and run
/subsystem=webservices:remove()
Just a note, exclude-subsystems functionality and deployment-strucure:1.2 was added in 7.1.2 and as such will not work on on 7.1.1.