• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

rmi callback

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my client is able to use functions stored in server thru rmi.. but i am not able to make calls from server to client.. will be glad if anyone can explain this with an easy example

thnx..
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by simranjit singh:
my client is able to use functions stored in server thru rmi.. but i am not able to make calls from server to client.. will be glad if anyone can explain this with an easy example

thnx..


When you say you are "not able to", it means that you get an exception or you can not figure out how to do that?
Well, if there is an exception then a stacktrace will help however, if you can not figure it out, then, the point is that the client should also expose its Remote interface for others(server) to call it.
So, in this scenario, there is no clear role separation of a client and server, both the objects act as both client and server.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
... so the question becomes: Is the client set up to act as an RMI server as well?
 
simranjit singh
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i can not figure out how to do that...

i tried but i landed up writing my output message on server sides cmd prompt(that according to me should have been printed on client sides cmd prmpt) and if i try putting up my that message in my client sides window,(textarea) it gives me nullpointer and for this i know why since it could not find a reference to that client window in which it should print.

server code:


server Interface:


client:


client interface file:


login file m using:



will be glad if you people can tellme where i am going wrong or what i can do to correct my code..

thanks
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not very sure whether this code runs with the client and server running in two different JVMs.
Well, i do not have any idea about Swing, but i am very skeptical about this code:


What you are doing is that you are exporting a different object (Instance 1)and registering a different object with the server(Instance 2).
This can only work when, the client and server are running in the same jvm when the actual instance of the client is passed to the server instead of the stub. Otherwise, it should give a Marshalling exception.
Anyways, i think if you pass instance 1 in the registerForCallback method, it should work.
I leave it to you to find out as to why, the message you expected to print on the client was printing on the server(assuming they run on same JVM)
 
simranjit singh
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


used this.. again the null pointer exception.. i cannot figure out where i am going wrong..


this jtextArea is giving error


Stacktrace :


problem of getting that message on server window has been solved.. thanks alot..
will be glad if this nullpointer can also be removed..
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Firstly, adding to my previous post, since JFrame is Serializable, so the rmi call succeeded even if the server and client were on different JVMs. The newly created ClientImpl was serialized and sent across to the server JVM.
Ok, now for the null pointer exception.
From the stack trace, i can hardly make out anything since i dont have the line numbers in the code. However, the messageReceived() method does not have anything but a system.out and jtextArea1.append(). I am curious as to where jtextarea1 is defined/initialized. The only source of an NPE can be that jtextarea1 is null.(Assuming that fromUsername and message are not null)
Excuse me if i am missing out something related to swing in the above as swing is latin and greek to me
 
simranjit singh
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
jTextArea is defined / initialized when initcomponents() method in clientRMIImpl is called. i am developing my project in netbeans 5.5, jdk 1.6

initcomponents i guess you can see in the clientRMIImpl.java code in the code above..

what can i do to pass a reference of that window to this jtextArea when i get that reply from server?
System.out.print just above is working just fine.
 
Villains always have antidotes. They're funny that way. Here's an antidote disguised as a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic