Mbeans 与 JBoss
我正在尝试调用部署在 JBoss 中的 MBean,但遇到此异常:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.io.InvalidClassException: org.jboss.security.auth.callback.SecurityAssociationHandler; org.jboss.security.auth.callback.SecurityAssociationHandler; class invalid for deserialization at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:293) at sun.rmi.transport.Transport$1.run(Transport.java:159) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:155) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:637) Caused by: java.io.InvalidClassException: org.jboss.security.auth.callback.SecurityAssociationHandler; org.jboss.security.auth.callback.SecurityAssociationHandler; class invalid for deserialization at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:713) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1733) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at org.jboss.invocation.MarshalledInvocation.readExternal(MarshalledInvocation.java:665) at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1792) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1751) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:290) ... 9 more Caused by: java.io.InvalidClassException: org.jboss.security.auth.callback.SecurityAssociationHandler; class invalid for deserialization at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:587) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732) ... 22 more
我正在使用 JBoss 5.1.0GA,并且客户端代码是
Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); env.put(Context.PROVIDER_URL, "jnp://localhost:1099"); InitialContext ctx; ctx = new InitialContext(env); MBeanServerConnection server = (MBeanServerConnection)ctx.lookup("jmx/rmi/RMIAdaptor"); // get reference to CacheMgmtInterceptor MBean String cache_service = "jboss:service=JNDIView"; ObjectName mgmt_name = new ObjectName(cache_service); System.out.println( server.getMBeanInfo(mgmt_name).getClassName()); Object[] obj = new String[1]; obj[0]= new String("hello Sapo pepe"); Object temp = server.invoke(mgmt_name, "sayHello", obj, new String[]{"String"}); System.out.println(temp);
我可以访问抛出 JBOSS JNDI-Console,因此 MBean 正在工作。 提前致谢
I'm trying to call a MBean deployed in JBoss, but i'm having this exception:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.io.InvalidClassException: org.jboss.security.auth.callback.SecurityAssociationHandler; org.jboss.security.auth.callback.SecurityAssociationHandler; class invalid for deserialization at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:293) at sun.rmi.transport.Transport$1.run(Transport.java:159) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:155) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:637) Caused by: java.io.InvalidClassException: org.jboss.security.auth.callback.SecurityAssociationHandler; org.jboss.security.auth.callback.SecurityAssociationHandler; class invalid for deserialization at java.io.ObjectStreamClass.checkDeserialize(ObjectStreamClass.java:713) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1733) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at org.jboss.invocation.MarshalledInvocation.readExternal(MarshalledInvocation.java:665) at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1792) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1751) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:306) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:290) ... 9 more Caused by: java.io.InvalidClassException: org.jboss.security.auth.callback.SecurityAssociationHandler; class invalid for deserialization at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:587) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732) ... 22 more
I'm using JBoss 5.1.0GA and the client code is
Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); env.put(Context.PROVIDER_URL, "jnp://localhost:1099"); InitialContext ctx; ctx = new InitialContext(env); MBeanServerConnection server = (MBeanServerConnection)ctx.lookup("jmx/rmi/RMIAdaptor"); // get reference to CacheMgmtInterceptor MBean String cache_service = "jboss:service=JNDIView"; ObjectName mgmt_name = new ObjectName(cache_service); System.out.println( server.getMBeanInfo(mgmt_name).getClassName()); Object[] obj = new String[1]; obj[0]= new String("hello Sapo pepe"); Object temp = server.invoke(mgmt_name, "sayHello", obj, new String[]{"String"}); System.out.println(temp);
I can access throw the JBOSS JNDI-Console, so the MBean is working.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,问题是 Eclipse 执行客户端时类路径中没有 jboss 客户端 jar。
解决方案是在 Eclipse 的运行配置选项的类路径选项卡中添加 jar 文件。
Ok, the problem was that Eclipse execute the client without jboss client jars in the classpath.
the solution was adding the jars files in the classpath tab in the run configurations option from the eclipse.