Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Wink Accept() fails with NullPointerException

Tags:

apache-wink

I am deploying my RESTful web application on jBoss EAP 6.1 (7.2.1Final) with Wink 1.2 and getting following exception on all the request;

     <b>JBWEB000070: exception</b>
            <pre>java.lang.NullPointerException
org.apache.wink.common.internal.http.Accept.valueOf(Accept.java:139)
org.apache.wink.server.internal.contexts.HttpHeadersImpl.getAcceptHeader(HttpHeadersImpl.java:152)
org.apache.wink.server.internal.contexts.HttpHeadersImpl.getAcceptableMediaTypes(HttpHeadersImpl.java:106)
org.apache.wink.server.internal.registry.ResourceRegistry.filterByProduces(ResourceRegistry.java:558)
org.apache.wink.server.internal.registry.ResourceRegistry.filterDispatchMethods(ResourceRegistry.java:482)
org.apache.wink.server.internal.registry.ResourceRegistry.findMethod(ResourceRegistry.java:359)
org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleResourceMethod(FindResourceMethodHandler.java:138)
org.apache.wink.server.internal.handlers.FindResourceMethodHandler.handleRequest(FindResourceMethodHandler.java:65)
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:63)
org.apache.wink.server.internal.handlers.FindRootResourceHandler.handleRequest(FindRootResourceHandler.java:95)
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:63)

The same application works OK on previous versions of jBoss like EAP 5.1 and old.

I have also captured the posted request using tcpmon and getting following information in headers;

    GET /hothouse-iris/Hothouse.svc/ HTTP/1.1
    Host: 127.0.0.1:9090
    Connection: keep-alive
    Authorization: Basic U1NPVVNFUjE6MTIzNDU2
    Cache-Control: no-cache
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36
    Content-Type: application/atom+xml
    Accept: */*
    Accept-Encoding: gzip,deflate,sdch
    Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
    Cookie: JSESSIONID=8D9FE5379FE7576610BB4B78A431AD10; __utma=96992031.2145502422.1381922298.1382004674.1382006170.4; __utmc=96992031; __utmz=96992031.1381922298.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)

I am using Chrome extension POSTMan to request my service and it works.

like image 521
SJunejo Avatar asked Nov 19 '25 06:11

SJunejo


2 Answers

The problem is that initialization of Accept class does not actually happen, and the delegate field is null.

The RuntimeDelegate is an interface whose implementation should be specified in META-INF/service/javax.ws.rs.ext.RuntimeDelegate file which is searched on the class path.

wink-common.jar contains such a service file with the correct class name of the implementation but if some other service file with the same name is found on class path (on of the jars) before the correct one, we will have such a weird behavior.

like image 93
Vasile Rotaru Avatar answered Nov 21 '25 09:11

Vasile Rotaru


The problem was that JAX-RS implementation provided by jboss 7 was conflicting with Apache Wink, we had to disable jboss impl completely by commenting the contents of module.xml under JBOSS_HOME\modules\system\layers\base\javax\ws\rs\api\main to stop loading the Jboss JAX-RS API and it worked fine

like image 26
SJunejo Avatar answered Nov 21 '25 09:11

SJunejo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!