Hy!
Please HELP! The ServerProg is running but I have still problems with the Client.
SERVER:
<beans>
<bean id="accountService" class="de.sonic.rmi.server02.AccountServiceImpl" />
<bean class="org.springframework.remoting.rmi.RmiService Exporter">
<property name="serviceName" value="AccountService"/>
<property name="service" ref="accountService"/>
<property name="serviceInterface" value="de.sonic.rmi.server02.AccountService"/>
<property name="registryHost" value="<real IP 10...>"/>
<!-- defaults to 1099 -->
<property name="registryPort" value="1099"/>
</bean>
</beans>
public interface AccountService {
public void insertAccount(Account acc);
public List getAccounts(String name); }
public class AccountServiceImpl implements AccountService {
List accounts = new ArrayList();
public void insertAccount(Account acc) {accounts.add(acc);}
public List getAccounts(String name) {return listOfAccounts;} }
public class Account implements Serializable {
private String name;
public String getName() { return name; };
public void setName(String name) {this.name = name;}}
public static void main(String[] args) {
String codebase = "http://<IP>/rmi/Spring_RMI_Server01_02/";;
System.setProperty( "java.rmi.server.codebase", codebase );
System.setProperty( "java.security.policy", codebase+"java.policy" );
System.setSecurityManager( new RMISecurityManager() );
try {
BeanFactory bf = new ClassPathXmlApplicationContext("de/sonic/rmi/server02/asd.xml");
} catch (BeanCreationException bce) {bce.printStackTrace();}
catch (Exception e) {e.printStackTrace();}
}
CLIENT:
<bean id="simpleClient" class="de.sonic.rmi.client02.SimpleClient">
<property name="accountService">
<ref bean="accountService"/>
</property>
</bean>
<bean id="accountService" class="org.springframework.remoting.rmi.RmiProxyFa ctoryBean">
<property name="serviceUrl">
<value>rmi://<IP>:1099/AccountService</value>
</property>
<property name="serviceInterface">
<value>de.sonic.rmi.client02.AccountService</value>
</property>
</bean>
public static void main(String[] args) {
String codebase = "http://<IP>/rmi/Spring_RMI_Server01_02/";;
System.setProperty( "java.rmi.server.codebase", codebase );
System.setProperty( "java.security.policy", codebase+"java.policy" );
System.setSecurityManager( new RMISecurityManager() );
BeanFactory bf = new ClassPathXmlApplicationContext("/de/sonic/rmi/client02/client.xml");
AccountService as = (AccountService)bf.getBean("accountService");
Account a = new Account();
a.setName("Sonic");
try {as.insertAccount(a);
} catch (Exception e) {e.printStackTrace();}
}
public class SimpleClient {
private AccountService accountService;
public void setAccountService(AccountService accountService) {
this.accountService = accountService;
}
public void insertNewAccount(Account acc) {
try {accountService.insertAccount(acc);
} catch (Exception e) {e.printStackTrace();}
}
public List getAccountsByName(String name) {
return accountService.getAccounts(name);}
}
public interface AccountService {
public void insertAccount(Account acc);
public List getAccounts(String name);
}
public class Account implements Serializable {
private String name;
public String getName() { return name; };
public void setName(String name) {this.name = name;}
}
The Server is starting, but the Client throws the following Error:
java.lang.NoSuchMethodException: $Proxy0.insertAccount(de.sonic.rmi.client02.Accoun t)
at java.lang.Class.getMethod(Class.java:1581)
at org.springframework.remoting.support.RemoteInvocat ion.invoke(RemoteInvocation.java:178)
at org.springframework.remoting.support.DefaultRemote InvocationExecutor.invoke(DefaultRemoteInvocationE xecutor.java:33)
at org.springframework.remoting.support.RemoteInvocat ionBasedExporter.invoke(RemoteInvocationBasedExpor ter.java:76)
at org.springframework.remoting.rmi.RmiBasedExporter. invoke(RmiBasedExporter.java:72)
at org.springframework.remoting.rmi.RmiInvocationWrap per.invoke(RmiInvocationWrapper.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastSe rverRef.java:294)
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:1 26)
at org.springframework.remoting.rmi.RmiInvocationWrap per_Stub.invoke(Unknown Source)
at org.springframework.remoting.rmi.RmiClientIntercep tor.doInvoke(RmiClientInterceptor.java:347)
at org.springframework.remoting.rmi.RmiClientIntercep tor.doInvoke(RmiClientInterceptor.java:294)
at org.springframework.remoting.rmi.RmiClientIntercep tor.invoke(RmiClientInterceptor.java:209)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :170)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy0.insertAccount(Unknown Source)
at de.sonic.rmi.client02.MyRMIClient.main(MyRMIClient .java:41)
Why is the Programm searching for the Method in Account?
An Errors in the ConfigFiles? The App without Spring (only RMI) is running. I have to compare the speed of the different implementations. Hessian and HTTPInvoker will be tested later.
Thanks a lot!
Sonic


Reply With Quote
)