2 zsx0321 zsx0321 于 2015.06.17 00:53 提问

spring4.03 rmi apache james2.3报错 20C

用jconsole调用
service:jmx:rmi://131.124.95.113:10202/jndi/rmi://131.124.95.113:10201/jmxrmi
可以直接连接上并且调用方法
图片说明
图片说明
但是用spring client调用就不行
下面是我的配置:

 <bean id="mainJAMESServerManagement" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
        <property name="serviceUrl">
                <value>service:jmx:rmi://131.124.95.113:10202/jndi/rmi://131.124.95.113:10201/jmxrmi</value>
        </property>
        <property name="serviceInterface">
                <value>com.test.remote.MainJAMESServerManagement</value>
        </property>
</bean>

初始化bean就报错为:
java.net.MalformedURLException: not a hierarchical URL: service:jmx:rmi://131.124.95.113:10202/jndi/rmi://131.124.95.113:10201/jmxrmi
at java.rmi.Naming.intParseURL(Naming.java:258)
at java.rmi.Naming.parseURL(Naming.java:220)
at java.rmi.Naming.lookup(Naming.java:79)
at org.springframework.remoting.rmi.RmiClientInterceptor.lookupStub(RmiClientInterceptor.java:200)
at org.springframework.remoting.rmi.RmiClientInterceptor.prepare(RmiClientInterceptor.java:147)
at org.springframework.remoting.rmi.RmiClientInterceptor.afterPropertiesSet(RmiClientInterceptor.java:135)
at org.springframework.remoting.rmi.RmiProxyFactoryBean.afterPropertiesSet(RmiProxyFactoryBean.java:68)

这句的意思貌似为url格式不正确,我改为
rmi://131.124.95.113:10201/jmxrmi
这回初始化不报错,调用的时候报错

 <bean id="mainJAMESServerManagement" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
        <property name="serviceUrl">
                <value>rmi://131.124.95.113:10201/jmxrmi</value>
        </property>
        <property name="serviceInterface">
                <value>com.test.remote.MainJAMESServerManagement</value>
        </property>
</bean>

报错为:
java.lang.NoSuchMethodException: javax.management.remote.rmi.RMIServerImpl_Stub.addUser(java.lang.String, java.lang.String)
at java.lang.Class.getMethod(Class.java:1605)
at org.springframework.remoting.rmi.RmiClientInterceptorUtils.invokeRemoteMethod(RmiClientInterceptorUtils.java:75)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:364)
at org.springframework.remoting.rmi.RmiClientInterceptor.invoke(RmiClientInterceptor.java:260)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
提示没有这个方法,但是远程抽象接口里面真的有这个方法,如上图。求高手解答

2个回答

u012006909
u012006909   2015.06.17 16:54

看一下你这个类MainJAMESServerManagement

zsx0321
zsx0321 发下面了
2 年多之前 回复
zsx0321
zsx0321   2015.06.18 21:46
 public interface MainJAMESServerManagement{

    boolean addUser(String userName, String password);
}
Csdn user default icon
上传中...
上传图片
插入图片