EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
  • 1.  EGL accessing a third-party REST service JSR352 Java Batch

    Posted 03/17/16 03:00 AM

    Hi,

    I'm trying to run a third-party REST service under EGL/RUI RBD 9.5.0.1 and WebSphere Liberty Profile 8.5.5.8 on localhost.

    When I invoke this POST function

                // submit a java batch job            call myJSR352.invokePost("",                    myJSONdata) returning to showResult                    onException serviceError;

    the RBD console shows these messages

    Launching defaultServer (WebSphere Application Server 8.5.5.8/wlp-1.0.11.cl50820151201-1942) on Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_80-b15 (en_AU)[AUDIT   ] CWWKE0001I: The server defaultServer has been launched.[AUDIT   ] CWWKE0100I: This product is licensed for development, and limited production use. The full license terms can be viewed here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/license/base_ilan/ilan/8.5.5.8/lafiles/en.html[AUDIT   ] CWWKZ0058I: Monitoring dropins for applications. [AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:9081/ibm/adminCenter/serverConfig-1.0/[AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:9081/ibm/api/[AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:9081/IBMJMXConnectorREST/[AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:9081/SleepyBatchletSample-1.0/[AUDIT   ] CWWKZ0001I: Application SleepyBatchletSample-1.0 started in 0.999 seconds.[AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:9081/adminCenter/[AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:9081/ibm/adminCenter/explore-1.0/[AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:9081/JobUI/[AUDIT   ] CWWKZ0001I: Application JobUI started in 2.224 seconds.[AUDIT   ] CWWKF0012I: The server installed the following features: [localConnector-1.0, json-1.0, appSecurity-2.0, jaxrs-2.0, jaxrsClient-2.0, restConnector-1.0, distributedMap-1.0, j2eeManagement-1.1, batch-1.0, el-3.0, ssl-1.0, jdbc-4.1, servlet-3.1, adminCenter-1.0, jsp-2.3, jndi-1.0, batchManagement-1.0].[AUDIT   ] CWWKF0011I: The server defaultServer is ready to run a smarter planet.[err] 17/03/2016 3:33:55 pm.0  EGL1539E:EGL1539E An exception occurred while communicating with the service. URL:https://localhost:9444/ibm/api/batch/jobinstances/EGL0001I The error occurred in EGL Rich UI Proxy.    detail1:500    detail2:FAILED    detail3:java.io.IOException:Server returned HTTP response code: 500 for URL: https://localhost:9444/ibm/api/batch/jobinstances/

    Websphere Liberty FFDC log appears to indicate a JSON exception

    ------Start of DE processing------ = [17/03/16 14:53:22:889 ACST]Exception = javax.json.JsonExceptionSource = com.ibm.ws.jbatch.rest.internal.resources.JobInstancesprobeid = 213Stack Dump = javax.json.JsonException: Cannot auto-detect encoding, not enough chars        at org.glassfish.json.UnicodeDetectingInputStream.detectEncoding(UnicodeDetectingInputStream.java:131)        at org.glassfish.json.UnicodeDetectingInputStream.<init>(UnicodeDetectingInputStream.java:76)        at org.glassfish.json.JsonParserImpl.<init>(JsonParserImpl.java:76)        at org.glassfish.json.JsonReaderImpl.<init>(JsonReaderImpl.java:68)        at org.glassfish.json.JsonProviderImpl.createReader(JsonProviderImpl.java:131)        at javax.json.Json.createReader(Json.java:220)        at com.ibm.ws.jbatch.rest.utils.BatchJSONHelper.readJsonObject(BatchJSONHelper.java:64)        at com.ibm.ws.jbatch.rest.internal.resources.JobInstances.submitJob(JobInstances.java:436)        at com.ibm.ws.jbatch.rest.internal.resources.JobInstances.access$400(JobInstances.java:79)        at com.ibm.ws.jbatch.rest.internal.resources.JobInstances$JobInstancesHandler.post(JobInstances.java:226)        at com.ibm.ws.jbatch.rest.internal.resources.RequestRouter.routeRequestInternal(RequestRouter.java:77)        at com.ibm.ws.jbatch.rest.internal.resources.RequestRouter.routeRequest(RequestRouter.java:60)        at com.ibm.ws.jbatch.rest.internal.resources.JobInstances.handleRequest(JobInstances.java:208)        at com.ibm.ws.rest.handler.internal.service.RESTHandlerContainerImpl.handleRequest(RESTHandlerContainerImpl.java:500)        at com.ibm.ws.rest.handler.internal.servlet.RESTProxyServlet.handleWithDelegate(RESTProxyServlet.java:116)        at com.ibm.ws.rest.handler.internal.servlet.RESTProxyServlet.service(RESTProxyServlet.java:64)

    I'm certain the JSON data I moved to myJSONdata variable field is valid because it works on Chrome's Postman REST client.  To be sure I also invoked the third-party REST GET function and that appears to indicate the service is active. (see screenshot)

     

     

    Any idea what is happening? 

     

    Thanks,

    Julius

    jmarb


  • 2.  Re: EGL accessing a third-party REST service JSR352 Java Batch

    Posted 03/21/16 05:56 AM

    Hi, oes the third-party REST GET function also receive json data? I guess the problem come from the decode of json. I see glassfish is the console. Do you use oracle jdk for websphere liberty? Try IBM jdk and see what happen.

    I will keep looking at this problem.

    Bin.

    Bin.


  • 3.  Re: EGL accessing a third-party REST service JSR352 Java Batch

    Posted 03/21/16 06:27 PM

    Hi,

    I captured the raw HTTP stream, the REST GET function does not inject JSON data, the parameter value '28' goes into the uri attribute

    POST http://localhost:9081/JobUI/___proxy HTTP/1.1Host: localhost:9081Connection: keep-aliveContent-Length: 176Origin: http://localhost:9081User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36Content-Type: application/jsonrequest;charset=UTF-8Accept: */*Referer: http://localhost:9081/JobUI/JobOperator-en_US.htmlAccept-Encoding: gzip, deflateAccept-Language: en-GB,en-US;q=0.8,en;q=0.6Cookie: LtpaToken2=lljF/2d6jHWToLybT6EDLcIv7bUSEcKOLkCtHUTdTCU5ayFwrLKiVr2ocv9P2481DHtFEENtu/uc2mC2l0grrUN6Di78VsCeaMJPVW/nnOFCW0PUBTVvq8cE8ajNY5k6wbRex35Oz6Vz6nWMCdc/u1HhIdh9y2mhPk29Ikk8nAw7Er95aWGWg8vsZ7QhV8Ea3O6SYcaN3UUYCZFDUTBx2XAYBfQdnB/Zp5toA8TvwxcSh52seoL0iKBjw1GRw73rso5K6DkGb2mjRQISZ0Y3MFUAUu5/24OMFLQ+ZN4dzkUlg2mE5myW4L8TVrN5O4h9; JSESSIONID=0000OdbZIovAwrTmKxC0unOZuFW:0fc91fbf-a21c-47ee-9628-ad54ebda0c97{"uri":"https://localhost:9444/ibm/api/batch/jobinstances/28","queryParameters":{},"method":"GET","body":"","headers":{"Authorization":"Basic d2xwYWRtaW46YzByM3BnbTE="}}

    while the REST POST function put the JSON data into the body attribute

    POST http://localhost:9081/JobUI/___proxy HTTP/1.1Host: localhost:9081Connection: keep-aliveContent-Length: 362Origin: http://localhost:9081User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36Content-Type: application/jsonrequest;charset=UTF-8Accept: */*Referer: http://localhost:9081/JobUI/JobOperator-en_US.htmlAccept-Encoding: gzip, deflateAccept-Language: en-GB,en-US;q=0.8,en;q=0.6Cookie: LtpaToken2=lljF/2d6jHWToLybT6EDLcIv7bUSEcKOLkCtHUTdTCU5ayFwrLKiVr2ocv9P2481DHtFEENtu/uc2mC2l0grrUN6Di78VsCeaMJPVW/nnOFCW0PUBTVvq8cE8ajNY5k6wbRex35Oz6Vz6nWMCdc/u1HhIdh9y2mhPk29Ikk8nAw7Er95aWGWg8vsZ7QhV8Ea3O6SYcaN3UUYCZFDUTBx2XAYBfQdnB/Zp5toA8TvwxcSh52seoL0iKBjw1GRw73rso5K6DkGb2mjRQISZ0Y3MFUAUu5/24OMFLQ+ZN4dzkUlg2mE5myW4L8TVrN5O4h9; JSESSIONID=0000OdbZIovAwrTmKxC0unOZuFW:0fc91fbf-a21c-47ee-9628-ad54ebda0c97{"uri":"https://localhost:9444/ibm/api/batch/jobinstances/","queryParameters":{},"method":"POST","body":"{\"applicationName\":\"SleepyBatchletSample-1.0\",\"moduleName\":\"SleepyBatchletSample-1.0.war\",\"jobXMLName\":\"sleepy-batchlet.xml\",\"jobParameters\":{\"sleep.time.seconds\":\"10\"}}","headers":{"Authorization":"Basic d2xwYWRtaW46YzByM3BnbTE="}}

    I tried using IBM JDK8 and the error still occurs.

     

    Am I calling the third-party REST within EGL/RUI the wrong way?

                // supply target URI            myJSR352 ICallJSR352{@RestBinding {baseURI = "https://localhost:9444/ibm/api/batch/jobinstances/"}};                        // change to appropriate values            ServiceLib.setHTTPBasicAuthentication(myJSR352, "wlpadmin","xxxxxxxxx");            // NOTE: these EGL calls are asynchronous            // submit a java batch job            call myJSR352.invokePost("",                    myJSONdata) returning to showResult                    onException serviceError;            // show a finished java batch job, e.g., 28 (28th java batch job request)            call myJSR352.invokeGet("28") returning to showResult                    onException serviceError;

    Thanks,

    Julius
     

    jmarb


  • 4.  Re: EGL accessing a third-party REST service JSR352 Java Batch

    Posted 03/21/16 10:48 PM

    Hi Julius. It looks good in EGL side. I need your project to investigate to see what happens between egl prxoy and java batch service. Is it possible that you email your egl project and batch project to me? My email is libbin@cn.ibm.com

    Bin.

    Bin.


  • 5.  Re: EGL accessing a third-party REST service JSR352 Java Batch

    Posted 03/22/16 12:04 AM

    Thanks Bin, I emailed the EGL and batch projects to libbin@cn.ibm.com

    jmarb


  • 6.  Re: EGL accessing a third-party REST service JSR352 Java Batch

    Posted 03/23/16 04:56 AM

    Hi Julius.

    It`s a defect of egl proxy,please open an PMR,and I will provide you fix later.

    Bin.
     

    Bin.


  • 7.  Re: EGL accessing a third-party REST service JSR352 Java Batch

    Posted 03/28/16 05:27 PM

    PMR submitted.  Thanks Bin.

    jmarb