views:

22

answers:

1

Hi, 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

A: 

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.

aivaldi