Java RestFull WebService: JAX-RS implementation with Jersey 2.3.1 libraries -


i trying run simple "hallo world" application jersey 2.3.1 rest service on jboss jboss-eap-6.1 as. in web.xml have disabled resteasy library. during deployment getting error:

jbweb000289: servlet com.sun.jersey.samples.helloworld.resources.myapplication threw load() exception: java.lang.nosuchmethoderror: javax.ws.rs.core.application.getproperties()ljava/util/map;

in pom put these dependencies:

<dependency>     <groupid>org.glassfish.jersey.core</groupid>     <artifactid>jersey-server</artifactid>     <version>2.3.1</version> </dependency> <dependency>     <groupid>org.glassfish.jersey.containers</groupid>     <artifactid>jersey-container-servlet-core</artifactid>     <version>2.3.1</version> </dependency> <dependency>     <groupid>javax.ws.rs</groupid>     <artifactid>javax.ws.rs-api</artifactid>     <version>2.0</version> </dependency> 

this web.xml resteasy tags disabling:

<?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">     <servlet>         <servlet-name>com.sun.jersey.samples.helloworld.resources.myapplication</servlet-name>         <servlet-class>org.glassfish.jersey.servlet.servletcontainer</servlet-class>         <init-param>             <param-name>javax.ws.rs.application</param-name>             <param-value>com.sun.jersey.samples.helloworld.resources.myapplication</param-value>         </init-param>            <load-on-startup>1</load-on-startup>     </servlet>     <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>     <servlet-mapping>         <servlet-name>com.sun.jersey.samples.helloworld.resources.myapplication</servlet-name>         <url-pattern>/*</url-pattern>     </servlet-mapping> </web-app> 

and resource config java class:

package com.sun.jersey.samples.helloworld.resources; import org.glassfish.jersey.server.resourceconfig; public class myapplication extends  resourceconfig {          public myapplication() {             packages("com.sun.jersey.samples.helloworld.resources");           //super(helloworldresource.class);       } } 

someone have idea solve it? in advance, roberto

nosuchmethoderror means having 2 different versions of class on classpath. javax.ws.rs.core.application class have getproperties() method in jax-rs 2 version, not in jax-rs 1.x, guess somehow combining old 1.x jersey (or old rest api) current (2.3.1) one.

also package working in (com.sun.jersey - 'old' jersey package) points bit towards direction (although placing code package cannot cause mentioned problem), started jersey 1.x example base (there samples in jersey 2 well, see helloworld-webapp on jersey github).

is possible, resteasy (also containing javax.ws.rs.core.application class) not switched off , somehow defaults jax-rs 1.x version?

i start inspecting pom file, @ effective pom (if project descriptor has parent) , check on classpath - believe there 1.x version of javax.ws.rs-api somewhere. try clean compiled stuff , rebuild scratch.

speaking of dependencies, if list exhaustive (regarding jersey), have add jersey-common (2.3.1) dependency, during initialization, resourceconfig.packages() method calls packagescanner constructor, contains call reflectionhelper - , not part of server jar more.

hope helps.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -