Mbeans 与 JBoss

发布于 2024-09-25 04:05:11 字数 3990 浏览 8 评论 0原文

我正在尝试调用部署在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪也成诗 2024-10-02 04:05:11

好吧,问题是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文