Announcement Announcement Module
Collapse
No announcement yet.
Spring RMI problem : help Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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

    HelloWorld.java

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




    SimpleHelloWorld.java

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



    HelloWorldHost.java

    package server;

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

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


    helloworld.xml


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans">
    <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" />
    </bean>
    </beans>

    This is the project structure directory

    http://img6.imageshack.us/img6/1447/...10706at358.png


    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

    and

    erwin:server erwinsetiawan$ java -Djava.security.policy=server.policy 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(ClassLoader.java :616)
    at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader .java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader. java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 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.

    Comment

    Working...
    X