82556

Tomcat 7 + Jersey 2.0 error

Question:

java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder; at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:289) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

Maven dependencies:

<dependency> <groupId>org.glassfish.jersey.ext</groupId> <artifactId>jersey-spring3</artifactId> <version>2.11</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.3.2</version> </dependency> <dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> <version>2.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.glassfish.jersey.connectors</groupId> <artifactId>jersey-apache-connector</artifactId> <version>2.10.1</version> </dependency> <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-servlet</artifactId> <version>2.11</version> </dependency> <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>2.11</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>1.8</version> </dependency> <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-common</artifactId> <version>2.11</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.2.3</version> </dependency> <dependency> <groupId>asm</groupId> <artifactId>asm-all</artifactId> <version>3.3.1</version> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> <version>2.2</version> </dependency> <dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-json-jackson</artifactId> <version>2.4.1</version> </dependency> <dependency> <groupId>org.glassfish.jersey.ext</groupId> <artifactId>jersey-spring3</artifactId> <version>2.11</version> </dependency> <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-servlet-core</artifactId> <version>2.9.1</version> </dependency> <dependency> <groupId>javax.ws.rs</groupId> <artifactId>jsr311-api</artifactId> <version>1.1.1</version> </dependency>

web.xml

<servlet> <servlet-name>MessageService</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>javax.ws.rs.core.Application</param-name> <param-value>MessageService</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>MessageService</servlet-name> <url-pattern>/api/*</url-pattern> </servlet-mapping>

Service class

@Path("/messageService") public class MessageService{ public MessageService() { } private static Logger logger = Logger.getLogger(MessageService.class); @GET @Path("/getMessages") @Produces(MediaType.APPLICATION_JSON) public List<MessageModel> getMessage(Integer subCatId) { return "something"; }

Have been struggling to find the cause of this error. Any help would be appreciated.

Answer1:

Looks like you have 2 colliding dependencies:

<dependency> <groupId>javax.ws.rs</groupId> <artifactId>jsr311-api</artifactId> <version>1.1.1</version> </dependency>

And:

<dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> <version>2.0</version> <scope>provided</scope> </dependency>

Try to remove 1.1.1 version.

Answer2:

Are you sure you have all the jars?

asm-5.0.jar asm-debug-all-5.0.3.jar gson-2.2.2.jar hk2-api-2.3.0.jar hk2-locator-2.3.0.jar hk2-utils-2.3.0.jar javassist-3.18.1-GA.jar javax.annotation-api-1.2.jar javax.inject-2.2.0.jar javax.servlet-api-3.1.0.jar javax.ws.rs-api-2.0.1.jar jaxb-api-2.2.10.jar jersey-apache-connector-2.12.jar jersey-client.jar jersey-common.jar jersey-container-grizzly2-http-2.1.jar jersey-container-servlet-core.jar jersey-container-servlet.jar jersey-guava-2.8.jar jersey-server.jar org.osgi.core-4.3.1.jar osgi-resource-locator-1.0.1.jar swt_win32_x86.jar validation-api-1.1.0.Final.jar

Recommend

  • Android FileProvider delete file
  • Celery + Redis - .get() hangs indefinitely after running smoothly for ~70 hours
  • why lock_guard can get an already locked mutex by unique_lock?
  • Client-Side: Accessing Windows Azure Drive?
  • How to set default security access for a Page Type in Silverstripe?
  • JENKINS: ERROR when I try to use an older JDK for a specific maven project
  • Get Users in Group from Azure AD via Microsoft Graph
  • Flask-Restful error: “as_view” method not inherited
  • Maven, ActionBarSherlock v4 and Roboguice v2 - How do I get it to build?
  • Regarding client side code generation from WSDL
  • Visual Studio 2008 and JavaScript brackets formatting
  • How can I create one checksum of two files in Maven to use it in the name of a directory
  • How can I include the Ivy dependency and none of its dependencies?
  • How to force Composer to download a local package?
  • composer dependency stating in doesn't have php-xsl
  • How to load Q library with Require.js?
  • maven jboss-as:start A required class was missing … org/sonaty…/ArtifactResolutionException
  • How do you create a Fuseki SPARQL server using the Apache Jena Java API?
  • Unzip archive in .Net CORE 1.0
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • Unable to install Git-core+svn by MacPorts
  • How to use JavaScript to determine whether a file exists in a directory?
  • How to determine if there are bytes available to be read from boost:asio:serial_port
  • How do I exclude a dependency in provided scope when running in Maven test scope?
  • Unity3D & Android: Difference between “UnityMain” and “main” threads?
  • Control modification in presentation layer
  • Counter field in MS Access, how to generate?
  • Spray.io: When (not) to use non-blocking route handling?
  • Javascript + PHP Encryption with pidCrypt
  • Websockets service method fails during R startup
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • How to get Windows thread pool to call class member function?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal