Announcement Announcement Module
No announcement yet.
Spring RMI problem : help Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring RMI problem : help

    I have following the tutorial from ebook Pro Spring 2.5, and this is my code to make RMI in Spring

    package server;
    public interface HelloWorld
    public String getMessage();

    package server;
    public class SimpleHelloWorld implements HelloWorld
    public String getMessage()
    return "Hello World";

    package server;

    import org.springframework.context.ApplicationContext;
    import plicationContext;

    public class HelloWorldHost {
    public static void main(String[] args) throws Exception {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("helloworld.xml");
    System.out.println("Host Started...");


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="">
    <bean id="helloWorldService" class="server.SimpleHelloWorld"/>
    <bean id="serviceExporter" class="org.springframework.remoting.rmi.RmiService Exporter">
    <property name="serviceName" value="HelloWorld" />
    <property name="service" ref="helloWorldService" />
    <property name="serviceInterface" value="server.HelloWorld" />
    <property name="registryPort" value="9000" />
    <property name="servicePort" value="9001" />

    This is the project structure directory

    Then i have to compile each file from terminal using this command:

    erwin:~ erwinsetiawan$ cd Documents/workspace/SpringHelloRMI
    erwin:SpringHelloRMI erwinsetiawan$ javac -d bin -sourcepath src -classpath lib/spring-context.jar:lib/spring-core.jar:lib/spring-beans.jar src/server/*.java

    and success, all class have been in bin folder now.

    My problem are:
    1. I can't run its class well from terminal, when I call the server I got this error
    erwin:server erwinsetiawan$ rmic SimpleHelloWorld
    error: File ./SimpleHelloWorld.class does not contain type SimpleHelloWorld as expected, but type server.SimpleHelloWorld. Please remove the file, or make sure it appears in the correct subdirectory of the class path.
    error: Class SimpleHelloWorld not found.
    2 errors


    erwin:server erwinsetiawan$ java HelloWorldHost
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldHost (wrong name: server/HelloWorldHost)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader. java:632)
    at java.lang.ClassLoader.defineClass( :616)
    at .java:283)
    at$000(URLClassLoader. java:58)
    at$ 197)
    at Method)
    at ava:190)
    at java.lang.ClassLoader.loadClass( 07)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche
    at java.lang.ClassLoader.loadClass( 48)
    erwin:server erwinsetiawan$
    2. I don't know really how to make my RMI server run on Mac OS terminal.

    Please Help! Thanks

  • #2
    Hi, you can use the RMI Compiler Maven Plugin.