wso2-am 2.0.0: "Error occurred while executing the action generateApplicationKey"
<p>I'm getting an error from the WSO2 API Manager Store when attempting to generate consumer key/secret pair.</p>

<p><a href="http://i.stack.imgur.com/8Mtyx.png" rel="nofollow">Screenshot: Error occurred while executing the action generateApplicationKey
</a></p>

<p>The logs contain about 1200 lines of stack trace, parts of which seem to repeat.  Here's a representative sample:</p>

<pre><code>TID: [-1234] [] [2016-09-22 13:57:11,563] ERROR {org.wso2.carbon.apimgt.impl.APIConsumerImpl} -  Could not execute Workflow {org.wso2.carbon.apimgt.impl.APIConsumerImpl}
org.wso2.carbon.apimgt.impl.workflow.WorkflowException: Error occurred when updating the status of the Application creation process
  at org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor.complete(ApplicationRegistrationSimpleWorkflowExecutor.java:82)
  at org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor.execute(ApplicationRegistrationSimpleWorkflowExecutor.java:54)
  at org.wso2.carbon.apimgt.impl.APIConsumerImpl.requestApprovalForApplicationRegistration(APIConsumerImpl.java:2790)
  at org.wso2.carbon.apimgt.impl.UserAwareAPIConsumer.requestApprovalForApplicationRegistration(UserAwareAPIConsumer.java:36)
  at org.wso2.carbon.apimgt.hostobjects.APIStoreHostObject.jsFunction_getApplicationKey(APIStoreHostObject.java:382)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
  at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:386)
  at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
  at org.jaggeryjs.rhino.store.modules.subscription.c3._c_anonymous_2(/store/modules/subscription/key.jag:39)
  at org.jaggeryjs.rhino.store.modules.subscription.c3.call(/store/modules/subscription/key.jag)
  at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2430)
  at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:269)
  at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:97)
  at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)
  at org.jaggeryjs.rhino.store.modules.subscription.c0._c_anonymous_11(/store/modules/subscription/module.jag:38)
  at org.jaggeryjs.rhino.store.modules.subscription.c0.call(/store/modules/subscription/module.jag)
  at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
  at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0._c_anonymous_1(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag:240)
  at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.call(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
  at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
  at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
  at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.call(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
  at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.exec(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
  at org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:567)
  at org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:273)
  at org.jaggeryjs.jaggery.core.manager.WebAppManager.exec(WebAppManager.java:588)
  at org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:508)
  at org.jaggeryjs.jaggery.core.JaggeryServlet.doPost(JaggeryServlet.java:29)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
  at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:377)
  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)
  at org.jaggeryjs.jaggery.core.JaggeryFilter.doFilter(JaggeryFilter.java:21)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:120)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
  at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:99)
  at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
  at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:57)
  at org.wso2.carbon.event.receiver.core.internal.tenantmgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:48)
  at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
  at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:62)
  at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:159)
  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
  at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1749)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1708)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.lang.Thread.run(Thread.java:745)
Caused by: org.wso2.carbon.apimgt.api.APIManagementException: Error occurred while executing SubscriberKeyMgtClient.
  at org.wso2.carbon.apimgt.impl.utils.APIUtil.handleException(APIUtil.java:1195)
  at org.wso2.carbon.apimgt.impl.workflow.AbstractApplicationRegistrationWorkflowExecutor.dogenerateKeysForApplication(AbstractApplicationRegistrationWorkflowExecutor.java:155)
  at org.wso2.carbon.apimgt.impl.workflow.AbstractApplicationRegistrationWorkflowExecutor.generateKeysForApplication(AbstractApplicationRegistrationWorkflowExecutor.java:118)
  at org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor.complete(ApplicationRegistrationSimpleWorkflowExecutor.java:78)
  ... 72 more
Caused by: org.wso2.carbon.apimgt.api.APIManagementException: Can not create OAuth application  : DefaultApplication_PRODUCTION
  at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.handleException(AMDefaultKeyManagerImpl.java:636)
  at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.createApplication(AMDefaultKeyManagerImpl.java:110)
  at org.wso2.carbon.apimgt.impl.workflow.AbstractApplicationRegistrationWorkflowExecutor.dogenerateKeysForApplication(AbstractApplicationRegistrationWorkflowExecutor.java:139)
  ... 74 more
Caused by: org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
  at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:326)
  at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:196)
  at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
  at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:451)
  at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:278)
  at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
  at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:430)
  at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
  at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
  at org.wso2.carbon.apimgt.keymgt.stub.subscriber.APIKeyMgtSubscriberServiceStub.createOAuthApplicationByApplicationInfo(APIKeyMgtSubscriberServiceStub.java:2393)
  at org.wso2.carbon.apimgt.keymgt.client.SubscriberKeyMgtClient.createOAuthApplicationbyApplicationInfo(SubscriberKeyMgtClient.java:62)
  at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.createApplication(AMDefaultKeyManagerImpl.java:108)
  ... 75 more
TID: [-1234] [] [2016-09-22 13:57:11,569] ERROR {org.wso2.carbon.apimgt.hostobjects.APIStoreHostObject} -  Error while obtaining the application access token for the application:DefaultApplication {org.wso2.carbon.apimgt.hostobjects.APIStoreHostObject}
org.wso2.carbon.apimgt.api.APIManagementException: Could not execute Workflow
  at org.wso2.carbon.apimgt.impl.APIConsumerImpl.requestApprovalForApplicationRegistration(APIConsumerImpl.java:2815)
  at org.wso2.carbon.apimgt.impl.UserAwareAPIConsumer.requestApprovalForApplicationRegistration(UserAwareAPIConsumer.java:36)
  at org.wso2.carbon.apimgt.hostobjects.APIStoreHostObject.jsFunction_getApplicationKey(APIStoreHostObject.java:382)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
  at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:386)
  at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
  at org.jaggeryjs.rhino.store.modules.subscription.c3._c_anonymous_2(/store/modules/subscription/key.jag:39)
  at org.jaggeryjs.rhino.store.modules.subscription.c3.call(/store/modules/subscription/key.jag)
  at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2430)
  at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:269)
  at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:97)
  at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)
  at org.jaggeryjs.rhino.store.modules.subscription.c0._c_anonymous_11(/store/modules/subscription/module.jag:38)
  at org.jaggeryjs.rhino.store.modules.subscription.c0.call(/store/modules/subscription/module.jag)
  at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
  at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0._c_anonymous_1(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag:240)
  at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.call(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
  at org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:23)
  at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0._c_script_0(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag:3)
  at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.call(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
  at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
  at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
  at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.call(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
  at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.exec(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
  at org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:567)
  at org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:273)
  at org.jaggeryjs.jaggery.core.manager.WebAppManager.exec(WebAppManager.java:588)
  at org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:508)
  at org.jaggeryjs.jaggery.core.JaggeryServlet.doPost(JaggeryServlet.java:29)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
  at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:377)
  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)
  at org.jaggeryjs.jaggery.core.JaggeryFilter.doFilter(JaggeryFilter.java:21)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:120)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
  at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:99)
  at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
  at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:57)
  at org.wso2.carbon.event.receiver.core.internal.tenantmgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:48)
  at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
  at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:62)
  at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:159)
  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
  at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1749)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1708)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  at java.lang.Thread.run(Thread.java:745)
Caused by: org.wso2.carbon.apimgt.impl.workflow.WorkflowException: Error occurred when updating the status of the Application creation process
  at org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor.complete(ApplicationRegistrationSimpleWorkflowExecutor.java:82)
  at org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor.execute(ApplicationRegistrationSimpleWorkflowExecutor.java:54)
  at org.wso2.carbon.apimgt.impl.APIConsumerImpl.requestApprovalForApplicationRegistration(APIConsumerImpl.java:2790)
  ... 70 more
Caused by: org.wso2.carbon.apimgt.api.APIManagementException: Error occurred while executing SubscriberKeyMgtClient.
  at org.wso2.carbon.apimgt.impl.utils.APIUtil.handleException(APIUtil.java:1195)
  at org.wso2.carbon.apimgt.impl.workflow.AbstractApplicationRegistrationWorkflowExecutor.dogenerateKeysForApplication(AbstractApplicationRegistrationWorkflowExecutor.java:155)
  at org.wso2.carbon.apimgt.impl.workflow.AbstractApplicationRegistrationWorkflowExecutor.generateKeysForApplication(AbstractApplicationRegistrationWorkflowExecutor.java:118)
  at org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor.complete(ApplicationRegistrationSimpleWorkflowExecutor.java:78)
  ... 72 more 
Caused by: org.wso2.carbon.apimgt.api.APIManagementException: Can not create OAuth application  : DefaultApplication_PRODUCTION
  at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.handleException(AMDefaultKeyManagerImpl.java:636)
  at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.createApplication(AMDefaultKeyManagerImpl.java:110)
  at org.wso2.carbon.apimgt.impl.workflow.AbstractApplicationRegistrationWorkflowExecutor.dogenerateKeysForApplication(AbstractApplicationRegistrationWorkflowExecutor.java:139)
  ... 74 more
Caused by: org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
  at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:326)
  at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:196)
  at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
  at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:451)
  at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:278)
  at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
  at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:430)
  at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
  at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
  at org.wso2.carbon.apimgt.keymgt.stub.subscriber.APIKeyMgtSubscriberServiceStub.createOAuthApplicationByApplicationInfo(APIKeyMgtSubscriberServiceStub.java:2393)
  at org.wso2.carbon.apimgt.keymgt.client.SubscriberKeyMgtClient.createOAuthApplicationbyApplicationInfo(SubscriberKeyMgtClient.java:62)
  at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.createApplication(AMDefaultKeyManagerImpl.java:108)
  ... 75 more
TID: [-1234] [] [2016-09-22 13:57:11,574] ERROR {JAGGERY.site.blocks.subscription.subscription-add.ajax.subscription-add:jag} -  org.jaggeryjs.scriptengine.exceptions.ScriptException: Error while obtaining the application access token for the application:DefaultApplication {JAGGERY.site.blocks.subscription.subscription-add.ajax.subscription-add:jag}
</code></pre>

<p>The "401 Error: Unauthorized" seems like it might be the key, but I know my credentials are correct because I used them to log in.</p>

<p>What's particularly interesting is, I only get this error when I'm using my company's LDAP server as the primary user store.</p>

<p>Here's a snippet from my {server-home}/repository/conf/user-mgt.xml:</p>

<pre><code>&lt;UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadOnlyLDAPUserStoreManager"&gt;
    &lt;Property name="TenantManager"&gt;org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager&lt;/Property&gt;
    &lt;Property name="ConnectionURL"&gt;ldap://localhost:1389&lt;/Property&gt;
    &lt;Property name="ConnectionName"&gt;CN=Steven McClellan,CN=Users,DC=Nanofluidics,DC=com&lt;/Property&gt;
    &lt;Property name="ConnectionPassword"&gt;passwordgoeshere&lt;/Property&gt;
    &lt;Property name="UserSearchBase"&gt;CN=Users,DC=Nanofluidics,DC=com&lt;/Property&gt;
    &lt;Property name="UserNameAttribute"&gt;uid&lt;/Property&gt;
    &lt;Property name="UserNameSearchFilter"&gt;(&amp;amp;(objectClass=person)(uid=?))&lt;/Property&gt;
    &lt;Property name="UserNameListFilter"&gt;(objectClass=person)&lt;/Property&gt;
    &lt;Property name="DisplayNameAttribute"/&gt;
    &lt;Property name="ReadGroups"&gt;true&lt;/Property&gt;
    &lt;Property name="GroupSearchBase"&gt;CN=Users,DC=Nanofluidics,DC=com&lt;/Property&gt;
    &lt;Property name="GroupNameAttribute"&gt;cn&lt;/Property&gt;
    &lt;Property name="GroupNameSearchFilter"&gt;(&amp;amp;(objectClass=group)(cn=?))&lt;/Property&gt;
    &lt;Property name="GroupNameListFilter"&gt;(objectClass=group)&lt;/Property&gt;
    &lt;Property name="MembershipAttribute"&gt;member&lt;/Property&gt;
    &lt;Property name="BackLinksEnabled"&gt;false&lt;/Property&gt;
    &lt;Property name="UsernameJavaRegEx"&gt;[a-zA-Z0-9._-|//]{3,50}$&lt;/Property&gt;
    &lt;Property name="PasswordJavaRegEx"&gt;^[\S]{5,50}$&lt;/Property&gt;
    &lt;Property name="RolenameJavaRegEx"&gt;[a-zA-Z0-9._-|//]{3,100}$&lt;/Property&gt;
    &lt;Property name="SCIMEnabled"&gt;false&lt;/Property&gt;
    &lt;Property name="PasswordHashMethod"&gt;PLAIN_TEXT&lt;/Property&gt;
    &lt;Property name="MultiAttributeSeparator"&gt;,&lt;/Property&gt;
    &lt;Property name="MaxUserNameListLength"&gt;100&lt;/Property&gt;
    &lt;Property name="MaxRoleNameListLength"&gt;100&lt;/Property&gt;
    &lt;Property name="UserRolesCacheEnabled"&gt;true&lt;/Property&gt;
    &lt;Property name="ConnectionPoolingEnabled"&gt;true&lt;/Property&gt;
    &lt;Property name="LDAPConnectionTimeout"&gt;5000&lt;/Property&gt;
    &lt;Property name="ReadTimeout"/&gt;
    &lt;Property name="RetryAttempts"/&gt;
    &lt;Property name="ReplaceEscapeCharactersAtUserLogin"&gt;true&lt;/Property&gt;
&lt;/UserStoreManager&gt;
</code></pre>

<p>(Note that I'm connecting to the LDAP server via an ssh tunnel at localhost:1389)</p>

<p>When I instead configure to connect to the <a href="http://www.forumsys.com/en/tutorials/integration-how-to/ldap/online-ldap-test-server/" rel="nofollow">test ldap server at forumsys.com</a>, I'm able to generate application key/secret pairs successfully.  Here's a snippet of the user-mgt.xml for that setup:</p>

<pre><code>&lt;UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadOnlyLDAPUserStoreManager"&gt;
    &lt;Property name="TenantManager"&gt;org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager&lt;/Property&gt;
    &lt;Property name="ConnectionURL"&gt;ldap://ldap.forumsys.com:389&lt;/Property&gt;
    &lt;Property name="ConnectionName"&gt;cn=read-only-admin,dc=example,dc=com&lt;/Property&gt;
    &lt;Property name="ConnectionPassword"&gt;password&lt;/Property&gt;
    &lt;Property name="UserSearchBase"&gt;dc=example,dc=com&lt;/Property&gt;
    &lt;Property name="UserNameAttribute"&gt;cn&lt;/Property&gt;
    &lt;Property name="UserNameSearchFilter"&gt;(&amp;amp;(objectClass=person)(cn=?))&lt;/Property&gt;
    &lt;Property name="UserNameListFilter"&gt;(objectClass=person)&lt;/Property&gt;
    &lt;Property name="DisplayNameAttribute"/&gt;
    &lt;Property name="ReadGroups"&gt;true&lt;/Property&gt;
    &lt;Property name="GroupSearchBase"&gt;dc=example,dc=com&lt;/Property&gt;
    &lt;Property name="GroupNameAttribute"&gt;cn&lt;/Property&gt;
    &lt;Property name="GroupNameSearchFilter"&gt;(&amp;amp;(objectClass=groupOfUniqueNames)(cn=?))&lt;/Property&gt;
    &lt;Property name="GroupNameListFilter"&gt;(objectClass=groupOfUniqueNames)&lt;/Property&gt;
    &lt;Property name="MembershipAttribute"&gt;uniqueMember&lt;/Property&gt;
    &lt;Property name="BackLinksEnabled"&gt;false&lt;/Property&gt;
    &lt;Property name="UsernameJavaRegEx"&gt;[a-zA-Z0-9._-|//]{3,30}$&lt;/Property&gt;
    &lt;Property name="PasswordJavaRegEx"&gt;^[\S]{5,30}$&lt;/Property&gt;
    &lt;Property name="RolenameJavaRegEx"&gt;[a-zA-Z0-9._-|//]{3,30}$&lt;/Property&gt;
    &lt;Property name="SCIMEnabled"&gt;false&lt;/Property&gt;
    &lt;Property name="PasswordHashMethod"&gt;PLAIN_TEXT&lt;/Property&gt;
    &lt;Property name="MultiAttributeSeparator"&gt;,&lt;/Property&gt;
    &lt;Property name="MaxUserNameListLength"&gt;100&lt;/Property&gt;
    &lt;Property name="MaxRoleNameListLength"&gt;100&lt;/Property&gt;
    &lt;Property name="UserRolesCacheEnabled"&gt;true&lt;/Property&gt;
    &lt;Property name="ConnectionPoolingEnabled"&gt;true&lt;/Property&gt;
    &lt;Property name="LDAPConnectionTimeout"&gt;5000&lt;/Property&gt;
    &lt;Property name="ReadTimeout"/&gt;
    &lt;Property name="RetryAttempts"/&gt;
    &lt;Property name="ReplaceEscapeCharactersAtUserLogin"&gt;true&lt;/Property&gt;
&lt;/UserStoreManager&gt;
</code></pre>

<p>Also noteworthy is the fact that this is the <em>only</em> operation that fails with this configuration. (That I'm aware of.) I'm able to log in to the /carbon, /publisher, and /store pages. I'm able to create, manage, publish, and subscribe to APIs. I'm able to create and manage users and roles. Etc., etc.</p>

<p>So I'm pretty confused. Can anyone help me out?</p>