Problems deploying JBOSS 6, JAX-RS with knitwear

My questions:

Q 1. How to enable packet scanning in JBOSS so that it can know where to look for implementation classes and providers (annotated using @Provider) in a war file?

Q 2. Why was my filter not registered by the application class and I had to do it in web.xml?

Scenario

I created a Jax-RS web service using Jersey and deployed it to JBOSS-6, firstly, I encountered an error that shows that JBOSS will not be able to scan through the packages that I provided in web.xml to find mine rest webservice services. So the way around was to create the Application class (I did not allow myself to use the ResourceConfig provided by Jersey for any specific reason) and registered my WebService implementation in the getClasses method, as shown below:

 public class MainApplication extends Application { @Override public Set<Class<?>> getClasses() { HashSet<Class<?>> set = new HashSet<Class<?>>(); set.add(RESTWSImplementation.class); set.add(SomeFilter.class); return set; } } 

it helped a little, but the filter was still not registered. i.e.

  set.add(SomeFilter.class); 

doesn't seem to work, so I mentioned this filter in my web.xml for example

 <init-param> <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name> <param-value>test.SomeFilter</param-value> </init-param> 

then everything worked perfectly. However, from the text below, I expected it to be registered immediately.

enter image description here

So again my questions are:

  • How to enable package scanning in JBOSS so that it can know where to look for implementation classes and providers (annotation using @Provider)?
  • Why was my filter not registered by the application class and I had to do it in web.xml?

Edit: 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>POCTEST</groupId> <artifactId>POCTEST</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <build> <sourceDirectory>src</sourceDirectory> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.6</version> <configuration> <warSourceDirectory>WebContent</warSourceDirectory> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>1.8</version> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20090211</version> </dependency> </dependencies> </project> 
+6
java jersey jboss jax-rs
source share
1 answer

please show your pom.xml.

Perhaps you are using:

  <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-json-provider</artifactId> <version>${jaksonVersion}</version> </dependency> 

Try:

  <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> <version>${restEasyVersion}</version> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jackson2-provider</artifactId> <version>${restEasyVersion}</version> </dependency> 

Edit:

Or you can try adding init param inside the servlet tag (in web.xml):

  <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>com.your.package</param-value> </init-param> 
+2
source share

All Articles