title: WSO2 EMM server Cannot read property "accessToken" from null
body: <p>I am configuring WSO2 EMM (Ver 2.0.1) server on ubuntu (14.04) machine. All configuration look proper but when I try to authenticate on device on url</p>
  
  <p><a href="https://server-name:9443/emm-web-agent/enrollments/iOS/login-agent" rel="nofollow">https://server-name:9443/emm-web-agent/enrollments/iOS/login-agent</a></p>
  
  <p>Server throws error of Cannot read property "accessToken" from null</p>
  
  <p>Stack trace</p>
  
  <pre><code>[2016-05-16 15:22:33,696] ERROR {org.wso2.carbon.identity.oauth2.token.handlers.grant.PasswordGrantHandler} -  Token request with Password Grant Type for an invalid tenant : https://server-name:9
  
  [2016-05-16 15:22:33,785] ERROR {/modules/enrollments/ios/agent-controller.jag} -  Error in obtaining token with Password grant type
  
  [2016-05-16 15:22:33,805] ERROR {org.jaggeryjs.jaggery.core.manager.WebAppManager} -  org.mozilla.javascript.EcmaError: TypeError: Cannot read property "accessToken" from null (/emm-web-agent/modules/enrollments/ios/agent-controller.jag#53)
  
  org.jaggeryjs.scriptengine.exceptions.ScriptException: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "accessToken" from null (/emm-web-agent/modules/enrollments/ios/agent-controller.jag#53)
  at org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:571)
  at org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:273)
  at org.jaggeryjs.jaggery.core.manager.WebAppManager.exec(WebAppManager.java:587)
  at org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:507)
  at org.jaggeryjs.jaggery.core.JaggeryServlet.doPost(JaggeryServlet.java:29)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
  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:748)
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
  at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:378)
  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
  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.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  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:613)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
  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.webapp.authenticator.framework.WebappAuthenticationValve.invoke(WebappAuthenticationValve.java:43)
  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:950)
  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:421)
  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)
  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1739)
  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1698)
  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.mozilla.javascript.EcmaError: TypeError: Cannot read property "accessToken" from null (/emm-web-agent/modules/enrollments/ios/agent-controller.jag#53)
  at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3687)
  at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3665)
  at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3693)
  at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3712)
  at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3725)
  at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1483)
  at org.jaggeryjs.rhino.emm_web_agent.modules.enrollments.ios.c2._c_script_0(/emm-web-agent/modules/enrollments/ios/agent-controller.jag:53)
  at org.jaggeryjs.rhino.emm_web_agent.modules.enrollments.ios.c2.call(/emm-web-agent/modules/enrollments/ios/agent-controller.jag)
  at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
  at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
  at org.jaggeryjs.rhino.emm_web_agent.modules.enrollments.ios.c2.call(/emm-web-agent/modules/enrollments/ios/agent-controller.jag)
  at org.jaggeryjs.rhino.emm_web_agent.modules.enrollments.ios.c2.exec(/emm-web-agent/modules/enrollments/ios/agent-controller.jag)
  at org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:567)
  </code></pre>