Announcement Announcement Module
Collapse
No announcement yet.
Problem is exposing my bean as RMI Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem is exposing my bean as RMI

    I am new to springs I want expose my bean as rmi getting some exception

    java.rmi.ConnectException: Connection refused to host: 10.224.10.90; nested exception is:
    java.net.ConnectException: Connection refused: connect

    /************************************************** *******/
    public class userClient {

    public static void main(String[] args) throws Exception {

    Test test =
    (Test)Naming.lookup(
    "rmi://<host>:1100/Test");
    test.Name("HI Dude");

    }
    }
    /*****************************8
    public interface TestInterface {

    public String Name(String Name);
    }
    /*********************************************
    public class Test implements TestInterface {

    public Test() {}
    public String Name(String name){
    System.out.println("Your name is "+name);
    return name;
    }

    }
    ///**************************************************
    and finally my config file

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <bean id="test" class="Test">
    </bean>
    <bean class="org.springframework.remoting.rmi.RmiService Exporter">
    <property name="service">
    <ref bean="test"/>
    </property>
    <property name="serviceName">
    <value>Test</value>
    </property>
    <property name="serviceInterface">
    <value>TestInterface</value>
    </property>
    <property name="registryPort">
    <value>1100</value>
    </property>
    </bean>
    </beans>
    //

    Thank in advance..


    -Delhi

  • #2
    I have solved the problem while starting the server first:

    public class Server {

    public static void main(String[] args) {
    BasicConfigurator.configure();
    try {

    BeanFactory bf =
    new ClassPathXmlApplicationContext(
    "userapplication.xml");
    } catch (BeanCreationException bce) {
    bce.printStackTrace();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    }
    After this you should be able to run your client.

    nort
    Last edited by nort; May 3rd, 2006, 04:43 PM.

    Comment


    • #3
      RmiServiceExporter does not manage to start the RMI registry

      Hi,

      Regarding your post as well as
      http://forum.springframework.org/arc...p/t-14191.html
      http://forum.springframework.org/arc...p/t-16222.html

      I'm facing the same issue, I use spring 1.2.8, Eclipse 3.1, JRE set to C:\Program Files\Java\jdk1.5.0_06, project set to be JDK 1.4 compliant, even when shutting down the firewall, the eclipse console shows 07/07/2006 14:14:04 INFO [main] org.springframework.remoting.rmi.RmiServiceExporte r.getRegistry(RmiServiceExporter.java:280) - Looking for RMI registry at port '1199' of host [localhost]
      2140 [main] INFO org.springframework.remoting.rmi.RmiServiceExporte r - Looking for RMI registry at port '1199' of host [localhost]
      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.remoting.rmi.RmiServiceExport er' defined in URL [file:/C:/eclipse/workspace/Spring/bin/demo/spring/live/service/employee/impl/appContext-rmi.xml]: Initialization of bean failed; nested exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
      java.net.ConnectException: Connection refused: connect
      java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
      java.net.ConnectException: Connection refused: connect
      at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEnd point.java:574)
      at sun.rmi.transport.tcp.TCPChannel.createConnection( TCPChannel.java:185)
      at sun.rmi.transport.tcp.TCPChannel.newConnection(TCP Channel.java:171)
      at sun.rmi.server.UnicastRef.newCall(UnicastRef.java: 306)
      at sun.rmi.registry.RegistryImpl_Stub.list(Unknown Source)

      I have this behaviour wether I use or not your RmiServer which is just loading the server appContext.xml (no confusion with any beanRefFactory.xml of a client). I tried as well to update the file C:\Program Files\Java\jdk1.5.0_06\jre\lib\security/java.policy adding the section grant {
      permission java.net.SocketPermission "*:1024-65535",
      "connect,accept";
      permission java.net.SocketPermission "*:80", "connect";
      };

      But unfortunately this does not help much.

      I also tried to start manually the C:\Program Files\Java\jdk1.5.0_06\jre\bin\rmiregistry , in that case spring can connect to this one but then the program fails as none of my class are set in the RMI Reg classpath:
      2578 [main] INFO org.springframework.remoting.rmi.RmiServiceExporte r - Binding RMI service 'EmployeeService' to registry at port '1099'
      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.remoting.rmi.RmiServiceExport er' defined in URL Initialization of bean failed; nested exception is java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
      java.lang.ClassNotFoundException: org.springframework.remoting.rmi.RmiInvocationWrap per_Stub
      java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
      java.lang.ClassNotFoundException: org.springframework.remoting.rmi.RmiInvocationWrap per_Stub
      at sun.rmi.server.UnicastServerRef.oldDispatch(Unicas tServerRef.java:385)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:240)
      at sun.rmi.transport.Transport$1.run(Transport.java:1 53)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport. java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages( TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandl er.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceiv edFromServer(StreamRemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(Str eamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:3 43)
      at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)


      Any idea would be greatly welcome !

      Comment


      • #4
        Same Problem

        I apologize I have no suggestion: I have the exact same
        problem and I would too appreciate any hints.

        Thanks,

        Ur

        Comment


        • #5
          Originally posted by nort
          I have solved the problem while starting the server first:



          After this you should be able to run your client.

          nort
          Could you please explain what part of the your code snippet
          solves the problem?

          Thanks,

          Ur

          Comment


          • #6
            Don't use BeanFactory

            if you Exposing your bean as RMI DON'T use BeanFactory for configuration instead use ApplicationContext

            Comment

            Working...
            X