11

I am getting below exception whenever my REST client code makes a call to the REST service using below code: Code:

public void putWatcher(Watcher watcher)
    {
        System.out.println("In REST Client putWatcher.***********");

        target = target.path(RESOURCE_WATCHERS).path(watcher.getWatcheruri());
        System.out.println(target.getUri());
        Invocation.Builder builder = target.request();
        builder.put(Entity.json(watcher));
//      Response response = target.request().put(Entity.json(watcher));
        System.out.println("Returned from REST Call");
    }

Exception:

: javax.ws.rs.ProcessingException: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family;
    at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:255)
    at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:667)
    at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:664)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:664)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:424)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.put(JerseyInvocation.java:318)

Caused by: java.lang.NoSuchMethodError: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family;
    at org.glassfish.jersey.message.internal.Statuses$StatusImpl.<init>(Statuses.java:63)
    at org.glassfish.jersey.message.internal.Statuses$StatusImpl.<init>(Statuses.java:54)
    at org.glassfish.jersey.message.internal.Statuses.from(Statuses.java:93)
    at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:323)
    at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:227)
    at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:246)
    ... 29 more

My REST service is deployed on Tomcat 8 server and the client code is deployed on JBoss 7.2. The client application is SIP-Servlets application which also bundles REST client.

When I test the client as a standalone Java Application it works but when deployed on JBoss it gives the error. My POM file is:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
</dependency>
<!-- logging dependency -->
<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.14</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging-api</artifactId>
    <version>1.0.4</version>
    <scope>provided</scope>
</dependency>
<!-- web j2ee dependencies -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>
<!-- sip dependencies -->
<dependency>
    <groupId>org.mobicents.servlet.sip</groupId>
    <artifactId>sip-servlets-spec</artifactId>
    <version>1.7.0.FINAL</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>2.13</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-common</artifactId>
    <version>2.13</version>
</dependency>
<dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-mapper-asl</artifactId>
    <version>1.9.13</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-json-jackson</artifactId>
    <version>2.13</version>
</dependency>

I also try to do as suggested on this link https://github.com/gondor/openstack4j/issues/30 It says to disable JAX-RS from JBOSS config standalone.xml. I am using standalone-sip.xml while starting the server so I modified that only. Removed these two lines:

<subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>
<extension module="org.jboss.as.jaxrs"/>

This also is not working. I don't know how to disable, just searched for JAX-RS and deleted those lines where I found those.

In one SO post there was a suggestion to use javax.ws.rs.core.Response respone instead of Response response tried that also but no luck.

One more info: the REST call itself is successful, that I can see on tomcat server.

Please suggest what else can be done.

Thanks

1
  • I got this exception when generating token we havent passed client id and secret,grant type all these parameters programatically.
    – Ravi
    Commented Jun 9, 2022 at 19:18

3 Answers 3

9

I recently bumped into this problem. It was caused by a library providing an old implementation of javax.ws.rs.core. I fixed it as follows:

    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-jaxws</artifactId>
        <version>1.6.2</version>
        <scope>runtime</scope>
        <exclusions>
            <!-- Causes java.lang.NoSuchMethodError: javax.ws.rs.core.Response$Status$Family.familyOf(I)Ljavax/ws/rs/core/Response$Status$Family; -->
            <exclusion>
                <groupId>javax.ws.rs</groupId>
                <artifactId>jsr311-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
2
  • Which version of jsr should I use instead, in case I have to mantain it? Commented Feb 5, 2018 at 15:41
  • Yes this work, but i don't understand how... Shouldn't we have to replace this 'old implementation' instead of just remove it? How did you come up with this solution? Commented Aug 1, 2018 at 10:39
3

Can you take a look at libraries catalogue of your JBoss instance and remove all implementations of JAX-WS? To me it seems they conflict with the Jersey you bundle in your WAR-file.

Edit:

Actually I guess you need to resolve JAX-WS version conflict between your server and web application. Method familyOf you are missing in Response.Status.Family was introduced in Java 7 but is missing from Java EE 6. So find Java EE 6 compatible Jersey version or upgrade the server.

And if later Maven will cause problems, then for the real kick, there's also

mvn dependency:tree

and

<dependency>
...
        <exclusions>
            <exclusion>...</exclusion>
1
  • If I delete the jar then JBoss doesn't start. Commented Dec 6, 2014 at 21:17
-2

I encountered a similar error. "java.lang.NoSuchMethodError: javax/ws/rs/ClientErrorException.validate(Ljavax/ws/rs/core/Response;Ljavax/ws/rs/core/Response$Status$Family;"

Root cause: web service performance tester invoke the web service using script without passing in correct request body. missing a "/" in the path url of web service call is another case.

when you see this validation error, that means some major error already happened, this noSuchMethodError is only a minor byproduct when handling the major error.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.