Java.lang.NoClassDefFoundError: javax / ws / rs / core / Configuration

I use a simple web service to relax and I use jboss 4.0, but I get the following exception ...

java.lang.NoClassDefFoundError: javax/ws/rs/core/Configuration

my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>RestfulWebService</display-name>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- <servlet>
    <servlet-name>HelloServlet</servlet-name>
    <load-on-startup>1</load-on-startup>
</servlet> -->
<!-- <servlet>
    <servlet-name>HelloServlet</servlet-name>
    <servlet-class>javax.ws.rs.core.Application</servlet-class>
</servlet> -->
<listener>
    <listener-class>
   org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
    </listener-class>
</listener> 
<!-- <context-param>
    <param-name>resteasy.scan</param-name>
    <param-value>true</param-value>
</context-param> -->

<servlet>
    <servlet-name>Resteasy</servlet-name>
    <servlet-class>
        org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
    </servlet-class>
    <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>com.websevices.TestService</param-value>
    </init-param>
</servlet>
<!-- <servlet-mapping>
        <servlet-name>javax.ws.rs.core.Application</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping> -->
<servlet-mapping>
    <servlet-name>Resteasy</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<context-param>
            <param-name>resteasy.servlet.mapping.prefix</param-name>
            <param-value>/rest</param-value>


+4
source share
2 answers

From the Exception, it is clear that the class loader cannot find the class configuration (from javax / ws / rs / core / Configuration).

Please check the classpath corresponding to the JAR file and make sure that the class file exists.

+2
source

​​ / . , , scope = 'provided', , :

, :

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

, copy javax.ws.rs-api classpath. <scope> </scope> :

:

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0.1</version>
</dependency>
+14

All Articles