Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

$Proxy0

 
Dustin Tosh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Has anyone ever had a problem with a $Proxy0 error?

I am printing out an error message when attempting to use a Naming.lookup.

The code is as follows:
(LocalDataAdapter)Naming.lookup("rmi://localhost/RemoteDatabase2");

My excecption.getMessage() is printing the $Proxy0

Any ideas?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dustin,

Welcome to JavaRanch and this forum.

If you print the entire stack trace you will probably get more information.

I assume you have run rmic to create the proxy stubs?

Regards, Andrew
 
Dustin Tosh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Andrew,

I forgot to run the rmic on my DatabaseImpl class. The stack trace looks like this after I do.

General exception: suncertify.remote.DatabaseImpl_Stub
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Input/Output
Error trying to set the Connection Type!
at suncertify.gui.GUIController.setConnectionType(GUIController.java:144
)
at suncertify.gui.MainWindow.<init>(MainWindow.java:56)
at suncertify.gui.MainWindow$1.run(MainWindow.java:69)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


I believe its either one of two things. A typecasting error when I am calling:

return (LocalDataAdapter)Naming.lookup("rmi://localhost/RemoteDatabase2");

Or.. It is a RMI problem that I can't seem to find. I've implemented my GUI and the DB and all is working except for the RMI. As soon as I get this I will clean my code up and hopefully submit it soon.

Thanks for your help!
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dustin,

Can you confirm that
  • line 144 in GUIController.java is the "(LocalDataAdapter)Naming.lookup("rmi://localhost/RemoteDatabase2");"
  • LocalDataAdapter is the interface that extends Remote
  • RemoteDatabase2 is the user name you gave the exported class that extends LocalDataAdapter
  • You are throwing the RuntimeException that it is at the top of the stack trace (this does not seem to be a very user friendly way for the user to find out that they forgot to start the server before starting the client)

  • Regards, Andrew
     
    Dustin Tosh
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Andrew,

    1. DBAccess is the server interface provided by sun. Data.java is a synchronized implementation of the DBAcess interface. LocalDataAdapter is a wrapper class for the Data.java class. LocalDataAdapter locks each row of the database before it is used, which uses a static vector in the Data.java class.

    2. RemoteDatabase2 is the name I assigned to the DatabaseImpl class. The DatabaseImpl class is a wrapper for the LocalDataAdapter class

    // Create and register the database
    java.rmi.registry.LocateRegistry.createRegistry(1099);
    DatabaseImpl db = new DatabaseImpl();
    Naming.rebind("RemoteDatabase2", db);

    3. Sometimes I just add the runtime errors in when I am in a hurry and then take them out later. It's fixed now.
     
    Steve Smith
    Greenhorn
    Posts: 26
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I had this problem recently. The issue was that I was casting to concrete implementation rather than the RMI interface. So if LocalDataAdapter is a concrete class, try casting to it's interface (write an interface for it if you dont already have one). I hope that helps you (worked for me).


    [ October 10, 2005: Message edited by: Steve Smith ]
     
    Dustin Tosh
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Let me first say thanks Steve and Andrew, I really appreciate the extra input. If nothing else it gets me thinking about things I might not have thought about.

    I tried changing the LocalDataAdapter to DataAdapter in the name.lookup method call, but no luck. Still printing out an error message about

    General exception: suncertify.remote.DatabaseImpl_Stub

    Any other ideas?
    [ October 10, 2005: Message edited by: Dustin Tosh ]
     
    Dustin Tosh
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Something interesting that might help shed some light on the subject?

    I thought perhaps the stub I created using rmic could not be found, however when I delete the stub I get:

    General exception: error unmarshalling return; nested exception is:
    java.lang.ClassNotFoundException: suncertify.remote.DatabaseImpl_Stub (no security manager: RMI class loader disabled)
    java.io.IOException: Input/Output Error trying to set the Connection Type!

    Which tells me that it must have been finding the stub before I deleted it. Does this mean that it must be a typecast error somewhere and that my RMI setup is fine?
     
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander
    Pie
    Posts: 12014
    220
    C++ Firefox Browser IntelliJ IDE Java Mac Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Dustin,

    I am not sure where the problem is at the moment, but it may help if we go back to an extremely simple test case and determine whether it works or not.

    So here is the code for a simple RMI server:You should be able to compile and run that directly:



    Then we need some code for a client:Again, there is nothing special about compiling and running it:



    As you can see, when I ran that, I received the expected response from the server. Do you get the same response?

    If you do get the same response when you run this, then you may be able to use my code as a template to look for problems in your code. The major things to watch for are that:
  • you run rmic on the correct class,
  • your interface extends Remote,
  • your class extends UnicastRemoteObject and implements your interface,
  • you bind an instance of your class,
  • your client retrives back an instance of the interface

  • Regards, Andrew
     
    Dustin Tosh
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for all of your help! Your ideas pointed me in the right direction. I thought I would post this update to help anyone else who has this error. The original $Proxy0 came from me forgetting to run the rmic on my DatabaseImpl class. Once that was solved I had a DatabaseImpl_Stub error that kept plaguing me. That turned out to be a typecast error. If you look at the example below I originally typecasted the object as a LocalDataAdapter, which was an implementation of DBAccess.

    (LocalDataAdapter)Naming.lookup("rmi://localhost/RemoteDatabase2");

    DBAccess is the server interface sun provided me. The first problem is fairly obvious to me now. I was casting the object to a implemented class, where I should have been casting it to an interface. After I changed the typecast to my DataAdapter interface it still didn't work. The second problem proved to be DBAccess, which didn't throw RemoteException. Sun DOES NOT allow you to change your interface to include RemoteExceptions, therefore I had to redesign my project and add a NetworkDataAdapter. NetworkDataAdapter contained all the method signatures defined in DBAcces PLUS the RemoteException. Finally I changed my Naming.lookup to this:

    (NetworkDataAdapter)Naming.lookup("rmi://localhost/RemoteDatabase2");

    Smooth sailing from there on out. Thanks again for all of your help!
    [ October 12, 2005: Message edited by: Dustin Tosh ]
     
    Steve Smith
    Greenhorn
    Posts: 26
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Glad you sorted it! One more thing I noticed was this:



    When I used code similar to this it failed if I started the RMI on anything other than port 1099. It may be worth testing to see if you have the same problem. The fix is to use something like this //localhost:port/RemoteDatabase2 instead of just RemoteDatabase2.
    [ October 12, 2005: Message edited by: Steve Smith ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic