RE: [Mx4j-user] RE: Hessian connector

<[email protected]>
Newsgroups gmane.comp.java.mx4j.devel
Message-ID <3DBB246A773D8A4DAF28AAEB59EC827CAAF44D@BEAVIS.daxtechnologies.com>
Hi Bordet,
 
Me again. After I change Hessian version to 3.0.13, rebuild MX4J(after
changes serializer and deserialize to be compatible with the new API,
see bellow) and I made a few tests
Everything seems to be ok, at lease for my application. In deserializer
I throw some exceptions in some new methods, just to know if it will use
that new API.
 
Do you think is possible to use Hessin 3.0.13 in the next release, and
when it is planned?
 
 
public Object readObject(AbstractHessianInput in) throws IOException {
        throw new RuntimeException("If you are here, something is wrong
:)");
    }
 
    public Object readList(AbstractHessianInput in, int length) throws
IOException {
        throw new RuntimeException("If you are here, something is wrong
:)");
    }
 
 
 
------------------------------------------------------------------------
-------------------------------------------------------
/*
 * Copyright (C) The MX4J Contributors.
 * All rights reserved.
 *
 * This software is distributed under the terms of the MX4J License
version 1.0.
 * See the terms of the MX4J License in the documentation provided with
this software.
 */
 
package mx4j.tools.remote.caucho.serialization;
 
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
 
import com.caucho.hessian.io.AbstractHessianOutput;
import com.caucho.hessian.io.Serializer;
 
/**
 * @version $Revision: 1.3 $
 */
class JMXSerializer implements Serializer
{
 
   public void writeObject(Object obj, AbstractHessianOutput out) throws
IOException
   {
      out.writeMapBegin(obj.getClass().getName());
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(obj);
      oos.close();
      out.writeBytes(baos.toByteArray());
   }
}
------------------------------------------------------------------------
-------------------------------------------------------
 
/*
 * Copyright (C) The MX4J Contributors.
 * All rights reserved.
 *
 * This software is distributed under the terms of the MX4J License
version 1.0.
 * See the terms of the MX4J License in the documentation provided with
this software.
 */
 
package mx4j.tools.remote.caucho.serialization;
 
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
 
import com.caucho.hessian.io.AbstractHessianInput;
import com.caucho.hessian.io.Deserializer;
 
/**
 * @version $
 */
class JMXDeserializer implements Deserializer
{
   private Class type;
 
   JMXDeserializer(Class type)
   {
      this.type = type;
   }
 
   public Class getType()
   {
      return type;
   }
 
    public Object readObject(AbstractHessianInput in) throws IOException
{
        throw new RuntimeException("If you are here, something is wrong
:)");
    }
 
    public Object readList(AbstractHessianInput in, int length) throws
IOException {
        throw new RuntimeException("If you are here, something is wrong
:)");
    }
 
   public Object readMap(AbstractHessianInput in) throws IOException
   {
      try
      {
         byte[] bytes = in.readBytes();
         ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
         ObjectInputStream ois = new ObjectInputStream(bais);
         Object result = ois.readObject();
         ois.close();
         return result;
      }
      catch (ClassNotFoundException x)
      {
         throw new IOException(x.toString());
      }
   }
}
 
 
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Bordet,
Simone
Sent: Tuesday, May 31, 2005 2:25 AM
To: Adrian Tarau; [email protected]
Subject: [Mx4j-user] RE: Hessian connector
 
Adrian,
 
which version of Hessian are you using ?
MX4J works with Hessian 3.0.8.
 
Simon
 

  _____  

From: [email protected]
[mailto:[email protected]] On Behalf Of Adrian Tarau
Sent: Monday, May 30, 2005 20:23
To: [email protected]
Subject: Hessian connector
I tried to use hessian connector and all the time I get this exception.
 
java.lang.IncompatibleClassChangeError: class
mx4j.tools.remote.caucho.serialization.JMXSerializer has interface
com.caucho.hessian.io.Serializer as super class
         at
mx4j.tools.remote.caucho.serialization.JMXSerializerFactory.getDefaultSe
rializer(JMXSerializerFactory.java:23)
         at
com.caucho.hessian.io.SerializerFactory.getSerializer(SerializerFactory.
java)
         at
com.caucho.hessian.io.HessianOutput.writeObject(HessianOutput.java:305)
         at
mx4j.tools.remote.caucho.hessian.HessianCauchoOutput.writeObject(Hessian
CauchoOutput.java:82)
         at
mx4j.tools.remote.caucho.CauchoClientInvoker$CauchoServiceProxy.writeArg
uments(CauchoClientInvoker.java:120)
         at
mx4j.tools.remote.caucho.CauchoClientInvoker$CauchoServiceProxy.invoke(C
auchoClientInvoker.java:66)
         at $Proxy0.invoke(Unknown Source)
         at
mx4j.tools.remote.http.HTTPClientInvoker.invoke(HTTPClientInvoker.java:1
17)
         at
mx4j.tools.remote.JMXConnectionMBeanServerConnection.invoke(JMXConnectio
nMBeanServerConnection.java:130)
 
JMXSerializer is defined below: 
 
class JMXSerializer extends Serializer
{
   public void writeObject(Object obj, AbstractHessianOutput out) throws
IOException
   {
      out.writeMapBegin(obj.getClass().getName());
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(obj);
      oos.close();
      out.writeBytes(baos.toByteArray());
   }
}
 
but Serializer is and interface com.caucho.hessian.io.Serializer so no
wander why JVM throws that error.
 
I use MX4J 3.0.1
 
Kind regards,
Adrian Tarau
 
Software Engineer
DAX Technologies Corp.
Matawan, New Jersey, 07747, U.S.
Tel:       (732) - 203 - 1784 x 125
Mobile:  (848) - 218 - 0804
Fax:      (732) - 203 - 1786
E-Mail:   <mailto:[email protected]> [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.