Ok so I tried to set-up a Jax-rs environment with CXF but unfortanetely I have been getting a very troublesome error that I cannot go around. I am running my application on a Java Web Tomcat 8 Server. My pom.xml file is the following
some irrelevant code..
<modelVersion>4.0.0</modelVersion>
<artifactId>calculatorWeb</artifactId>
<packaging>war</packaging>
<properties>
<maven.test.skip>${skipUnitTests}</maven.test.skip>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>WebContent\WEB-INF\web.xml</webXml>
<webResources>
<resource>
<directory>lib</directory>
<targetPath>WEB_INF/lib</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.6.1</version>
</dependency>
</dependencies>
Everything seems fine with the pom.xml file and when I produce the .war file the lib folder is in the WEB-INF folder. The relevant part of my web.xml file is the following:
<servlet>
<display-name>CXFNonSpringJaxrsServlet</display-name>
<servlet-name>CXFNonSpringJaxrsServlet</servlet-name>
<servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
</servlet-class>
<init-param>
<param-name>javax.ws.rs.core.Application</param-name>
<param-value>calculator.CalculatorApplication</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>CXFNonSpringJaxrsServlet</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
The general project structure is as follows:
-root
- lib
- src
- main
- java
- calculator
- CalculatorApplication.java
- CalculatorResource.java
- test
- target
- WebContent
- WEB-INF
- web.xml
- resources
- META-INF
- MANIFEST.MF
- pom.xml
If you need more information I am happy to provide it. Thank you in advance!