Serializable interface

I have a dount about with Serializable
Serializable interface does not have any methods or varialbles, then how can a class be serialized just by implementing Serializable interface. What is happening internally in Java to make this. Pls clear my doubt.
Thanks
Srinivas

Can U pls brief about reflectionSun has a tutorial on reflection that might interest you:
http://java.sun.com/docs/books/tutorial/reflect/index.html

Similar Messages

  • What is the use of Serializable Interface in java?

    Hello friends,
    I have one dout and i want to share with u guys:
    Why Serializable interface made and actully
    what's the use of it?
    At which place it become useful ?
    It is not contain any method then why it is made?
    If anyone have any idea about this then please reply.
    Thanks in advace
    Regards,
    Jitendra Parekh

    t is not contain any method then why it is made?To point out to the user of a class (and the programs) that the design of this class is conforming to certain restraints needed for Serialization.

  • Failed to serialize interface javax.xml.soap.SOAPElementweblogic.xml.schema

    I have generated my Web Service Client Control Class based on WSDL file provided by Web Service Provider using JAX-RPC in "Oracle Workshop for WebLogic version 10.3".
    I am using Web Service Client Control class in WebLogic Portal portlet backing class to invoke Web Service. But while invoking Web Service, I am getting following error:
    Caused by: java.rmi.RemoteException: Failed to invoke; nested exception is:
    javax.xml.soap.SOAPException: failed to serialize interface javax.xml.soap.SOAPElementweblogic.xml.schema.binding.SerializationException: mapping lookup failure. class=interface javax.xml.soap.SOAPElement class context=TypedClassContext{schemaType=['http://xyz.com/abc/UpdateSR']:updateSRRequest}
    Here is the code of my Portlet Backing class where I am using Service Control to invoke Web Service:
    URL webServiceUrl = new URL(webServiceLocation);
    ServiceFactory serviceFactory = ServiceFactory.newInstance();
    QName qName = new QName(nameSpaceURI, serviceName);
    Service siebelService = serviceFactory.createService(webServiceUrl, qName);
    updateSRServiceControl siebelServiceProxy = (updateSRServiceControl)siebelService.getPort(qName, updateSRServiceControl.class);
    UpdateSRResponse updateSRResponse = siebelServiceProxy.updateSR(updateSRRequest);
    Please let me know if more information required.
    I appreciate for help.
    Thanks in advance.
    Regards
    Neeraj

    I have generated my Web Service Client Control Class based on WSDL file provided by Web Service Provider using JAX-RPC in "Oracle Workshop for WebLogic version 10.3".
    I am using Web Service Client Control class in WebLogic Portal portlet backing class to invoke Web Service. But while invoking Web Service, I am getting following error:
    Caused by: java.rmi.RemoteException: Failed to invoke; nested exception is:
    javax.xml.soap.SOAPException: failed to serialize interface javax.xml.soap.SOAPElementweblogic.xml.schema.binding.SerializationException: mapping lookup failure. class=interface javax.xml.soap.SOAPElement class context=TypedClassContext{schemaType=['http://xyz.com/abc/UpdateSR']:updateSRRequest}
    Here is the code of my Portlet Backing class where I am using Service Control to invoke Web Service:
    URL webServiceUrl = new URL(webServiceLocation);
    ServiceFactory serviceFactory = ServiceFactory.newInstance();
    QName qName = new QName(nameSpaceURI, serviceName);
    Service siebelService = serviceFactory.createService(webServiceUrl, qName);
    updateSRServiceControl siebelServiceProxy = (updateSRServiceControl)siebelService.getPort(qName, updateSRServiceControl.class);
    UpdateSRResponse updateSRResponse = siebelServiceProxy.updateSR(updateSRRequest);
    Please let me know if more information required.
    I appreciate for help.
    Thanks in advance.
    Regards
    Neeraj

  • Using Serializable interface

    Hi, I have to write a program that implements the Serializable interface along with a LinkedList. It looks like this:
    public class Library implements Serializable{
       private LinkedList<LibraryBranch> collection;
    }However, all of my methods after that give a warning/error "class, interface, or enum expected." Do I have to write my own methods for Serializable that allows me to read and write data? I don't completely understand the Serializable interface description in the API.
    Thanks for your help.
    - Jeremy

    I don't know, the assignment asks for it. I think I have to be able to write the objects into a file and read them back again later.

  • Why do we need Serializable Interface since there is no method decl. inside

    On working with Serialization in java
    I could see that the Serializable Interface is empty without any method inside.
    Also, the writeObject() and readObject() accepts only if the Serializable interface is implemented to a class.
    What is the use of implementing an empty Interface?
    Please clarify.
    Thanks in advance.
    Regards,
    R.Mahendra Babu

    The completely empty Serializable is only a marker interface -- it simply allows the serialization mechanism to verify that the class is able to be persisted.

  • Working of serializable interface, when it doesn't have any methods

    Hi,
    I am curious about how the serializable interface is used in JVM.
    This is an empty interface. ie. it does not have any method signatures or any variables inside.
    How does java use this interface, for serializing purposes.
    Also, why should it be an interface, when its all empty.

    Such marker interfaces are just used to tell something about about a class, in this cases that the developer wants that instances of a class can be serialized. The code that handles the serialization just check s"instanceof Serializable". Of course Serializbale could look like this
    public interface Serializable
    public boolean isSerializable();
    But why make things more complicated than necessary?

  • Example class that implements Serializable interface

    Dear,
    I have a class myData that I want to implement Serializable interface. class myData has only two fields: Integer iData1, String sData2.
    Could anybody shown me how my myData class should be?
    Thanks a lot!

    Hey, if you have yet to obtain a remote reference from the app server ...then we are into pandora's box. I lost three whole heads of hair getting up on JBoss when I first started. You want to check out the JBoss forums on the JBoss website, and the enterprise javabeans forum here. Search some posts and read the free JBoss manual.
    Unfortunately, there isn't a 'here, do this' solution to getting connected with JBoss. There are quite a few gotcha's. There are descriptors, descriptor syntax ...and this changes between releases so there seems to be alot of people saying 'here, do this' ...but you try and it doesn't work (wrong release). Here are some descriptors that I threw up recently for someone ...a place to start.
    http://forum.java.sun.com/thread.jsp?forum=13&thread=414432
    This drove me nuts until it all worked right. I was stuck for three weeks at one point ...ready to give up, but then I got it. Perservere ...its a nice container for learning in (its free!).
    I will try and watch for you.
    Oh, and put something in your head ...at least then you will keep your hair !
    :)

  • Can any one explaing about serializable interface.

    1)why we need serializable interface,when there is no methods in that interface.

    http://java.sun.com/javase/technologies/core/basic/serializationFAQ.jsp#whyserial
    http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html
    http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/serial-arch.html#4539

  • Functionality to generate UUID (for Serializable interface)

    When working with custom components, the java.io.Serializable interface often is a must. Eclipse always complains about the missing UUID-attribute. There are a few plugins around to generate them, but an integrated solution in NitroX would be really cool.

    Eclipse 3.1 will offer you the option to generate serials for you if you open the Quick Fix menu for the warning.PERFECT. :D :D Thanks for the hint. So we only have to wait for NitroX fro 3.1 :twisted:
    Apart from that I would claim it's hardly a feature in the scope of NitroX.Well. Yes an no.
    As lots of the objects that one uses in the context of the session, or as objects that should be sent over the wire (state=client) in JSF, it is in the scope of every plugin or IDE that wants to help the developer develop JSF-application, therefor it is in the scope...
    But with Eclipse providing it already (soon...) it is no discussion any more.
    regards
    Alexander

  • Why does serializable interface has no methods inside it

    Aloha
    Can anyone please help me with this....Serializable interface has no methods inside it.So how is it useful to the user.Also if I am writing a class which implements Serializable how does JVM know what to do.?

    JoachimSauer wrote:
    dannyyates wrote:
    [The JVM] doesn't know about serialisation [...]Sorry for the nitpick, but that's not completely true. The JVM needs to know about serialisation at least at little bitNo.
    since Serialization creates new objects without the code from the constructrs ever being run. ObjectInputStream loads the classes just like any other code would, although it's obviously reading the serialized stream to get that information... and then calls newInstance() on ObjectStreamClass.
    And ObjectStreamClass uses reflection to get a constructor (via java.lang.Class getDeclaredConstructor ) and then uses said java.lang.reflect.Constructor to create a new instance via newInstance()
    There is no JVM magic. It is all Java code. (With the exception of what java.lang.reflect.Constructor does because at the point it dives into sun packages but you could do the same by calling java.lang.reflect.Constructor)

  • Serializable interface problems

    I am playing around with the Serializable interface and created a class:
    import java.io.Serializable;
    public class SerialMessage implements Serializable {
         public byte[] from = new byte[4];
         public byte[] to = new byte[4];
         public byte[] message = new byte[50];
    Next I created somethign that would use this class
    import java.io.*;
    public class SOMessageUser {
         public static void main (String[] args) {
              SerialMessage one = new SerialMessage();
              SerialMessage two = new SerialMessage();
              byte[] serializedMessage;
              try {
                   ByteArrayOutputStream baos = new ByteArrayOutputStream();
                   ObjectOutputStream oos = new ObjectOutputStream(baos);
                   System.out.print("From: ");
                   System.in.read(one.from);
                   System.out.print("\n");
                   System.out.print("To: ");
                   System.in.read(one.to);
                   System.out.print("\n");     
                   System.out.print("Message: ");
                   System.in.read(one.message);
                   System.out.print("\n");
                   oos.writeObject(one);
                   serializedMessage = baos.toByteArray();
                   ByteArrayInputStream bais = new ByteArrayInputStream(serializedMessage);          
                   ObjectInputStream ois = new ObjectInputStream(bais);          
                   two = (SerialMessage)ois.readObject();
                   System.out.print ("From: " + two.from.toString());
                   System.out.print ("To: " + two.to.toString());
                   System.out.print (two.message.toString());
              } catch (Exception e) {
                   e.printStackTrace();
    Very simple as you can see somewhere I have a logical error classes compile and run but here is the output.
    From: as
    To: sa
    Message: qwertyuiopasdfghjklzxcvbn
    From: [B@422edeTo: [B@112f614[B@1d9dc39[root@linux-lev root]#
    why is it that I am gettig these numbers which I am guessing are addresses instead of my byte[]'s?

    Hi,
    >
                   System.out.print ("From: " + two.from.toString());
                   System.out.print ("To: " + two.to.toString());
                   System.out.print (two.message.toString());
              Replace your above lines with the following ones:
                   System.out.print ("From: " + new String(two.from));
                   System.out.print ("To: " + new String(two.to));
                   System.out.print (new String(two.message));

  • Restart persistance and Serializable interface

    When restarting Tomcat 5.5, I see the following things appearing in my log files:
    WARNING: Cannot serialize session attribute parameters for session 701E5E884E3423FE160B65BF6C44DEEB
    java.io.NotSerializableException: toets.toetselementen.VraagTypeSo i guess this means that the session of certain users of my website get broken. I would like to keep my users satisfied by not breaking their sessions with Tomcat restarts.
    On the Tomcat website, i found the following information:
    [http://tomcat.apache.org/tomcat-5.5-doc/config/manager.html|http://tomcat.apache.org/tomcat-5.5-doc/config/manager.html]
    The bottom of that page mentions that the session attributes must implement the Serializable interface. So I assume VraagType is somewhere used as a session attribute, and it indeed does not implement the Serializable interface:
    package toets.toetselementen;
    public class VraagType {
        private int id;
        private String type;
        public VraagType(int id, String type) {
            this.id = id;
            this.type = type;
        public int id() {
            return id;
        public String type() {
            return type;
    }So I assume the VraagType class must implement the Serializable interface to be able to have (Tomcat 5.5) restart persistance. My question is however: is it enough to simply add 'implements Serializable' to my class definition, or will I also have to implement certain methods?

    Yep, it is basically just a marker interface to let Java know that this class is allowed to be serialized. You don't want to do this with sensitive information such as an User object with a password as unencrypted string property --in such case, you could also declare it transient and live with the fact that it doesn't come back after deserialization.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Implementing the Serializable interface

    Hi guys,
    I have a conceptual question about implementing the Serializable interface - since it's only a marker interface (i.e. - it doesn't have any abstract methods) why does Java demand an object to implement this interface in order to be written into a file? What I'm asking is why wouldn't they make the writeObject method's signature
    public void writeObject(*Object* o)
    so any object can get in? What is the point of forcing a class to implement an interface in order to enable it to be written to a file?

    So that serialization requires the explicit consent of the class or superclass/superinterface.

  • A Bean must implement the java.io.Serializable interface? What makes the di

    Hi, I have took an example from sun notes on JavaBeans (you can find the example here http://java.sun.com/developer/onlineTraining/Beans/beans02/page2.html). The code is like this.....
    import java.awt.*;
    import java.io.Serializable;
    public class SimpleBean extends Canvas
                     implements Serializable {
      private Color color = Color.green;
      //getter method
      public Color getColor() {
         return color;
      //setter method
      public void setColor(Color newColor) {
         color = newColor;
         repaint();
      //override paint method
      public void paint (Graphics g) {
         g.setColor(color);
         g.fillRect(20,5,20,30);
      //Constructor: sets inherited properties
      public SimpleBean() {
         setSize(60,40);
         setBackground(Color.red);
    }I didn't find any difference in executing the program by implementing the Serializable interface and without implementing. On choosing serialize component in the File Menu, I serialized the component after changing its color (property), and saved as .ser file. And created the .Jar file including .ser file. when I load the jar file and place the bean in the beanbox, it is showing the bean that is updated. This can be done by implemeting Serializable interface and without implementing Serializable interface also. And I have a statement that has been given in the notes provided by SUN. That is ' Bean must implement the Serializable interface. Objects that support this interface can save and restore their state from disk '. I couldnot come up with the summation of this statement.
    Anyone who has an idea... please give an explanation.
    Thank you.

    Maybe you should show us your coding how you saved your beans state.
    Are you serious that you save the special object? Or do you save the values of the object into a file and load those values into a new object?

  • How serialization happens in java thru serializable interface??

    Hi,
    Can anybody plz tell me what are the advantages of having a blank interface??
    One example of blank interface is Serializable interface in java. Serializable being a blank interface allows you to perform persistence in java framework just by implementing it. Just curious to know how the blank interface (Serializable) does the serialization in java???
    Tx in Advance
    Jameel

    Serializable is a marker interface. It simply indicates that any object that has instanceOf Serializable returning true can be serialized. By implmenting this interface you declare that your class is serializable.

Maybe you are looking for

  • Word/Excel in the target machine?

    Do I need Word/Excel installed in the target machine if I develope a stand-alone application with the office toolkit report generation?

  • Parsing file more than 64k

    Hi All In ORACLE XML DB , I m getting problem to parse XML files (ORACLE 10g R2 stored Procedure). I have created Node to parse XMl files ,but as per as Node memory limitation (64KB) maximum. I am not able to parse XML files those have data more then

  • BUG: domains are stored in wrong file when saving a model

    For a project we use a project specific domain file. When I want to add a domain I first select the project domain file and then add the domain. I can see that this new domain is stored in this project specific domain xml file. However, when I save t

  • Compilations in new itunes

    A common problem, AGAIN. I want cover flow to show one album that represents a compilation, not by each artist on the compilation. I have checked the proper box in the preferences, BUT when I try to highlight all tracks > get info > part of compilati

  • Need output like below mentioned format

    Hi, By using below query , iam getting output in the below formate as metioned select m.year "Year", --decode(m.year,like '200%','a') "DG", --decode(instr(m.year,'200'),0,Null,'Shallow Water <1000 Feet') "DG", --decode(substr('Shallow Water <1000 Fee