• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

rmiregistry programmatically

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,

I am having problems when I turn on the rmiregistry programmatically... using LocateRegistry.CreateRegistry.

My RMI servers bind successfully to the registry. However, when I try to connect to these servers, I get



What could be the problem?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What URL are you using in Naming.lookup()?
 
Rob Qas
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
rmi://localhost:1099/dataSource
 
Rob Qas
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i started the server with this code



but when i check netstate -a thers no lisiner on port 1099
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you on Windows?

try a

netstat -a

from the command prompt. This will at least tell you if the port your listening on is open. Looks like it just can't make the connection.

OPEN THOSE PORTS!!!
 
Rob Qas
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes iam using windows..

i tried netstat -a and its not listing to the port i dont why!!
when i run the rmiregistry from the command promt i dont got any problems but if i run it programaticly its not working ..
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any code keeping your server alive?

It could be creating your server object, starting the registry, binding your server, and then just exiting - the registry would just die with the rest of your code.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello
please test this code if you need to solve your problem


public static void main(String[] args) throws Exception
{
try
{
remoteServer server = new remoteServerImpl();
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
System.setProperty(Context.PROVIDER_URL, "rmi://localhost:1099");
Registry registry = LocateRegistry.createRegistry(1099);
remoteServer stub = (remoteServer) UnicastRemoteObject.exportObject(server,1099);
registry.rebind ("dataSource", stub);
JOptionPane.showMessageDialog(null,"##### SERVER STARTED #####");
System.out.println("##### SERVER STARTED #####");
}
catch (Exception e)
{
}
}
TARIQ SHADID
WEB DEVELOPER
 
Rob Qas
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so how can i keep my server alive? please if you can send me a sample code for doing this .. thanks for your help
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All you have to do is create a new thread and start it.

Normally this isn't a problem because the server won't die as long as there are remote references to it - and normally the RMI Naming service fulfills that - but since you are starting the naming server in the same JVM - there are no remote references to it.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic