Announcement Announcement Module
Collapse
No announcement yet.
RMI newbie-- getting errors in STS for imports in client side app java code Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • RMI newbie-- getting errors in STS for imports in client side app java code

    Hi

    I am trying to create an RMI service using Spring. The IDE I am using is the latest version of Spring Tool Suite.

    I am following instructions as per this URL--> http://www.onlinetechvision.com/?p=510

    Now, I have created the server-side code correctly, and the RMI server app context XML file is as below-->

    <!-- Beans Declaration -->
    <bean id="SampleTask" class="com.test.SampleTask" />



    <!-- RMI Server Declaration -->
    <bean class="org.springframework.remoting.rmi.RmiService Exporter">

    <!-- serviceName represents RMI Service Name -->
    <property name="serviceName" value="SampleTask"/>

    <!-- service represents RMI Object(RMI Service Impl) -->
    <property name="service" ref="SampleTask"/>

    <!-- serviceInterface represents RMI Service Interface exposed -->
    <property name="serviceInterface" value="com.test.Task"/>

    <!-- defaults to 1099 -->
    <property name="registryPort" value="1099"/>

    </bean>

    Now, I have created the client side app also, and in it this is the code-- (I have omitted the imports/package name)--basically a single variable of integer type is passed as command line param to the client JAR file. This parm is then used as param during call to RMI Service. (It is the only param in RMI invocation).



    public class TestClient {

    private static Logger logger = Logger.getLogger(TestClient .class);

    /**
    * Main method of the RMI Service Client
    *
    */
    public static void main(String[] args) {

    logger.debug("RMI Service Client is starting...");

    //RMI Client Application Context is started...
    ApplicationContext context = new ClassPathXmlApplicationContext("rmiClientAppContex t.xml");

    //Remote User Service is called via RMI Client Application Context...
    SampleTaskrmiClient = (SampleTask) context.getBean("SampleTask");
    int userid;
    //get the user id for whom RMI is to be used...this was passed as an argument to the client JAR file...
    if(args.length!=1)
    System.exit(1);
    else userid= Integer.parseInt(args[0]);

    rmiClient.run(userid);


    logger.debug("RMI Service Client is stopped...");
    }
    }

    Also, the RMI Client App context XML file is as below--

    <!-- RMI Client Declaration -->
    <bean id="SampleTask" class="org.springframework.remoting.rmi.RmiProxyFa ctoryBean">

    <!-- serviceUrl represents RMI Service Url called-->
    <property name="serviceUrl" value="rmi://api.test.com:1099/SampleTask"/>

    <!-- serviceInterface represents RMI Service Interface called -->
    <property name="serviceInterface" value="com.test.Task"/>

    <!-- refreshStubOnConnectFailure enforces automatic re-lookup of the stub if a
    call fails with a connect exception -->
    <property name="refreshStubOnConnectFailure" value="true"/>

    </bean>


    However I am getting errors in Eclipse-- basically for the 2 imports in client side java code-- the imports for "com.test.SampleTask" and "com.test.Task" are showing this error--> The import _ _ _ _ _ cannot be resolved.

    What is wrong in my code? Is there some config/setting change that I have to make?

    Thanks,
    Arvind.
Working...
X