By: chiran wijesekara user 21 Oct 2017 at 8:43 p.m. CDT

9 Responses
chiran wijesekara gravatar
I'm following this (https://gluu.org/docs/oxd/libraries/java/) and i've successfully done up to getting authorization url step. After that, i tried Get "Tokens By Code" step. I sent all three required parameters but it throws null pointer exception. *********************LOG IS PASTED BELOW ************************ Info: 2017-10-22 06:58:21,560 TRACE [org.xdi.oxd.client.TransportClient] Send: 0800{"command":"register_site","params":{"scope":["openid","profile"],"contacts":null,"op_host":"https://accounts.google.com","op_discovery_path":null,"authorization_redirect_uri":"http://localhost:8080/testapp/welcome","post_logout_redirect_uri":null,"protection_access_token":null,"redirect_uris":null,"response_types":null,"claims_redirect_uri":null,"client_id":"237882107417-amlljkau52q3ejkt2i7mtuun88qjt88b.apps.googleusercontent.com","client_secret":"i0FCRUE0ZyCyNBnNnprpo6Bi","client_name":null,"client_jwks_uri":null,"client_token_endpoint_auth_method":null,"client_request_uris":null,"client_frontchannel_logout_uris":null,"client_sector_identifier_uri":null,"ui_locales":null,"claims_locales":null,"acr_values":null,"grant_types":null,"trusted_client":false,"oxd_rp_programming_language":null}} Info: 2017-10-22 06:58:21,563 TRACE [org.xdi.oxd.common.CoreUtils] commandSize: -1, stringStorage: Info: 2017-10-22 06:58:21,654 TRACE [org.xdi.oxd.common.CoreUtils] Parsed sizeString: 0112, commandSize: 112 Info: 2017-10-22 06:58:21,656 TRACE [org.xdi.oxd.common.CoreUtils] Read result: ReadResult{m_command='{"status":"ok","data":{"oxd_id":"50e4ca58-fadd-405e-9291-2d64ccdef3cb","op_host":"https://accounts.google.com"}}', m_leftString=''} Info: 2017-10-22 06:58:21,656 TRACE [org.xdi.oxd.client.TransportClient] Response: ReadResult{m_command='{"status":"ok","data":{"oxd_id":"50e4ca58-fadd-405e-9291-2d64ccdef3cb","op_host":"https://accounts.google.com"}}', m_leftString=''} Info: 2017-10-22 06:58:21,733 TRACE [org.xdi.oxd.client.TransportClient] Send: 0208{"command":"get_authorization_url","params":{"prompt":"login","scope":null,"oxd_id":"50e4ca58-fadd-405e-9291-2d64ccdef3cb","acr_values":null,"hd":null,"protection_access_token":null,"custom_parameters":null}} Info: 2017-10-22 06:58:21,733 TRACE [org.xdi.oxd.common.CoreUtils] commandSize: -1, stringStorage: Info: 2017-10-22 06:58:22,353 TRACE [org.xdi.oxd.common.CoreUtils] Parsed sizeString: 0344, commandSize: 344 Info: 2017-10-22 06:58:22,354 TRACE [org.xdi.oxd.common.CoreUtils] Read result: ReadResult{m_command='{"status":"ok","data":{"authorization_url":"https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=237882107417-amlljkau52q3ejkt2i7mtuun88qjt88b.apps.googleusercontent.com&redirect_uri=http://localhost:8080/testapp/welcome&scope=openid+profile&state=93f4a3dqql9lqpuh2u0e184ltn&nonce=2g00dajvlajnbkngam3asaf3la&prompt=login"}}', m_leftString=''} Info: 2017-10-22 06:58:22,354 TRACE [org.xdi.oxd.client.TransportClient] Response: ReadResult{m_command='{"status":"ok","data":{"authorization_url":"https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=237882107417-amlljkau52q3ejkt2i7mtuun88qjt88b.apps.googleusercontent.com&redirect_uri=http://localhost:8080/testapp/welcome&scope=openid+profile&state=93f4a3dqql9lqpuh2u0e184ltn&nonce=2g00dajvlajnbkngam3asaf3la&prompt=login"}}', m_leftString=''} Info: 2017-10-22 06:58:49,601 TRACE [org.xdi.oxd.client.TransportClient] Send: 0214{"command":"get_tokens_by_code","params":{"code":"4/zZZcbl5to6CseSg-jQGMY0C05ipVa2lspH0L1tb5i6A","state":"93f4a3dqql9lqpuh2u0e184ltn","oxd_id":"50e4ca58-fadd-405e-9291-2d64ccdef3cb","protection_access_token":null}} Info: 2017-10-22 06:58:49,604 TRACE [org.xdi.oxd.common.CoreUtils] commandSize: -1, stringStorage: Info: 2017-10-22 06:58:52,539 TRACE [org.xdi.oxd.common.CoreUtils] Parsed sizeString: 0112, commandSize: 112 Info: 2017-10-22 06:58:52,539 TRACE [org.xdi.oxd.common.CoreUtils] Read result: ReadResult{m_command='{"status":"error","data":{"error":"internal_error","error_description":"Unknown internal server error occurs."}}', m_leftString=''} Info: 2017-10-22 06:58:52,539 TRACE [org.xdi.oxd.client.TransportClient] Response: ReadResult{m_command='{"status":"error","data":{"error":"internal_error","error_description":"Unknown internal server error occurs."}}', m_leftString=''} Info: 2017-10-22 06:58:52,563 ERROR [org.xdi.oxd.common.CommandResponse] Unrecognized field "error" (Class org.xdi.oxd.common.response.GetTokensByCodeResponse), not marked as ignorable at [Source: java.io.StringReader@349b4e6a; line: 1, column: 11] (through reference chain: org.xdi.oxd.common.response.GetTokensByCodeResponse["error"]) org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "error" (Class org.xdi.oxd.common.response.GetTokensByCodeResponse), not marked as ignorable at [Source: java.io.StringReader@349b4e6a; line: 1, column: 11] (through reference chain: org.xdi.oxd.common.response.GetTokensByCodeResponse["error"]) at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53) at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267) at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:673) at org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:659) at org.codehaus.jackson.map.deser.BeanDeserializer.handleUnknownProperty(BeanDeserializer.java:1365) at org.codehaus.jackson.map.deser.BeanDeserializer._handleUnknown(BeanDeserializer.java:725) at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:703) at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580) at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2732) at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863) at org.xdi.oxd.common.CommandResponse.dataAsResponse(CommandResponse.java:71) at com.wijesekara.testapp.WelcomeServlet.processRequest(WelcomeServlet.java:45) at com.wijesekara.testapp.WelcomeServlet.doGet(WelcomeServlet.java:78) at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) at java.lang.Thread.run(Thread.java:748) Info: 2017-10-22 06:58:52,565 ERROR [org.xdi.oxd.common.CommandResponse] Unable to parse string to response, string: {"error":"internal_error","error_description":"Unknown internal server error occurs."} Warning: StandardWrapperValve[WelcomeServlet]: Servlet.service() for servlet WelcomeServlet threw exception java.lang.NullPointerException at com.wijesekara.testapp.WelcomeServlet.processRequest(WelcomeServlet.java:46) at com.wijesekara.testapp.WelcomeServlet.doGet(WelcomeServlet.java:78) at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) at java.lang.Thread.run(Thread.java:748)

By Jajati Badu Account Admin 23 Oct 2017 at 7:32 a.m. CDT

Jajati Badu gravatar
Hi Chiran, From the log file I can see your application url is http://localhost:8080/testapp However if you have followed the Java library document (https://gluu.org/docs/oxd/libraries/java/#configure-the-client-application)the document says , application will not work if it is not https and a valid host name. The client host name should be a valid hostname(FQDN), not localhost or an IP Address. You can configure the host name by adding the following entry in your host file. Linux Host file location /etc/host : 127.0.0.1 client.example.com Please try to make the url something like https://hostname and you should not get any error. Thanks, Jajati

By chiran wijesekara user 24 Oct 2017 at 6:24 a.m. CDT

chiran wijesekara gravatar
Hi Jajati, Is only setting up a domain name in hosts file is enough or else have i to enable SSL too.(by virtual host file)

By Jajati Badu Account Admin 24 Oct 2017 at 6:35 a.m. CDT

Jajati Badu gravatar
Hi Chiran, Yes. You need to enable SSL. In my previous message I have mentioned that the url has to be https Kind Regards, Jajati

By chiran wijesekara user 24 Oct 2017 at 7:13 a.m. CDT

chiran wijesekara gravatar
Thanks Jajati. I have added the following to host.conf, 127.0.0.1 client.testapp.com and in virtual hosts file i have, <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> <VirtualHost *:8080> ``` ServerName client.testapp.com ServerAlias client.testapp.com DocumentRoot "" DocumentRoot "" ServerName client.testapp.com SSLEngine on SSLCertificateFile "" SSLCertificateKeyFile "" " > AllowOverride All Order allow,deny Allow from all ``` </VirtualHost> am i doing correct, thanks.

By Jajati Badu Account Admin 24 Oct 2017 at 7:22 a.m. CDT

Jajati Badu gravatar
Hi Chiran, This is related to apache server configuration. you need to make sure you are able to open your test application on https and application url will look like https://client.testapp.com Thanks, Jajati

By chiran wijesekara user 24 Oct 2017 at 7:24 a.m. CDT

chiran wijesekara gravatar
Hi Jajati, Thank you. I'll do it that way. Thanks

By chiran wijesekara user 24 Oct 2017 at 7:24 a.m. CDT

chiran wijesekara gravatar
Hi Jajati, Thank you. I'll do it that way. Thanks

By chiran wijesekara user 25 Oct 2017 at 7:19 a.m. CDT

chiran wijesekara gravatar
I am using tomcat7. have i to do using apache2 virtual hosting method to enable SSL. Or else can i use ssl confugration for tomcat

By Jajati Badu Account Admin 25 Oct 2017 at 7:45 a.m. CDT

Jajati Badu gravatar
This is Java application and should work with Tomacat / Apache . Just make sure that you are able setup the UI. You can try apache and setup SSLS. Once you are able to run your web application you should be able to use oxd-server Thanks, Jajati