2

I deployed 2 keymanager nodes, 2 pub-store nodes, 1 gateway manager node and 2 gateway worker nodes in one server, and deployed nginx for load balance. When i try to access API via API Console, it reported below error:

TID: [-1234] [] [2016-08-29 21:10:57,237]  WARN {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler} -  API authentication failure due to Unclassified Authentication Failure {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler}
TID: [-1234] [] [2016-08-29 21:10:57,238] ERROR {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler} -  API authentication failed with error 900900 {org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler}
org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityException: Error while accessing backend services for API key validation
    at org.wso2.carbon.apimgt.gateway.handlers.security.keys.WSAPIKeyDataStore.getAllURITemplates(WSAPIKeyDataStore.java:77)
    at org.wso2.carbon.apimgt.gateway.handlers.security.APIKeyValidator.getAllURITemplates(APIKeyValidator.java:635)
    at org.wso2.carbon.apimgt.gateway.handlers.security.APIKeyValidator.doGetAPIInfo(APIKeyValidator.java:487)
    at org.wso2.carbon.apimgt.gateway.handlers.security.APIKeyValidator.findMatchingVerb(APIKeyValidator.java:459)
    at org.wso2.carbon.apimgt.gateway.handlers.security.APIKeyValidator.getResourceAuthenticationScheme(APIKeyValidator.java:251)
    at org.wso2.carbon.apimgt.gateway.handlers.security.oauth.OAuthAuthenticator.authenticate(OAuthAuthenticator.java:119)
    at org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler.handleRequest(APIAuthenticationHandler.java:117)
    at org.apache.synapse.rest.API.process(API.java:325)
    at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:90)
    at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:69)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:300)
    at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:75)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:319)
    at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:152)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    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: org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityException: Error while accessing backend services for API key validation
    at org.wso2.carbon.apimgt.gateway.handlers.security.keys.APIKeyValidatorClient.getAllURITemplates(APIKeyValidatorClient.java:171)
    at org.wso2.carbon.apimgt.gateway.handlers.security.keys.WSAPIKeyDataStore.getAllURITemplates(WSAPIKeyDataStore.java:75)
    ... 18 more
Caused by: java.lang.NullPointerException
    at org.wso2.carbon.apimgt.gateway.handlers.security.keys.APIKeyValidatorClient.toTemplates(APIKeyValidatorClient.java:193)
    at org.wso2.carbon.apimgt.gateway.handlers.security.keys.APIKeyValidatorClient.getAllURITemplates(APIKeyValidatorClient.java:166)
    ... 19 more

What's the config issue?enter image description here

Emman Sun
  • 351
  • 3
  • 15

1 Answers1

2

This is a known issue, and is fixed in latest master. I'll check and update the answer if I can find a workaround.

Bee
  • 12,251
  • 11
  • 46
  • 73
  • 1
    After i fixed the code, i encountered another issue: 2016-08-30 04:36:49,465 [-] [PassThroughMessageProcessor-4] ERROR ServerWorker Error processing GET reguest for : /pizzashack/1.0.0/menu. Error detail: null. java.lang.NullPointerException at org.wso2.carbon.apimgt.gateway.handlers.throttling.ThrottleHandler.doRoleBasedAccessThrottlingWithCEP(ThrottleHandler.java:197) ... – Emman Sun Aug 30 '16 at 08:43
  • It seems it's due to i configed EnableAdvanceThrottling=false? from APIHandlerServiceComponent.java, if (this.configuration.getThrottleProperties().isEnabled()) {... ServiceReferenceHolder.getInstance().setThrottleDataHolder(throttleDataHolder); ...}. Is advance throttling MUST in APIM 2.0 now? – Emman Sun Aug 30 '16 at 10:04
  • It's not a must. I'll check and get back to you regarding the error. – Bee Aug 30 '16 at 13:29
  • If you correctly patched the code, and disabled advanced throttling, it should fix this. 1) How did you apply the patch? Can you try the same in a fresh pack? 2) Can you move to ThriftClient instead of WSClient? – Bee Aug 30 '16 at 17:16
  • I just applied [fixed in latest master](https://github.com/wso2/carbon-apimgt/pull/2880/files) to APIKeyValidatorClient. for 2) move to ThriftClient instead of WSClient, how to config ThriftServerHost/ThriftServerPort due to i have cluster of key-managers(2 nodes)? – Emman Sun Aug 31 '16 at 01:50
  • Ah, I don't think you can use Thrift option in that case. However, if you patch that properly, it should work with WSClient. How did you apply the change to server? replaced the jar in `plugins` or put the new jar to `patch directory`? You should use the latter approach. You have to create a directory like `patchxxxx` (eg. patch5000) inside `repository/components/patches/` directory and put the jar inside that. Then restart the server. – Bee Aug 31 '16 at 03:33
  • I cannot find the source code for that patch. Do you have any build version of it? I have the exact same defect. – pfernandom Jun 22 '17 at 22:19
  • https://patch-diff.githubusercontent.com/raw/wso2/carbon-apimgt/pull/2880.patch is the patch. You should apply this on v6.0.4 tag of https://github.com/wso2/carbon-apimgt – Praminda Jun 23 '17 at 10:47
  • Thank you, @praminda for the reply! However, I don't see any v6.0.4 tag (or branch) in that repo. The oldest tag is 6.1.28. Which one should I clone to use that patch with? – pfernandom Jun 26 '17 at 18:29
  • Github UI does not list all tags. It seems there's a limit. But the tag is there. You can check it out. – Bee Jun 26 '17 at 18:51
  • @pfernandom as Bhathiya mentioned the tag is there. But github doesn't show all tags. Do a **git fetch origin** and **git checkout v6.0.4** to checkout the tag – Praminda Jun 28 '17 at 15:07