build() method of javax.ws.rs.core.Response throwing java.lang.ClassNotFoundException: Unable to load class 'org.apache.cxf.jaxrs.impl.ResponseImpl in Fuse Fabric

Solution Unverified - Updated -

Issue

  • We are trying to build javax.ws.rs.core.Response object using below code throwing java.lang.ClassNotFoundException after deploying to Fuse using Fabric. Working fine when tested from local camel context.
public void buildResponse(Exchange exchange) {
        log.info("in buildResponse method");
        String httpResponseCode = (String)exchange.getIn().getHeader("httpResponseCode");
        Response httpResponseCodeWithBody = Response.status(Integer.parseInt(httpResponseCode)).entity(exchange.getIn().getBody()).build();
        exchange.getOut().setBody(httpResponseCodeWithBody);
    }

Here is the exception stack trace:

Exception stack trace :
Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/jaxrs/impl/ResponseImpl
  at org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl.createResponseBuilder(RuntimeDelegateImpl.java:87)[org.apache.cxf:cxf-rt-frontend-jaxrs:3.1.5.redhat-630187]
  at javax.ws.rs.core.Response$ResponseBuilder.newInstance(Response.java:848)[org.apache.servicemix.specs:org.apache.servicemix.specs.jsr339-api-2.0.1:2.7.0 javax.ws.rs:javax.ws.rs-api:2.0.1 org.apache.servicemix.specs:org.apache.servicemix.specs.locator:2.7.0]
  at javax.ws.rs.core.Response.status(Response.java:613)[org.apache.servicemix.specs:org.apache.servicemix.specs.jsr339-api-2.0.1:2.7.0 javax.ws.rs:javax.ws.rs-api:2.0.1 org.apache.servicemix.specs:org.apache.servicemix.specs.locator:2.7.0]
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_101]
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_101]
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_101]
  at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_101]
  at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:408)[org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]
  at org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:279)[org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]
  at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:252)[org.apache.camel:camel-core:2.17.0.redhat-630187 com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2]
... 69 more
Caused by: java.lang.ClassNotFoundException: Unable to load class 'org.apache.cxf.jaxrs.impl.ResponseImpl' because the bundle wiring for org.apache.cxf.cxf-rt-frontend-jaxrs is no longer valid.

  at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1521)
  at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:77)
  at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1993)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_101]

  • In our application, we are able to see the package by running the below command.
JBossFuse:admin@child> packages:exports | grep org.apache.cxf.jaxrs.impl
   221 org.apache.cxf.jaxrs.impl; version=3.1.5
   221 org.apache.cxf.jaxrs.impl.tl; version=3.1.5

Environment

  • Red Hat JBoss Fuse
    • 6.2.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content