wso2 / msf4j

WSO2 Microservices Framework for Java (MSF4J)
http://wso2.com/products/microservices-framework-for-java/
Apache License 2.0
400 stars 348 forks source link

Need a way to provide a proper error message when the introspect.war is not deployed. Otherwise it'll cause NullPointerException in OAuth2SecurityInterceptor.java:118 #341

Open martnst opened 7 years ago

martnst commented 7 years ago

Hi,

I'm experimentally setting up a WOS2 MicroService secured with WSO2 Identity Server based on this example. Doing so I apparently run into an open issue of an unhandled NullPointerException. See this comment.

Here is the Stacktrace I get:

2017-01-27 12:12:21 WARN  MSF4JMessageProcessor:83 - Interceptors threw an exception
org.wso2.msf4j.internal.InterceptorException: Exception while executing preCalls
    at org.wso2.msf4j.internal.InterceptorExecutor.execPreCalls(InterceptorExecutor.java:69)
    at org.wso2.msf4j.internal.MSF4JMessageProcessor.dispatchMethod(MSF4JMessageProcessor.java:114)
    at org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:72)
    at org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler.lambda$publishToWorkerPool$12(WorkerPoolDispatchingSourceHandler.java:125)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
    at org.wso2.msf4j.security.oauth2.OAuth2SecurityInterceptor.validateToken(OAuth2SecurityInterceptor.java:118)
    at org.wso2.msf4j.security.oauth2.OAuth2SecurityInterceptor.preCall(OAuth2SecurityInterceptor.java:81)
    at org.wso2.msf4j.internal.InterceptorExecutor.execPreCalls(InterceptorExecutor.java:63)
    ... 6 more

Do you have any details on what it causing the NPE and how I can fix it in my setup?

martnst commented 7 years ago

Okay, turns out I simply forgot this step:

2) Copy resources/introspect.war to wso2is-5.1.0/repository/deployment/server/webapps directory.

thusithathilina commented 7 years ago

Did you able to get this solve?

martnst commented 7 years ago

Yes, as commented I forgot to add this introspect module.

In my opinion, however, there should still be added a more meaning full error message.

thusithathilina commented 7 years ago

@martnst Thanks for the info. We will look into this in future. I've marked this as an enhancement