Hi guys:
I have the server application:
Interface:
Implementation:Code:public interface ServiceInterface extends Remote { public String syaHello() throws RemoteException; }
xmlCode:public class ServiceImplementation extends UnicastRemoteObject implements ServiceInterface{ /** * */ private static final long serialVersionUID = 2262342784592437834L; protected ServiceImplementation() throws RemoteException { super(); // TODO Auto-generated constructor stub } public String syaHello() throws RemoteException { return "Server says, Hey"; } }
Main:Code:<beans> <bean id="printService" class="au.com.test.ServiceImplementation"></bean> <bean id="rmiServer" class="org.springframework.remoting.rmi.RmiServiceExporter"> <!-- does not necessarily have to be the same name as the bean to be exported --> <property name="serviceName" value="PrintService"/> <property name="service" ref="printService"/> <property name="serviceInterface" value="au.com.test.ServiceInterface"/> <!-- defaults to 1099 --> <property name="registryPort" value="1199"/> </bean> </beans>
When i try to run the main class, it throws Exception:Code:public class Main { public static void main(String[] args){ ApplicationContext context = new ClassPathXmlApplicationContext("service.xml"); RmiServiceExporter server = (RmiServiceExporter)context.getBean("rmiServer"); server.prepare(); System.out.println("I am ready, Server !!!"); } }
Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'rmiServer' defined in class path resource [service.xml]: Invocation of init method failed; nested exception is java.rmi.server.ExportException: object already exported
Caused by: java.rmi.server.ExportException: object already exported
Do you have any idea?
Thanks
Tony


Reply With Quote