Hi Thierry,

Thanks for your reply.

I am facing a difference issue now :(

When I use my android client to get the details from google app engine
server it shows "internal connector error"
I am using android emulator for testing when I click the get button in the
application in android emulator it shows "internal connector error"

Also it shows 

No available client connector supports the required protocols: 'HTTP' .
Please add the JAR of a matching connector to your classpath.

but I have added the following jars to both my android client and google app
engine server:

org.restlet.jar
org.restlet.ext.net.jar
com.noelios.restlet.ext.httpclient_3.1.jar
com.noelios.restlet.ext.net.jar
com.noelios.restlet.ext.servlet_2.5.jar
com.noelios.restlet.jar

Here is the log cat file for android:


02-10 14:54:53.381: DEBUG/dalvikvm(201): VM cleaning up
02-10 14:54:53.501: DEBUG/ddm-heap(156): Got feature list request
02-10 14:54:53.511: DEBUG/ddm-heap(203): Got feature list request
02-10 14:54:53.563: INFO/ActivityManager(54): Start proc
org.restlet.example.android.serialisation for activity
org.restlet.example.android.serialisation/.ContactActivity: pid=217
uid=10022 gids={3003}
02-10 14:54:53.662: DEBUG/dalvikvm(201): LinearAlloc 0x0 used 676828 of
4194304 (16%)
02-10 14:54:53.953: INFO/jdwp(217): received file descriptor 20 from ADB
02-10 14:54:54.121: DEBUG/ddm-heap(217): Got feature list request
02-10 14:54:55.152: WARN/org.restlet(217): No available client connector
supports the required protocols: 'HTTP' . Please add the JAR of a matching
connector to your classpath.
02-10 14:54:55.604: INFO/ActivityManager(54): Displayed activity
org.restlet.example.android.serialisation/.ContactActivity: 2482 ms (total
2482 ms)
02-10 14:55:05.362: DEBUG/dalvikvm(97): GC freed 2852 objects / 163568 bytes
in 136ms
02-10 14:56:37.332: DEBUG/KeyguardViewMediator(54): pokeWakelock(5000)
02-10 14:56:37.452: INFO/ARMAssembler(54): generated
scanline__00000077:03545404_00000A04_00000000 [ 29 ipp] (51 ins) at
[0x231dd8:0x231ea4] in 27353199 ns
02-10 14:56:37.572: INFO/ActivityManager(54): Start proc
com.android.inputmethod.latin for service
com.android.inputmethod.latin/.LatinIME: pid=224 uid=10001 gids={3003, 1015}
02-10 14:56:37.992: INFO/jdwp(224): received file descriptor 10 from ADB
02-10 14:56:38.191: DEBUG/ddm-heap(224): Got feature list request
02-10 14:56:38.531: DEBUG/dalvikvm(224): Trying to load lib
/system/lib/libjni_latinime.so 0x43758040
02-10 14:56:38.531: DEBUG/dalvikvm(224): Added shared lib
/system/lib/libjni_latinime.so 0x43758040
02-10 14:56:39.503: DEBUG/dalvikvm(217): GC freed 4653 objects / 276480
bytes in 103ms
02-10 14:56:39.651: INFO/ARMAssembler(54): generated
scanline__00000077:03515104_00000000_00000000 [ 27 ipp] (41 ins) at
[0x2abc38:0x2abcdc] in 636673 ns
02-10 14:56:39.672: INFO/ARMAssembler(54): generated
scanline__00000077:03515104_00001001_00000000 [ 64 ipp] (84 ins) at
[0x2abce0:0x2abe30] in 1687644 ns
02-10 14:56:40.373: WARN/org.restlet(217): No available client connector
supports the required protocols: 'HTTP' . Please add the JAR of a matching
connector to your classpath.
02-10 14:56:40.373: INFO/org.restlet(217): A recoverable error was detected
(1002), attempting again in 2000 ms.
02-10 14:56:42.422: INFO/org.restlet(217): A recoverable error was detected
(1002), attempting again in 2000 ms.
02-10 14:56:45.082: DEBUG/dalvikvm(97): GC freed 163 objects / 7696 bytes in
305ms
02-10 14:56:49.712: WARN/InputManagerService(54): Window already focused,
ignoring focus gain of:
com.android.internal.view.IInputMethodClient$Stub$Proxy@43917738
02-10 14:59:39.761: DEBUG/dalvikvm(95): GC freed 7489 objects / 406360 bytes
in 189ms
02-10 15:00:35.502: INFO/org.restlet(217): A recoverable error was detected
(1002), attempting again in 2000 ms.
02-10 15:00:37.573: INFO/org.restlet(217): A recoverable error was detected
(1002), attempting again in 2000 ms.
02-10 15:01:23.222: WARN/InputManagerService(54): Window already focused,
ignoring focus gain of:
com.android.internal.view.IInputMethodClient$Stub$Proxy@438da808


***********************

Here is the android client code:

package org.restlet.example.android.serialisation;

import org.restlet.Client;
import org.restlet.Context;
import org.restlet.data.Protocol;
import org.restlet.example.android.serialisation.R;
import org.restlet.example.common.Address;
import org.restlet.example.common.Contact;
import org.restlet.example.common.ContactResource;
import org.restlet.resource.ClientResource;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * Handles the view of a contact.
 */
public class ContactActivity extends Activity {
        /**
         * Private OnClickListener that is able to run its task in a separate
         * thread.
         */
        private static abstract class MyOnClickListener implements
                        Button.OnClickListener, Runnable {
                public abstract void run();
        }

        /** The alert dialog box. */
        private AlertDialog alertDialog;
        /** The current contact. */
        private Contact contact;

        /** Global handler used to refresh the interface. */
        private final Handler handler = new Handler() {
                @Override
                public void handleMessage(Message msg) {
                        progressDialog.dismiss();
                        switch (msg.what) {
                        case 0:
                                // Update the interface using the retrieved 
contact
                                if (contact != null) {
                                        TextView tvFirstName = (TextView) 
findViewById(R.id.field_firstname);
                                        TextView tvLastName = (TextView) 
findViewById(R.id.field_lastname);
                                        TextView tvAge = (TextView) 
findViewById(R.id.field_age);
                                        TextView tvHaLine1 = (TextView) 
findViewById(R.id.field_ha_line1);
                                        TextView tvHaLine2 = (TextView) 
findViewById(R.id.field_ha_line2);
                                        TextView tvHaZipcode = (TextView) 
findViewById(R.id.field_ha_zipcode);
                                        TextView tvHaCity = (TextView) 
findViewById(R.id.field_ha_city);
                                        TextView tvHaCountry = (TextView) 
findViewById(R.id.field_ha_country);

                                        
tvFirstName.setText(contact.getFirstName());
                                        
tvLastName.setText(contact.getLastName());
                                        
tvAge.setText(Integer.toString(contact.getAge()));
                                        Address homeAddress = 
contact.getHomeAddress();
                                        if (homeAddress != null) {
                                                
tvHaLine1.setText(homeAddress.getLine1());
                                                
tvHaLine2.setText(homeAddress.getLine2());
                                                
tvHaZipcode.setText(homeAddress.getZipCode());
                                                
tvHaCity.setText(homeAddress.getCity());
                                                
tvHaCountry.setText(homeAddress.getCountry());
                                        }

                                        findViewById(R.id.update_button)
                                                        
.setVisibility(View.VISIBLE);
                                }
                                break;
                        case 1:
                                // Update the interface once the contact has 
been updated
                                break;
                        case 2:
                                // Error.
                                
alertDialog.setMessage(msg.getData().getString("msg"));
                                alertDialog.show();
                                break;

                        default:
                                super.handleMessage(msg);
                                break;
                        }
                }
        };

        /** The progress dialog used during the interactions with the server. */
        private ProgressDialog progressDialog;

        /** The current contact resource. */
        private ContactResource resource;

        /**
         * Returns the string value of a field given its id.
         * 
         * @param fieldId
         *            The id of the field.
         * @return The string value of the field.
         */
        private String getStringValue(int fieldId) {
                String result = null;
                View v = findViewById(fieldId);
                if (v != null) {
                        CharSequence value = ((TextView) v).getText();
                        if (value != null) {
                                result = value.toString();
                        }
                }
                return result;
        }

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.contact);
                Client client = new Client(new Context(), Protocol.HTTP);  
       
client.getContext().getParameters().add("converter","com.noelios.restlet.ext.net.HttpClientHelper");
        
        

                // Initialize the resource proxy.
        
                ClientResource cr = new ClientResource(
                                
"http://my-android-app.appspot.com/contacts/123";);
                resource = cr.wrap(ContactResource.class);
                

                Button getButton = (Button) findViewById(R.id.get_button);
                Button updateButton = (Button) findViewById(R.id.update_button);
                updateButton.setVisibility(View.INVISIBLE);

                getButton.setOnClickListener(new MyOnClickListener() {
                        public void onClick(View v) {
                                progressDialog = 
ProgressDialog.show(v.getContext(),
                                                
getString(R.string.process_dialog_title),
                                                
getString(R.string.process_dialog_get), true, false);
                                Thread thread = new Thread(this);
                                thread.start();
                        }

                        @Override
                        public void run() {
                                try {
                                        // Get the remote contact
                                        contact = resource.retrieve();
                                        // The task is over, let the parent 
conclude.
                                        handler.sendEmptyMessage(0);
                                } catch (Exception e) {
                                        Message msg = Message.obtain(handler, 
2);
                                        Bundle data = new Bundle();
                                        data.putString("msg", "Cannot get the 
contact due to: "
                                                        + e.getMessage());
                                        msg.setData(data);
                                        handler.sendMessage(msg);
                                }
                        }
                });

                updateButton.setOnClickListener(new MyOnClickListener() {
                        public void onClick(View v) {
                                progressDialog = 
ProgressDialog.show(v.getContext(),
                                                
getString(R.string.process_dialog_title),
                                                
getString(R.string.process_dialog_update), true, false);
                                Thread thread = new Thread(this);
                                thread.start();
                        }

                        @Override
                        public void run() {
                                // Update the remote contact
                                TextView tvFirstName = (TextView) 
findViewById(R.id.field_firstname);
                                TextView tvLastName = (TextView) 
findViewById(R.id.field_lastname);
                                TextView tvAge = (TextView) 
findViewById(R.id.field_age);
                                
contact.setFirstName(tvFirstName.getText().toString());
                                
contact.setLastName(tvLastName.getText().toString());
                                
contact.setAge(Integer.parseInt(tvAge.getText().toString()));

                                Address homeAddress = null;
                                String haLine1 = 
getStringValue(R.id.field_ha_line1);
                                String haLine2 = 
getStringValue(R.id.field_ha_line2);
                                String haZipcode = 
getStringValue(R.id.field_ha_zipcode);
                                String haCity = 
getStringValue(R.id.field_ha_city);
                                String haCountry = 
getStringValue(R.id.field_ha_country);
                                if (haLine1 != null || haLine2 != null || 
haZipcode != null
                                                || haCity != null || haCountry 
!= null) {
                                        homeAddress = new Address(haLine1, 
haLine2, haZipcode,
                                                        haCity, haCountry);
                                }
                                contact.setHomeAddress(homeAddress);

                                // Update the remote resource.
                                try {
                                        resource.store(contact);
                                        // The task is over, let the parent 
conclude.
                                        handler.sendEmptyMessage(1);
                                } catch (Exception e) {
                                        Message msg = Message.obtain(handler, 
2);
                                        Bundle data = new Bundle();
                                        data.putString("msg", "Cannot update 
the contact due to: "
                                                        + e.getMessage());
                                        msg.setData(data);
                                        handler.sendMessage(msg);
                                }
                        }
                });

                // Initializes the alert dialog.
                alertDialog = new AlertDialog.Builder(this).create();
                alertDialog.setTitle(getString(R.string.error_dialog_title));
                alertDialog.setButton(getString(R.string.error_dialog_button),
                                new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface 
dialog, int which) {
                                                return;
                                        }
                                });
        }
}

***************
I have added internet permission in the manifest file.

Here is the code for server:



package server.application;


import org.restlet.Application;
import org.restlet.Component;
import org.restlet.Restlet;
import org.restlet.data.Protocol;
import org.restlet.resource.Directory;
import org.restlet.routing.Router;

public class TestServerApplication extends Application {

    /**
     * When launched as a standalone application.
     * 
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        Component component = new Component();          
        
        component.getServers().add(Protocol.HTTP, 8080);
        component.getClients().add(Protocol.CLAP);
        component.getClients().add(Protocol.FILE);
       
        component.getDefaultHost().attach(new TestServerApplication());
        component.start();
    }

    @Override
    public Restlet createInboundRoot() {
        Router router = new Router(getContext());
              
        // Serve the files generated by the GWT compilation step.
         
    
    Directory dir = new Directory(getContext(),"war:///");
       
        router.attachDefault(dir);
        router.attach("/contacts/123", ContactServerResource.class);

        return router;
    }

}

Please help me out.

Thanks in advance




-- 
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/The-protocol-used-by-this-request-is-not-declared-in-the-list-of-client-connectors-FILE-tp6006629p6011057.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2703212

Reply via email to