Results 1 to 9 of 9

Thread: Servant on Android device

  1. #1
    JoseLSegura is offline Registered User
    Name: Jose Segura
    Organization: ARCO Research Group - UCLM
    Project: Argos - Elcano
    Join Date
    Apr 2010
    Location
    Spain
    Posts
    10

    Question Servant on Android device

    Hello. I'm new to programming for Android devices. I'm using Ice for Android (the latest version, 0.1.1).

    I've been able to write a client application for an external servant, but I'm having trouble with hosting a servant on the Android device.

    First, I briefly explain my application architecture:

    - I have an Android activity that launches a Android service.
    - The Android service, created by the activity, holds the communicator and the object adapter. I only initialize them on a user interface button callback.

    My GUI has two buttons: one of them invokes the service to create the communicator and the object adapter. The other button creates the servant and adds it to the object adapter via my running service.

    It works very good, apparently. When I try to remotely invoke the "checked cast" on the proxy hosted on my Android device, the Android's "logcat" gives me this message:

    Code:
    WARN/System.err(384): 600 error: Ice Acceptor Thread: 0.0.0.0:58458: acceptAsync: 
    WARN/System.err(384): 0.0.0.0:58458
    WARN/System.err(384): java.lang.NullPointerException
    WARN/System.err(384):     at IceInternal.Network.addressesToString(Network.java:1139)
    ...
    I have marked as synchronized the method that creates the communicator and the object adapter and the method that instanciates the servant and adds it to the adapter.

    My servant's remote methods are "synchronized" too.

    I was looking for a minimal example of servant hosted on a Android device, but I can't find anyone.

    What are my mistakes? Thanks for your attention.
    José Luis Segura - ARCO Research Group

  2. #2
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,445
    Hi,

    Welcome to the forum.

    Do you have network tracing enabled? If so, try setting Ice.Trace.Network=0 to see if it works around the problem.

    Cheers,
    Mark

  3. #3
    JoseLSegura is offline Registered User
    Name: Jose Segura
    Organization: ARCO Research Group - UCLM
    Project: Argos - Elcano
    Join Date
    Apr 2010
    Location
    Spain
    Posts
    10
    First of all, thanks for your welcome

    Now, about my problem.

    I just tried your suggestion, but it doesn't work... The log doesn't change at all.

    Is there any alternative idea?

    Thanks for your surprisingly quick reply.
    José Luis Segura - ARCO Research Group

  4. #4
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,445
    Hi,

    It would help us to see the complete stack trace of the NullPointerException.

    Regards,
    Mark

  5. #5
    JoseLSegura is offline Registered User
    Name: Jose Segura
    Organization: ARCO Research Group - UCLM
    Project: Argos - Elcano
    Join Date
    Apr 2010
    Location
    Spain
    Posts
    10
    Hello.

    Excuse me for my inactivity... this was a difficult weekend :P

    Here it is: my traceback.

    Code:
    04-19 08:44:36.108: WARN/System.err(6852): 19/04/10 08:44:36:107 error: Ice Acceptor Thread: 0.0.0.0:43839: acceptAsync:
    04-19 08:44:36.108: WARN/System.err(6852): 0.0.0.0:43839
    04-19 08:44:36.108: WARN/System.err(6852): java.lang.NullPointerException
    04-19 08:44:36.108: WARN/System.err(6852):     at IceInternal.Network.addressesToString(Network.java:1139)
    04-19 08:44:36.108: WARN/System.err(6852):     at IceInternal.Network.fdToString(Network.java:1115)
    04-19 08:44:36.108: WARN/System.err(6852):     at IceInternal.TcpTransceiver.<init>(TcpTransceiver.java:345)
    04-19 08:44:36.118: WARN/System.err(6852):     at IceInternal.TcpAcceptor.accept(TcpAcceptor.java:52)
    04-19 08:44:36.118: WARN/System.err(6852):     at IceInternal.IncomingConnectionFactory.acceptAsync(IncomingConnectionFactory.java:473)
    04-19 08:44:36.118: WARN/System.err(6852):     at IceInternal.IncomingConnectionFactory.access$000(IncomingConnectionFactory.java:14)
    04-19 08:44:36.118: WARN/System.err(6852):     at IceInternal.IncomingConnectionFactory$1.run(IncomingConnectionFactory.java:328)
    04-19 08:44:36.118: WARN/System.err(6852):     at java.lang.Thread.run(Thread.java:1096)
    José Luis Segura - ARCO Research Group

  6. #6
    JoseLSegura is offline Registered User
    Name: Jose Segura
    Organization: ARCO Research Group - UCLM
    Project: Argos - Elcano
    Join Date
    Apr 2010
    Location
    Spain
    Posts
    10
    I'm working on it and I have an update on the status:

    I started debugging the IceAndroid sources, looking for where is the "null" object reference, and I have found it:

    On the method IceInternal.Network.fdToString it receives a "SelectableChannel", and from that, it makes a SocketChannel object.

    When it executes the getLocalAddress operation on this SocketChannel, it returns null, and this null is later passed to "addressesToString", who raises the NullPointerException and makes me cry :P

    I hope it helps
    José Luis Segura - ARCO Research Group

  7. #7
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,445
    Hi,

    Thanks for posting more details on the problem. Android's network classes are behaving differently than other JVM implementations and Ice wasn't properly working around these issues. I've posted a patch that should prevent the NullPointerException.

    Regards,
    Mark

  8. #8
    JoseLSegura is offline Registered User
    Name: Jose Segura
    Organization: ARCO Research Group - UCLM
    Project: Argos - Elcano
    Join Date
    Apr 2010
    Location
    Spain
    Posts
    10
    Quote Originally Posted by mes View Post
    Hi,

    Thanks for posting more details on the problem. Android's network classes are behaving differently than other JVM implementations and Ice wasn't properly working around these issues. I've posted a patch that should prevent the NullPointerException.

    Regards,
    Mark
    I love you Mark

    I just patched, compiled and tested my application and it works!!!

    Thanks for your time and effort.

    I'm asking why your chat example works without problems and my "hello world" server (a minimal example) didn't work... is it related with the use of Glacier?
    José Luis Segura - ARCO Research Group

  9. #9
    mes's Avatar
    mes
    mes is offline ZeroC Staff
    Name: Mark Spruiell
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Feb 2003
    Location
    California
    Posts
    1,445
    Quote Originally Posted by JoseLSegura View Post
    I'm asking why your chat example works without problems and my "hello world" server (a minimal example) didn't work... is it related with the use of Glacier?
    Not exactly. The NullPointerException occurs in your Android server while Ice's object adapter is attempting to accept a new incoming connection. The chat demo's object adapter is not assigned any physical endpoints and therefore it cannot accept new incoming connections. Rather, it uses the createObjectAdapterWithRouter operation to create an object adapter that can only receive requests sent over bidirectional connections.

    Hope that helps,
    Mark

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Android Server
    By Daniel_Kim in forum Help Center
    Replies: 1
    Last Post: 05-31-2011, 10:55 PM
  2. Replies: 2
    Last Post: 06-23-2007, 07:19 AM
  3. A mobile device application by using Ice-E
    By jli125 in forum Help Center
    Replies: 3
    Last Post: 03-09-2007, 09:34 AM
  4. Is it possible to port ICE to Mobile device?
    By gnoygnas in forum Help Center
    Replies: 0
    Last Post: 11-18-2004, 03:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •