2017-04-26 81 views
0

我想实现与RMI和AOP的Spring应用程序。我的服务器组件有问题。如果接口扩展Remote它的作品只是起点等精细RMI与春天和AOP

UnknownAdviceTypeException: Advice object [org.springframework.context.annotati[email protected]1f90645] is neither a supported subinterface of [org.aopalliance.aop.Advice] nor an [org.springframework.aop.Advisor] 

:如果服务接口,我要揭露不延长Remote和方法不抛出RemoteException,我得到的错误。 我application.xml只有一个豆声明:

<bean id="testService" class="org.springframework.remoting.rmi.RmiServiceExporter"> 
    <property name="serviceName" value="TestService" /> 
    <property name="service" ref="testServiceImpl"/> 
    <property name="serviceInterface" 
     value="xxx.service.TestService" /> 
</bean> 

我的接口只有在@Transactional注解,而实现具有@Service注解。

在我的客户端,我也收到错误。在这里,我得到一个不是唯一的bean的错误:发现bean testServicetestServiceImpl。我client.xml的是这样的:

<bean class="xxx.start.Client"> 
    <property name="testService" ref="testService"/> 
</bean> 

<bean id="testService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean"> 
    <property name="serviceUrl" value="rmi://localhost:1099/TestService"/> 
    <property name="serviceInterface" value="xxx.service.TestService"/> 
</bean> 

我跟着这个guide,但上面去的错误。如果你能帮助我很高兴。如果我运行没有RMI的JUnit测试,它的工作都很好

+0

不要把'@ Transactional'在接口这会导致问题。把它放在你的实现上。有了这个设置,你现在有了一个代理服务器代理服务器。 –

+0

@ M.Deinum但不是'@ Transactinal'为类中的所有方法打开一个事务?如果是的话,它也会为不需要的方法开放一个事务。我在impl上用'@ Transactional'对其进行了测试,并且我仍然得到关于建议的错误 – XtremeBaumer

+0

无论它是否在界面上,它仍然会执行,它只会应用于公共方法(它应该只是您的接口方法)。 –

回答

0

我发现它为什么会抛出错误。这是因为我有default-autowiring设置为byType,但RmiServiceExporter应该有autowire=no