Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: JAVA RMI question

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question JAVA RMI question

    I am a newbie to RMI.

    From the client side, calling Remote method and passing hashmap of keys and values are null. I want the server to fill the values for each key. is that possible.


    Map<String, Object> mapObj = new HashMap<String, Object>();
    in a loop, I just fill the keys (string of the mapObject) and values as null.
    remoteObjectIF.callMethod(mapObj)

    mapObj.get("key1") gives me null. the server side logging gives the whatever object i am filling.

    can We pass hashmap to server and have it filled and clien access the same hashmap?


    the objects in hashmap are serializable.

    Please explain.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,307
    Thanks
    181
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: JAVA RMI question

    can We pass hashmap to server and have it filled and clien access the same hashmap?
    Think about how what the communication entails - Client/server communication occurs by passing data between the two JVM's - and this data is JVM specific - in most cases changes in one is not reflected in the other (exceptions to the rule could be something like changes to database values). If you need values to be passed between two JVM's you must explicitly transfer those values

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA RMI question

    yes. i realised that it is between 2 jvms.

    when I explicitly return the structure back again, the client received the values.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,307
    Thanks
    181
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: JAVA RMI question

    Quote Originally Posted by rlk View Post
    yes. i realised that it is between 2 jvms.

    when I explicitly return the structure back again, the client received the values.
    I do not understand...is your problem solved then? If not, please provide more information as to you method calls. In your code above, you pass a map to the remote method, but you do not seem to get the Map back from the method call (assuming that method returns the Map to you)

  5. #5
    Junior Member
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA RMI question

    yes i changed my code on the Remote method to return the map;

    Map<String, Object> mapObj = new HashMap<String, Object>();

    mapObj = remoteObjectIF.callMethod(mapObj);

    in the remote method it returns as shown below..

    map<string, Object> callMethod(Map<string, Object> m_map){

    map<string, Object> localmap;

    fill m_map objects

    result = m_map;

    retrun result;

    }

  6. #6
    Junior Member
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA RMI question

    I am getting java outofmemory: java heap space exception when deserializing.
    the returned object is bigger. how to handle this situation?

  7. #7
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,307
    Thanks
    181
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: JAVA RMI question

    IF you have a new problem, please start a new thread.

    Did you search the net or the forums?
    Common Java Mistakes

Similar Threads

  1. help for this java question
    By marlontoyo in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 20th, 2011, 08:09 PM
  2. Newbie Java Question
    By tinkersp in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 23rd, 2011, 01:41 PM
  3. java question on objects
    By joe98 in forum Threads
    Replies: 2
    Last Post: April 12th, 2011, 03:54 PM
  4. Java Question
    By NiCKYmcd in forum Java Theory & Questions
    Replies: 1
    Last Post: August 25th, 2010, 08:47 AM
  5. Question for Java experts please
    By XElCaballoX in forum Java Theory & Questions
    Replies: 2
    Last Post: August 19th, 2010, 01:43 AM