Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
|
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 23rd, 2003, 09:33 AM
Registered User
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem running RMI

Hello,

I am experimenting with Java RMI. I know RMI is a part of J2SE and not J2EE but I have this example from "Professional Java Server Programming J2EE 1.3 Edition" and you don't have any other appropriate thread for it.

After I have bought "Professional Java
Server Programming J2EE 1.3 Edition" from WROX I try to run the first
RMI-example. But something is going wrong:

1) if I try to run rmiregistry with appropriate policy-file, I get buffer
   overflow exception from RegisterIt - class (after a very long time)
   while registring my server-class.

2) in some faq - lists I found a work-around with
   sun.rmi.registry.RegistryImpl ("java
   -Djava.security.policy=registerit.policy
   sun.rmi.registry.RegistryImpl").

   So I first create server class. Next I create server stub
   (now they are matching). Then I create client class and registration class.
   Now I start registry and register my server-class, but if
   I try to connect it from my client class, I still get
   "java.rmi.UnmarshalException: invalid method hash".

   I know this exception appears if my stub is not matching my remote server
   class. But it is not possible because I always generate my stub after
   creating server class so they must be synchronized.

3) When I try out Activatable example on my system and try to registry my
   activatable server class I get connection refused exception (rmid is
   running). I can only register my server class if
   sun.rmi.registry.RegistryImpl is running too. But then I get invalid method
   hash when I was trying to run my client class.

Has anyone an idea what is going wrong?
Why rmiregistry does not work on my system?
Why rmid does not work?

I am wondering if I have to set some environmental variables because of the
fact that nothing concerned rmi is running on my system properly.

I am working with Java 1.4.1 and BlackdownJava2-1.4.1.

Lydia


   Here are my files (not for activatable example):

   Server-Interface

Code:
public interface HelloInterface extends java.rmi.Remote
{
    // This method is called by remote clients and is implemented
    // by remote object
    public String hello() throws java.rmi.RemoteException;
}
   Server-Class

Code:
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;

public class HelloServer extends UnicastRemoteObject
                         implements HelloInterface
{
    public HelloServer() throws RemoteException
    {
        super();
    }

    public String hello() throws RemoteException
    {
        return "Hello World";
    }
}
    Register-Class

Code:
import java.rmi.*;

public class RegisterIt
{
    public static void main(String args[])
    {
        try
        {
        HelloServer obj = new HelloServer();
        System.err.println("Object instantiated : " + obj);
        System.err.println("rebinding HelloServer...");
        Naming.rebind("/HelloServer", obj);
        System.err.println("HelloServer bound in registry");
        }
        catch (Exception e)
        {
        e.printStackTrace();
        }
    }
}
    Client-Class

Code:
import java.rmi.*;

public class HelloClient
{
    public static void main(String args[])
    {
        if (System.getSecurityManager() == null)
        {
        System.setSecurityManager(new RMISecurityManager());
        }

        try
        {
            HelloInterface obj = (HelloInterface) Naming.lookup("/HelloServer");
        String message = obj.hello();
        System.err.println(message);

        }
        catch (Exception e)
        {
        e.printStackTrace();
        }
    }
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
First RMI Program Pratik_Garg J2EE 1 April 4th, 2006 03:41 AM
RMI newbie NickTheBubble J2EE 0 December 17th, 2004 07:59 AM
Why rmi don't run? Edward King J2EE 2 December 7th, 2004 05:41 AM
java.rmi.UnmarshalException malar J2EE 1 August 10th, 2004 07:27 AM
help for running dynamic client/server pgm in rmi sivapmk J2EE 3 January 17th, 2004 10:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.