Search code examples
androidibm-mobilefirstworklight-adapters

Android native client fails to connect to Worklight


Hey i'm trying to connect android native app with Worklight api i have deployed the server and i copied all the jars and files required to my project then i used the code in the docs but i always get connection failure and it seems there is an exception on the server

here is my code

  _this = this;

    buttonConnect = (Button)findViewById(R.id.buttonConnect);
    buttonInvoke = (Button)findViewById(R.id.buttonInvoke);
    textView = (TextView)findViewById(R.id.textView);

    final WLClient client = WLClient.createInstance(this);
   // client.connect(new MyConnectListener());
    buttonConnect.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            updateTextView("Connecting...");
            client.connect(new MyConnectListener());
        }
    });

    buttonInvoke.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            updateTextView("Invoking procedure...");

           // String adapterName = "RSSReader";
            String adapterName = "adapter";//m
           // String procedureName = "getStoriesFiltered";
            String procedureName = "procedurename";


            WLProcedureInvocationData invocationData =
                    new WLProcedureInvocationData(adapterName, procedureName);

            Object[] parameters = new Object[] {""};// it require no parameter
            invocationData.setParameters(parameters);

            WLRequestOptions options = new WLRequestOptions();
            options.setTimeout(30000);

            WLClient client = WLClient.getInstance();
            client.connect(new MyConnectListener());
            client.invokeProcedure(invocationData, new MyInvokeListener(), options);
        }
    });
}

public static void updateTextView(final String str){
    Runnable run = new Runnable() {
        public void run() {
            textView.setText(str);
        }
    };
    _this.runOnUiThread(run);
}

and here is the exception on the server console

    [ERROR   ] Unknown exception: Datasource smartgov/jdbc/CommonShellDS not found in jndi
Unknown exception: Datasource smartgov/jdbc/CommonShellDS not found in jndi
[ERROR   ] FWLSE0099E: An error occurred while invoking procedure  [project RTA_Common_Shell]iDosServiceAdapter/HttpRequestFWLSE0100E:  parameters: [project RTA_Common_Shell]
Http request failed: java.net.UnknownHostException: RTAMHTIBSTGAMX1.rtatestdom.local: nodename nor servname provided, or not known
FWLSE0101E: Caused by:  [project RTA_Common_Shell]java.net.UnknownHostException: RTAMHTIBSTGAMX1.rtatestdom.local: nodename nor servname provided, or not knownjava.lang.RuntimeException: Http request failed: java.net.UnknownHostException: RTAMHTIBSTGAMX1.rtatestdom.local: nodename nor servname provided, or not known

Thanks


Solution

  • Your application will not know what is RTAMHTIBSTGAMX1.rtatestdom.local.

    You need to supply a qualified hostname or public IP address of the machine hosting the Worklight Server.

    You probably used that host in either wlclient.properties or in the adapter XML.
    Make sure to update it with said qualified hostname/public IP address.