Serializable Objects - Clustering

          Hi,
          I want to know:
          For a Bean to support Fail Over(to be able to replicate on secondary server) in a
          cluster does it need to be Serilizable.
          If the bean is not serializable and is part of a cluster with the 'InMemory' replication
          type defined in weblogic-ejb-jar.xml if a fail over situation occurs what will happen.
          Your attention is sincerely appreciated.
          Thanks,
          Kiran
          

          Yes. That answers my question.
          Thanks,
          Kiran
          "Sudhir" <[email protected]> wrote:
          >
          >
          >Yes ,
          >it requires the bean or object Seriliazable interface.
          >Replication takes place by value not by ref.
          >Also wnen ever u change the object the value
          >use the SET attribute this is very imp in order to
          >get replicated.
          >
          >Hope this helps
          >Sudhir
          >
          >
          >
          >
          >
          >"Kiran" <[email protected]> wrote:
          >>
          >>Hi,
          >>
          >>I want to know:
          >>
          >>For a Bean to support Fail Over(to be able to replicate on secondary server)
          >>in a
          >>cluster does it need to be Serilizable.
          >>
          >>If the bean is not serializable and is part of a cluster with the 'InMemory'
          >>replication
          >>type defined in weblogic-ejb-jar.xml if a fail over situation occurs what
          >>will happen.
          >>
          >>Your attention is sincerely appreciated.
          >>
          >>Thanks,
          >>Kiran
          >>
          >>
          >>
          >
          

Similar Messages

  • Returning a serializable object from a java stored procedure

    [Server : Oracle 8.1.6 on WinNT4 server. Client : java 1.2.2 on WinNT4 workstation.]
    I am attempting to use a java stored procedure to build a complex serializable java object on the database (to minimise number of requests/queries on the network) and then return this object in response to the original query.
    I have it writing a BLOB by means of
    OutputStream os = retval.getBinaryOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(os);
    oos.writeObject(v);
    return retval;
    where retval is a blob selected from a dummy table (created for this purpose) and v is a vector containing only serializable objects.
    However, on the client side when I attempt to recover the object by
    OracleResultSet rs = (OracleResultSet)stmt.executeQuery("SELECT javatest FROM DUAL");
    oracle.sql.BLOB blob=rs.getBLOB(1);
    InputStream inp = blob.getBinaryStream();
    ObjectInputStream oinp = new ObjectInputStream(inp);
    Vector retval = (Vector)oinp.readObject();
    I get an exception telling me that the input stream does not contain an object at the line containing new ObjectInputStream(inp);
    The full exception is :
    java.io.StreamCorruptedException: InputStream does not contain a serialized object
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:731)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:165)
    at eRespond.DBLayer.JavaStoredProcedures.testdbobj.test2(testdbobj.java:143)
    at eRespond.DBLayer.JavaStoredProcedures.testdbobj.main(testdbobj.java, Compiled Code)
    I've checked that the returned blob is non-null, and that oracle.sql.BLOB is used throughout.
    Any thoughts?
    Thanks,
    mark.

    Firstly I guess to be able to new B() as a Thread, B
    should extends Thread.
    Secondly the constructor should not have any return
    type:
    public B(String cmd)
    instead of
    public void B(String cmd)
    Lastly there is no need to override the start() method
    if all it does is to call the superclass. The subclass
    automatically inherits the method.
    Hope this helps.thanks for replying so soon...
    yes, you are right, it should extends Thread and it is, i forgot to out in this example... my mistake!
    i'll try the construnctor thing to see if it works. bare in mind that i working with java stored procedures, it should work even so, right?
    thanks

  • Jndi and serializable objects

    Hi,
    I am attempting to create a cache on the web server to store
    frequently accessed reference data. I do so by running a series of
    queries in a startup class. The data retrieved from the result set of
    each query is stored in a custom class and bound to the server context.
    My understanding is that when serializable objects are bound, they are
    written to disk (so as not.to waste valuable Heap space I assume). As a
    test I made the startup query return a large amount of data and I
    expected to see the amount of free disk space decrease as the objects
    were bound however I did not see this occurring. I examined the memory
    usage of the java process with the NT task manager, and the memory usage
    was increasing pretty dramatically as the query results were performed
    and new objects created to store this data.
    Based on these observations I assume that the objects I created and
    bound are stored in the Java Heap and not written to disk. Would
    Weblogic at some point write these to disk if memory became tight or is
    my understanding that binding an object serializes it incorrect?
    If it turns out that what I am attempting here consumes a lot of heap
    space, I assume that server performance will suffer which is
    unacceptable. Would using read-only entity beans be a better solution?
    The container could manage this memory more effectively but it would
    seem to add a lot of overhead for a simple read only data cache.
    Thanks,
    Steve Snodgrass

    We never write jndi data to the disk. So if you add more objects your are
    going to take up more heap space. You should be looking at other
    alternatives to implement this.
    -- Prasad
    Steve Snodgrass wrote:
    Hi,
    I am attempting to create a cache on the web server to store
    frequently accessed reference data. I do so by running a series of
    queries in a startup class. The data retrieved from the result set of
    each query is stored in a custom class and bound to the server context.
    My understanding is that when serializable objects are bound, they are
    written to disk (so as not.to waste valuable Heap space I assume). As a
    test I made the startup query return a large amount of data and I
    expected to see the amount of free disk space decrease as the objects
    were bound however I did not see this occurring. I examined the memory
    usage of the java process with the NT task manager, and the memory usage
    was increasing pretty dramatically as the query results were performed
    and new objects created to store this data.
    Based on these observations I assume that the objects I created and
    bound are stored in the Java Heap and not written to disk. Would
    Weblogic at some point write these to disk if memory became tight or is
    my understanding that binding an object serializes it incorrect?
    If it turns out that what I am attempting here consumes a lot of heap
    space, I assume that server performance will suffer which is
    unacceptable. Would using read-only entity beans be a better solution?
    The container could manage this memory more effectively but it would
    seem to add a lot of overhead for a simple read only data cache.
    Thanks,
    Steve Snodgrass

  • How to create a SOAP body based on a Serializable Object?

    Hello,
    I have a serializable object such as this one
            HeaderSection header = new HeaderSection();
            RequestName requestName = new RequestName();
            requestName.setActivityName("this is an activity");
            NNSVMessage nnsvMessage = new NNSVMessage();
            nnsvMessage.setHeaderSection(header);
            nnsvMessage.setRequestSection(request);
            nnsvMessage.setResponseSection(response);I create a SOAP message using SAAJ API
            SOAPMessage message = messageFactory.createMessage();
            SOAPPart soapPart = message.getSOAPPart();
            SOAPEnvelope envelope = soapPart.getEnvelope();
            SOAPBody body = envelope.getBody();
    ...How can I stuff this object into the SOAP body?
    Thanks,
    Mustafa

    Hi Saleem,
    Herewith an example:
            Dim oDoc As SAPbobsCOM.Documents
            oDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
            oDoc.CardCode = "530010"
            oDoc.DocDate = Date.Now
            oDoc.DocDueDate = Date.Now
            oDoc.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Service
            oDoc.Lines.ItemDescription = "Line 1"
            oDoc.Lines.Price = 100
            oDoc.Lines.VatGroup = "O1"
            oDoc.Lines.AccountCode = "0000090000"
            oDoc.Lines.Add()
            oDoc.Lines.ItemDescription = "Line 2"
            oDoc.Lines.Price = 200
            oDoc.Lines.VatGroup = "O1"
            oDoc.Lines.AccountCode = "0000090201"
            If oDoc.Add <> 0 Then
                MessageBox.Show(oCompany.GetLastErrorDescription)
            Else
                MessageBox.Show("Added")
            End If
    Hope it helps,
    Adele

  • Custom Deserialization for a List of serializable objects

    I'm running into trouble creating custom deserialization using the readObject method.
    Here is the code the reads the blob from the database:
    Blob blob = rs.getBlob(idx++);
                InputStream iStream = blob.getBinaryStream();
                try {
                    ObjectInputStream oiStream = new ObjectInputStream(iStream);
                    Object object = oiStream.readObject();
                    List data = (List) object;
                    report.setData(data);
                catch (EOFException ignored) {}
                finally {
                    iStream.close();               
                }And my class:
    public class PerformanceReportRowInfo extends PerformanceInfo
        private static final long serialVersionUID = 20060406L;
        private String _dateStr;
        private long _queries;
        private void readObject (ObjectInputStream ois) throws IOException,
                ClassNotFoundException
            ObjectInputStream.GetField fields = ois.readFields();
            _dateStr = (String) fields.get("_dateStr", null);
            try {
                _queries = fields.get("_queries", 0L);
            } catch (IOException io) {
                int intQueries = fields.get("_queries", 0);
                _queries = (long) intQueries;
    }The reason custom deserialization is needed is because we are converting the "_queries" attribute from an int to a long, and do not want to have to replace all the blobs in our DB with long types.
    For some reason, however, the readObject method never gets called in the PerformanceReportRowInfo, and instead i continue to get the error message:
    java.io.InvalidClassException: PerformanceReportRowInfo; incompatible types for field _queries
    I even added logging to the readObject method to make sure it wasnt getting called, and my suspicion was confirmed, it was indeed not getting called. Is my problem related to the fact that it is extending another serializable object (in this case PerformanceInfo) that doesnt have a custom readObject method? Or is it because of how im converting the blob to a List in the first block of code? BTW, the exception occurs at this line:
    Object object = oiStream.readObject();
    Thanks for the help!

    It is Serializable and does not extend any other class (except Object of course), here is the full stack trace:
    Caused by: java.io.InvalidClassException: PerformanceReportRowInfo; incompatible types for field _queries
         at java.io.ObjectStreamClass.matchFields(ObjectStreamClass.java:2175)
         at java.io.ObjectStreamClass.getReflector(ObjectStreamClass.java:2070)
         at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:586)
         at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1552)
         at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
         at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1552)
         at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
         at java.util.ArrayList.readObject(ArrayList.java:591)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:946)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1809)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
         at MyClass.readReport(MyClass.java:332)

  • Created serializable object, but get "Class not found" on "createObjectMessage()" cal

    I'm using OC4J 9.0.2.1 and JDeveloper 9.0.2 with Oracle db. I have a set of queues created in the database.
    Before I try to send my request, I create an instance of the serializable object I want to send. I do all of my queue connection setup, then I call:
    queueSession.createObjectMessage(request);
    Where "queueSession" is a QueueSession obtained from "queueConnection.createQueueSession()".
    When I step over this function call, I get the following:
    oracle.jms.AQjmsException: JMS-109: Class not found: com.attws.it.bsa.felix.mci.common.ServiceInfoRequest
    (The indicated class name is the type of the "request" object.)
    What could I be doing wrong?

    The code below creates the following classes when I compile it (using jsk1.3):
    DistanceBarApplication2.class
    DistanceBarApplication2$1
    DistanceBarApplication2$2
    DistanceBarApplication2$3
    DistanceBarApplication2$DistanceBar2
    The error I receive is: load: class DistanceBarApplication2 not found
    Here is my HTML code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    </HEAD>
    <BODY>
    <applet code="DistanceBarApplication2.class" width=300 height=50>
    </applet>
    </BODY>
    </HTML>
    Here is the Java code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DistanceBarApplication2 extends JApplet {
    private final DistanceBar2 bar = new DistanceBar2();
    public void init() {
    bar.setMaximum(100);
    bar.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    bar.stop();
    JOptionPane.showMessageDialog(bar, bar.getValue() + " yards");
    bar.start();
    this.getContentPane().add(bar);
    bar.start();
    static class DistanceBar2 extends JProgressBar {
    private Thread mThread;
    private boolean mRunning= false;
    private int mValue = 0;
    private boolean mUp = true;
    private Runnable updater = new Runnable() {
    public void run() {
    setValue(mValue);
    public void start() {
    if (mRunning) {
    return;
    mRunning = true;
    mThread = new Thread(new Runnable() {
    public void run() {
    while (mRunning) {
    try {
    Thread.sleep(30);
    } catch (InterruptedException e) { }
    adjust();
    mThread.setDaemon(true);
    mThread.start();
    public void stop() {
    mRunning= false;
    // Best to let a thread run itself out
    // if (mThread != null)
    // mThread.interrupt();
    // Don't need this for this applet, but possibly later
    // public Dimension getPreferredSize() {
    // return new Dimension(300,70);
    private void adjust() {
    int delta = getMaximum() / 40;
    mValue += delta * (mUp ? 1 : -1);
    if (mValue >= getMaximum()) {
    mValue = getMaximum();
    mUp = false;
    } else if (mValue <= 0) {
    mValue = 0;
    mUp = true;
    SwingUtilities.invokeLater(updater);

  • Attributes in a Serializable object in a file

    Hello,
    I have an application that stores a Serializable object into a file, but when I edit the file I can see the attributes from the stored object. And I thought that when you do that the stored data where bytes, instead of strings.
    Can somebody explain me how can I store an object into a file that cannot be shown the content?
    Here is my code:
    String fichero_datos = "D:\\workspace2\\Cliente\\Datos.dat"; //That is the file
    Cliente elCliente = new Cliente ("Fulanito"); //That is the object that stores a String
    FileOutputStream fo = new FileOutputStream(fichero_datos);
    ObjectOutputStream salida = new ObjectOutputStream(fo);
    salida.writeObject(elCliente);
    salida.flush();
    salida.close();
    fo.close();And the result file:
    �..sr..ClienteJB``}\..L. nombreq..Ljava/lang/String;L ..Fulanito
    I do not want the string �Fulanito� to be accesible by editing the file.
    Thanks a lot for your attention,
    - Susana

    And I thought that when you do that the stored data where bytes, instead of strings. When encoded as UTF-8, String are made up of bytes. You cannot assume that because bytes are used, that the file should be completely unreadable.
    You will have trouble editing the file in a text editor as the binary values will get changed and the the stream will appear to be corrupted.
    The only way to ensure the data is unmodifyable is to encrypt the data.
    If you want the data to be mearly unreadable, add a DeflatorOutputStream between the ObjectOutputStream and the FileOutputStream. This will compress the data and make it unreadbale unless you use an InflatorInputStream.

  • Sending Non-Serializable Objects

    I'm trying to make my server program send a non-serializable object to the client program. But I'm getting a 'java.io.NotSerializableException'. Is there any way to send a non-serializable object through an ObjectOutputStream, or through some other type of stream object?
    Thanks.
    ~jon

    I have some experience before, here is one solutions:Well, nice to know, but its not a solution to the problem discussed in this topic though.
    >
    >
    using toByteArray to get a byte[] and a length of the
    array
    then using the following format to send through
    sockets,
    [bytearray.length][byte array content]
    It really works in a project of a MMS system I have
    worked on.

  • Serialializing non serializable objects

    Hi guys,
    I have to serialize (and then send through socket) a class which implements java.io.Serializable. This class also has some reference with other classes, which should be serialized togheter.
    But when I run the main class (which only serializes) , java.io.NotSerializableException is thrown.
    How do I recognize if a class is effectively serializable?
    How do I serialize too even with non-serializable objects?
    (I need all these objects)
    note : In the class I have only put the marker "implements java.io.Serializable",should I have to do somenthing else?
    Thank You for your great help!

    Hi guys,
    I have to serialize (and then send through socket)a
    class which implements java.io.Serializable. This
    class also has some reference with other classes,
    which should be serialized togheter.
    But when I run the main class (which onlyserializes)
    , java.io.NotSerializableException is thrown.
    How do I recognize if a class is effectively
    serializable?
    How do I serialize too even with non-serializable
    objects?
    (I need all these objects)
    note : In the class I have only put the marker
    "implements java.io.Serializable",should I have todo
    somenthing else?
    Thank You for your great help!I wish there was a utility that could inspect a
    Class, traverse its containment tree and flag
    serializability issues. This could be more powerful
    if generics are used.
    To solve your problem besides the marker, implement
    methods writeObject and readObject and serializing
    the contained object that is not serializable by
    hand. For example if your class is X which contains Y
    that is not serializable then you need to serialize
    fields Y in X.writeObject and construct a Y object in
    X.readObject:
    class Y { // not serializable and you cannot modify
    it
    int i;
    int j;
    Y(int i, int j)
    class X implements Serializable {
    String xyz;
    Y y;
    private void writeObject(ObjectOutputStream out)
    throws IOException{
    out.writeObject(xyz);
    out.writeInt(y.getI());
    out.writeInt(y.getJ());
    private void readObject(ObjectInputStream in)
    throws IOException{
    xyz = (String) in.readObject();
    int i = in.readInt();
    int j = in.readInt();
    y = new Y(i, j);Remember to maintain the same order in readObject and
    writeObject.
    Hi guys,
    I have to serialize (and then send through socket)a
    class which implements java.io.Serializable. This
    class also has some reference with other classes,
    which should be serialized togheter.
    But when I run the main class (which onlyserializes)
    , java.io.NotSerializableException is thrown.
    How do I recognize if a class is effectively
    serializable?
    How do I serialize too even with non-serializable
    objects?
    (I need all these objects)
    note : In the class I have only put the marker
    "implements java.io.Serializable",should I have todo
    somenthing else?
    Thank You for your great help!I wish there was a utility that could inspect a
    Class, traverse its containment tree and flag
    serializability issues. This could be more powerful
    if generics are used.
    To solve your problem besides the marker, implement
    methods writeObject and readObject and serializing
    the contained object that is not serializable by
    hand. For example if your class is X which contains Y
    that is not serializable then you need to serialize
    fields Y in X.writeObject and construct a Y object in
    X.readObject:
    class Y { // not serializable and you cannot modify
    it
    int i;
    int j;
    Y(int i, int j)
    class X implements Serializable {
    String xyz;
    Y y;
    private void writeObject(ObjectOutputStream out)
    throws IOException{
    out.writeObject(xyz);
    out.writeInt(y.getI());
    out.writeInt(y.getJ());
    private void readObject(ObjectInputStream in)
    throws IOException{
    xyz = (String) in.readObject();
    int i = in.readInt();
    int j = in.readInt();
    y = new Y(i, j);Remember to maintain the same order in readObject and
    writeObject.

  • Returning Non Serializable Objects

    Is it possible in anyway to return non serializable objects from the remote method of an EJB, for instance return a result set. Everytime i try, i get a CORBA marshalling exception, i tried to put the resultset in a serilized object such as an enumeration or vector but got the same error when retreiving it from the enumeration or vector. Help is needed and appreciated. Thanx.

    Is it possible in anyway to return non serializable objects from the remote method of an EJB, for instance return a result set. Everytime i try, i get a CORBA marshalling exception, i tried to put the resultset in a serilized object such as an enumeration or vector but got the same error when retreiving it from the enumeration or vector. Help is needed and appreciated. Thanx.

  • Inserting non-serializable objects

    Is there any way to insert non-serializable objects into a database? (Or to convert them to bytes?)

    Is there any way to insert non-serializable objectsinto a database?
    A joke right?No, it's not a joke. It would be a pretty bad one if it were.
    Yes, there is a way. Create a table that corresponds
    to the object where each attribute in the object
    corresponds to field in the object. Add a unique key
    if one doesn't exist.I wish it were that simple. I don't have access to those attributes...
    >
    To create an object insert a row into the table. To
    load the object use the unique key to query for the
    row. To 'delete' the object delete the row from the
    table.BTW, the object in question is the java.awt.geom.Area object (http://java.sun.com/j2se/1.3/docs/api/java/awt/geom/Area.html ).
    The only way I can think of to insert an object that doesn't map to a SQL type is to convert it to bytes through serialization, and insert it as RAW data.
    I've extended Area to add a name and made my class serializable. However, since Area is not serializable, the only data I can retrieve after deserializing is the name I added (from my understanding of serialization, I have to save Area's data myself, but can't since I don't have access to it, so the deserialization process calls the Area() constructor which initializes the object to empty).

  • Non Serializable Objects

    I am working on a java project and I have to serialize a class (created by me) which has many references to other classes that should be serialized too.
    I add the marker "implements serializable" to all the necessary classes, but when I run I get a non serializable exception.
    Maybe one ore more objects are non serializable, but how do I identify them?
    I've read that If I have to serialize non serializable objects, I need to write my own writeObject(ObjectOutputStream out)throws IOException and readObject(ObjectInputStream in) , but I don't know how to implement and us them.
    note : I can't use transient beacuse I need everything to be serialized!
    Thanks a lot. Bye!

    Now I'll post my code, If anyone knows how to serialize (and then deseserialize) the class "AgentMessage" , and its subclasses "StaticPart" and "DynElement" from the main class , I'll be grateful.. It's about 2 days I'm working on it and I continue getting "nonserialializable exception" ...
    thank you guys
    package agentsLibrary;
    //some imports
    public class AgentMessage implements Serializable{
         private static final long serialVersionUID = 1L;
         private StaticPart sp;
         private DynElement de;
         public AgentMessage(String agent,byte[] code,String mainclass,Certificate signerId,PrivateKey priv,String configuration,Serializable dclear,byte[] dsecret,PathEl[] dpath,byte[] c){ //costruttore
              sp=new StaticPart(agent,code,mainclass,signerId,priv,configuration);
              de=new DynElement(dclear,dsecret,c,dpath);
         public StaticPart getSp(){
              return sp;
         public DynElement getDe(){
              return de;
         private void writeObject(java.io.ObjectOutputStream out) throws IOException{
              System.out.println("class implements writeObject( )");
              //depends on the method to store out all the important state
              //out.defaultWriteObject();//perform the default serialization(va sempre fatto il default)
              out.writeObject(sp);
              out.writeObject(de);
         private void readObject(java.io.ObjectInputStream in)throws ClassNotFoundException, IOException {
              System.out.println("class implements readObject( )");
              //in.defaultReadObject();
              sp=(StaticPart)in.readObject();
              de=(DynElement)in.readObject();
    package agentsLibrary;
    public class StaticPart implements Serializable{
         private static final long serialVersionUID = 1L;
         private String agent="";
         private byte[] code=null;
         private String mainclass="";
         private Certificate signerid=null;
         private PrivateKey priv=null;
         private Calendar timestamp=null;
         private Signature sig=null;
         private byte[] buffertotale=null;
         private byte[] firma=null;
         private String configuration="";
         public StaticPart(String agent, byte[] code, String mainclass, Certificate signerid, PrivateKey priv,String configuration){
              this.configuration=configuration;
              this.code=code;
              this.mainclass=mainclass;
              this.agent=agent;
              this.priv=priv;
              this.signerid=signerid;
              timestamp=Calendar.getInstance();
              Date time=new Date();
              time=timestamp.getTime();//Gets this Calendar's current time.
              try {
                   byte[] nomeagent=agent.getBytes("8859_1");//converto stringa
                   byte[] mainclas=mainclass.getBytes("8859_1");//converto stringa
                   byte[] signer=signerid.getEncoded();
                   byte[] priva=priv.getEncoded();
                   byte[] dat=null;
                   dat=time.toString().getBytes("8859_1");
                   buffertotale=new byte[nomeagent.length+mainclas.length+signer.length+priva.length+dat.length+code.length];
                   System.arraycopy(nomeagent, 0, buffertotale, 0, nomeagent.length);
                   System.arraycopy(code, 0, buffertotale, nomeagent.length, code.length);
                   System.arraycopy(mainclas, 0, buffertotale, code.length, mainclas.length);
                   System.arraycopy(signer, 0, buffertotale, mainclas.length, signer.length);
                   System.arraycopy(priva, 0, buffertotale, signer.length, priva.length);
                   System.arraycopy(dat, 0, buffertotale, priva.length, dat.length);
              } catch (UnsupportedEncodingException e) {
                   e.printStackTrace();
                   System.exit(1);
              } catch (CertificateEncodingException e) {
                   e.printStackTrace();
                   System.exit(1);
              try {
                   sig = Signature.getInstance(priv.getAlgorithm());
                   sig.initSign(priv);
                   sig.update(buffertotale, 0, buffertotale.length);
                   firma=sig.sign();
              } catch (SignatureException e) {
                   e.printStackTrace();
                   System.exit(1);
              } catch (InvalidKeyException e) {
                   e.printStackTrace();
                   System.exit(1);
              } catch (NoSuchAlgorithmException e) {
                   e.printStackTrace();
                   System.exit(1);
         public boolean verify() {
              try{
                   PublicKey pub=signerid.getPublicKey();
                   Signature sig = Signature.getInstance(pub.getAlgorithm());
                   sig.initVerify(pub);
                   sig.update(buffertotale, 0, buffertotale.length);
                   return sig.verify(firma);
              } catch (SignatureException e) {
                   e.printStackTrace();
                   System.exit(1);
              } catch (InvalidKeyException e) {
                   e.printStackTrace();
                   System.exit(1);
              } catch (NoSuchAlgorithmException e) {
                   e.printStackTrace();
                   System.exit(1);
              return false;
         public String getAgentName() {
              return agent;
         public byte[] getCode() {
              return code;
         public String getClassName() {
              return mainclass;
         public PrivateKey getPrivate() {
              return priv;
         public Certificate getId() {
              return signerid;
         public byte[] getSignature(){
              return firma;
         public String getConfiguration(){
              return configuration;
    package agentsLibrary;
    import java.io.Serializable;
    public class DynElement implements java.io.Serializable{
         private static final long serialVersionUID = 1L;
         private Serializable dclear=null;
         private byte[] dsecret=null;
         private PathEl[] dpath=null;
         private byte[]c=null;
         public DynElement(Serializable dclear,byte[] dsecret,byte[]c,PathEl[] dpath){
              this.dclear=dclear;
              this.dsecret=dsecret;
              this.c=c;
              this.dpath=dpath;
         public byte[] getC() {
              return c;
         public Serializable getDclear() {
              return dclear;
         public PathEl[] getDpath() {
              return dpath;
         public byte[] getDsecret() {
              return dsecret;
    //finally the following is the main class that should serialize
    AgentMessage msg=new AgentMessage(name,code,mainclass,signerId,privata,configuration,dclear,dsecret,dpath,c);
              try {
                   System.out.println("Sending Agent Message to Server "+ip+":"+port);
                   Socket s = new Socket(ip,port);
                   ObjectOutputStream out=new ObjectOutputStream(s.getOutputStream());
                   out.writeObject(msg);
                   out.flush();
                   s.close();
              } catch (Exception e) {
                   return false;
              return true;
         }

  • Non-Serializable objects in webservice

    Hi everyone,
    I'm writing a webservice that connects and performs update on a third-party
    data repository (document management system) through the vendor provided
    framework.
    Some of the objects used in the framework are not serialized, and WebLogic
    Workshop 7.0 won't compile my services because they contain non-serializable
    objects. Those objects are not used as messages or method parameters, rather
    are the member variables of the services.
    My question is how would I go about using non-serialized objects in a
    webservice class with WebLogic Workshop 7.0? I've seen some Apache AXIS
    webservice examples that does the similar thing, but some of the services
    works with non-serializable objects. Do I need to create an EJBcontrol that
    masks non-serializable objects to be used with the webservice?
    Any input is greatly appreciated. I'm still new at webservice programming.
    Thank you,
    Makoto

    Hi everyone,
    I'm writing a webservice that connects and performs update on a third-party
    data repository (document management system) through the vendor provided
    framework.
    Some of the objects used in the framework are not serialized, and WebLogic
    Workshop 7.0 won't compile my services because they contain non-serializable
    objects. Those objects are not used as messages or method parameters, rather
    are the member variables of the services.
    My question is how would I go about using non-serialized objects in a
    webservice class with WebLogic Workshop 7.0? I've seen some Apache AXIS
    webservice examples that does the similar thing, but some of the services
    works with non-serializable objects. Do I need to create an EJBcontrol that
    masks non-serializable objects to be used with the webservice?
    Any input is greatly appreciated. I'm still new at webservice programming.
    Thank you,
    Makoto

  • Failed to replicate non-serializable object  Weblogic 10 3 Cluster environ

    Hi,
    We have problem in cluster environment, its showing all the objects in Session needs to be serialized, is there any tool to find what objects in session needs to be serialized or any way to find. There was no issue in WLS 8 when the application again setup in WLS 10, we are facing the session replication problem.
    The setup is there are two managed server instance in cluster, they are set to mulicast(and also tried with unicast).
    stacktrace:
    ####<Jun 30, 2010 7:11:16 PM EDT> <Error> <Cluster> <userbser01> <rs002> <[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1277939476284> <BEA-000126> <All session objects should be serializable to replicate. Check the objects in your session. Failed to replicate non-serializable object.>
    ####<Jun 30, 2010 7:11:19 PM EDT> <Error> <Cluster> <userbser01> <rs002> <[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1277939479750> <BEA-000126> <All session objects should be serializable to replicate. Check the objects in your session. Failed to replicate non-serializable object.>
    Thanks,

    Hi
    Irrespective of WLS 8.x or WLS 9.x, 10.x, in general any objects that needs to be synced/replicated across the servers in cluster should be Serializable (or implement serializable). The object should be able to marshall and unmarshall. Simple reason why it did not showed in WLS 8.x is may be in that version they could not show these details like Error. May be they showed as Info or Warn or Just Ignored it. Weblogic Server became more and more stable and more efficient down the lines like from its oldest version 4.x, 5.x, 6.x, 7.x to latest 10.x. So my guess is they added more logic and more functionality to capture all possible errors and scenarios. I did worked on WLS 8.1 SP4 to SP6 long time back. Could not remember if I saw or did not see these errors for cluster domain with non-serializabe objects. I vaguley remember seeing it for Portal Domains but not sure. I do not have 8.x installed, otherwise I would have given a quick shot and confirm it.
    So even though it did not showed up in WLS 8.x, still underneath rule is any object that needs to be replicated that is getting replicated in cluster needs to implement Serializable interface.
    Thanks
    Ravi Jegga

  • Concept and situation to use Serializable Object?

    Hi Guys ,
    i Have read through the java ApI Specs about Serializable Object..
    I would like to know in what circumstances we need to serialize / implementing the Serializable class.
    Can anyone give me real world analogy?
    Then what will happen if we dont serializable our class/object?
    Thanks in advance,
    Regards,
    Willy

    you might think about serialization as an easy way to send an object over a stream...
    examples could be: save an object on a disk, over the network, over diferent vms, etc...

Maybe you are looking for