How to invoke RMI call in java service

I want to call a remote java service via RMI call from within a java service.
I have a Hello server that I can call from a java client running in a command window. Now I want to call the same java service from a java client running under IS.

Following is my code. It fails at the call to Naming.lookup with the following message (note, rmiregistry is running and the Hello service is bound to it):

Could not run ‘helloClient’.
java.lang.reflect.InvocationTargetException: HelloInterface

/**helloClient java service for the “Hello, world!” example. */
try {
System.out.println (“Starting HelloClient”);
String host = “ladson-hp”;
HelloInterface hello;
hello =(HelloInterface) Naming.lookup (“//” + host + “/Hello”);
System.out.println (hello.say());
catch (Exception e) {
System.out.println ("HelloClient exception: " + e);


Are all of the required classes for HelloInterface in the IS classpath? I would assume so since your java service compiles.

When the HelloServer is started and registered does the lookup name match the string being assembled in your code (e.g. “//ladson-hp/Hello”)?


I am able to run the same java client code from a dos window, indicating that the server is running and the registry is accurate. When running under IS the java code seems to have a problem with reflection, maybe because there is an additional layer of code (that is, IS) underneath the lookup call.

Is this a simple example that you could share? How is your HelloClient connecting to the RMI registry server? I would think you would need a port number in addition to the host name, but its hard to tell without looking at the code.


I have uploaded which contains the following java files: (server) (client)

Also included are two batch files:

Simply unzip the files into a directory. Start a DOS window and run the first batch file (compiles all java, runs rmic, starts rmiregistry, and runs the server)

Then start another DOS window and run the second batch file (runs the client)

The server should deliver the message “Hello World” to the client. That is the behavior I am trying to emulate under IS.

BTW, the port defaults to 1099. (6 KB)

I want to import the class HelloInterface.class into my java service, but I don’t know where to put the class file on the file system. Given the java service name is

and the dependent class is

Where do I place the HelloInterface.class class file?

C:\webMethods6\IntegrationServer\lib ???
C:\webMethods6\IntegrationServer\packages\IRS_RMI\lib ???
other ???

Here is what I deduce re placement of class files to support java services.

  1. All subordinate class files must be placed in a jar (or zip) file. One cannot import a freestanding class that does not reside in a jar/zip

  2. Place the jar in the following folder to make it available server-wide (you must restart IS before the jar is recognized)


  1. Place the jar/zip in the following folder to make it available to a given package (say JavaclassExample)


You need not re-start IS to make the jar/zip available.

  1. Here is how you reference the class in various contexts.

a. JavaclassExample (package name)
javaclassExample (top level folder name)
javaFolder (second level folder name)
javaService (java service name)

b. javaFolder.MyClass (import reference)

c. String myVariable = MyClass.myMethod(“World”); (code within java svc)

d. myFolder\MyClass.class (contents of jar/zip file)

Here is my java service:
System.out.println(“starting javaService”);
String myVariable = MyClass.myMethod(“World”);
System.out.println("myMethod returned " + myVariable);
System.out.println(“stopping javaService”);

Here is my external supporting class:
import java.lang.String;

public class MyClass
public static String myMethod(String str)
System.out.println(“MyClass.myMethod started with input=” + str);
return str.toUpperCase();


You can import a class for your java services but your classes need to use a package declaration. I think the package name should be the name of any folders above your java service (e.g. folder.subfolder.subfolder), but I always have to experiement to get this right. Take a look at the package declaration in the java source generated from your java service for a hint.