Externalizable and serializable superclass

hi!
i've got al lot of objects that extend jcomponent and i don't want to serialize all the fields of those. so i implemented the externalizable interface, but the superclass is also serialized, why does this happen??? here's a test-class:
class TestExtOrig implements Serializable
   public String test = "Hi";
public class TestExt extends TestExtOrig implements Externalizable
   private static final long serialVersionUID = 2494746796557083423L;
   public static void main(String[] args) throws SecurityException, IOException
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      DebugObjectOutputStream dos = new DebugObjectOutputStream(bos);
      dos.writeObject(new TestExt());
      dos.close();
   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
   public void writeExternal(ObjectOutput out) throws IOException
}The DebugObjectOutputStream simply extends ObjectOutputStream and prints the called method on StdOut, so that i can see what's really written. Well, here it is:
writeUTF(org.wimberger.hptoolkit.client.TestExt)
writeLong(2494746796557083423)
defaultByte(12)
writeShort(0)
writeUTF(org.wimberger.hptoolkit.client.TestExtOrig)
writeLong(7683992437612625549)
defaultByte(2)
writeShort(1)
defaultByte(76)
writeUTF(test)The problem with that is that it writes the TestExtOrig class also. How can i avoid that???
thanks in advance,
Christoph Wimberger

Hi Christoph,
I think the debug you are seeing is when the ObjectOutputStream write the ClassDescriptor to the OutputStream, not the object. I believe this happens the first time an instance of a particular class is written to the ObjectOutputStream.
Regards,
Scott

Similar Messages

  • Drag and Drop questions and Serialization in the 1Z0-852 Upgrade exam?

    Hi,
    Does anyone know if the drag and drop items and serialization have been removed from the 1Z0-852 Java SE 6 Programmer Certified Professional UPGRADE exam?
    I know that they have been removed from the 1Z0-851, but not sure about the upgrade exam.
    Thanks in advance,
    Alvaro

    Alvaro wrote:
    Hi,
    Does anyone know if the drag and drop items and serialization have been removed from the 1Z0-852 Java SE 6 Programmer Certified Professional UPGRADE exam?
    I know that they have been removed from the 1Z0-851, but not sure about the upgrade exam.
    Thanks in advance,
    Alvaro(1) Drag and Drop
    .... this question format will have been removed:
    Ref: http://blogs.oracle.com/certification/entry/0596
    (2) Serialization:
    It is best to compare the topics from your notes to the current topics, however according to my reading of the current topics it is in scope at least to some extent:
    http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=41&p_exam_id=1Z0_852 (Section 3 API Contents):
    Develop code that serializes and/or de-serializes objects using the following APIs from java.io: DataInputStream, DataOutputStream, FileInputStream, FileOutputStream, ObjectInputStream, ObjectOutputStream and Serializable.

  • Marshall and Serialization

    Hello There:
    Can any one please educate me the difference between marshaling an object and serialize an object. They looked the same to me. they both flat the object to a readable format and maintain the state of the object. What's the difference, why both terms are used. Where do I find the definition of 'marshal'? Thank you very much!
    -RM

    Please search the web for general questions. But we'll let you slide this time. Here's what my search turned up:
    http://forum.java.sun.com/thread.jspa?threadID=616673&messageID=3436144
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=1&t=009261
    ...if you want more just google:
    http://www.google.com/search?q=marshalling+vs.+serialization

  • Entry processor performance and serialization

    Our application invokes an entry processor from a .Net extend client. We are seeing very poor performance the first few times the processor is invoked (typically 60ms vs 2ms). I was expecting this to be due to the overhead of the initial TCP connection but this doesn't appear to be the case. Here is a typical set of timings from the beginning of invoking the EP on the client:
    5ms: Object starts being deserialized on proxy
    7ms: Deserialization is finished, and serialization begins
    9ms: Serialization is complete.
    55ms: Deserialization begins on the storage node
    58ms: Deserialization complete on storage node
    58.5: Entry processor invocation complete
    60ms: Serialization of result is complete
    My questions are:
    - What is happening between the end of serialization of the object by the proxy and deserialization starting on the storage node?
    - Given that the cache is POF enabled, why is the proxy deserializing and reserializing the entry processor?
    Version is 3.7.1.6

    Hi Rob,
    Config is below. defer-key-association-check is not set. The timings were established by logging the POF serialization in each process so its definitely the proxy that is doing it.
    Regards,
    Dave
    Client config:
    <?xml version="1.0"?>
    <cache-config xmlns="http://schemas.tangosol.com/cache">
    <caching-scheme-mapping>
    <cache-mapping>
    <cache-name>Cache</cache-name>
    <scheme-name>remote-scheme</scheme-name>
    </cache-mapping>
    </caching-scheme-mapping>
    <caching-schemes>
    <remote-cache-scheme>
    <scheme-name>remote-scheme</scheme-name>
    <service-name>ExtendProxyService</service-name>
    <initiator-config>
    <tcp-initiator>
    <remote-addresses>
    <socket-address>
    <address>localhost</address>
    <port>1234</port>
    </socket-address>
    </remote-addresses>
    <connect-timeout>5s</connect-timeout>
    </tcp-initiator>
    <outgoing-message-handler>
    <request-timeout>1s</request-timeout>
    </outgoing-message-handler>
    <serializer>
    <class-name>Tangosol.IO.Pof.ConfigurablePofContext, Coherence</class-name>
    <init-params>
    <init-param>
    <param-type>string</param-type>
    <param-value>assembly://..../pof-config.xml</param-value>
    </init-param>
    </init-params>
    </serializer>
    </initiator-config>
    </remote-cache-scheme>
    </caching-schemes>
    </cache-config>
    Server cache config:
    <?xml version="1.0"?>
    <cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
    xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">
    <defaults>
    <serializer>pof</serializer>
    </defaults>
    <caching-scheme-mapping>
    <cache-mapping>
    <cache-name>Cache</cache-name>
    <scheme-name>cache-distributed</scheme-name>
    </cache-mapping>
    </caching-scheme-mapping>
    <caching-schemes>
    <distributed-scheme>
    <scheme-name>cache-distributed</scheme-name>
    <service-name>PartitionedCache</service-name>
    <thread-count>10</thread-count>
    <partition-count>2039</partition-count>
    <backing-map-scheme>
    <local-scheme />
    </backing-map-scheme>
    <autostart>true</autostart>
    </distributed-scheme>
    <proxy-scheme>
    <service-name>ExtendProxyService</service-name>
    <thread-count>5</thread-count>
    <acceptor-config>
    <tcp-acceptor>
    <local-address>
    <address>localhost</address>
    <port system-property="tangosol.coherence.proxy.port"></port>
    </local-address>
    </tcp-acceptor>
    </acceptor-config>
    <proxy-config>
    <cache-service-proxy>
    <class-name>....InteceptorCacheService</class-name>
    <init-params>
    <init-param>
    <param-type>com.tangosol.net.CacheService</param-type>
    <param-value>{service}</param-value>
    </init-param>
    </init-params>
    </cache-service-proxy>
    </caching-schemes>
    </cache-config>

  • OPSM 1.2 [Oracle pedigree and Serialization manager] installation is failed

    Hi All,
    We are doing OPSM 1.2 installation on Oracle Enterprise Linux 5.6 [64-bit].
    Steps we have done:
    1. installed 11g db and created repositories for soa server.
    2. installed weblogic server 10.3.6
    3. Installed soa server & created two managed servers soa_server1 and pas_server1 in weblogic as per the doc " Oracle Pedigree and Serialization Manager Installation Guide"
    4. And created required schemas in db for OPSM.
    5. and ran $MW_ORA_HOME/common/bin/wlst.sh ./pasMasterInstall.py
    Below are The error we are getting at the time of deployment is:
    Deploying the PasSerializationManager application...
    Deploying application from /u01/ORASOA/Middleware/Oracle_SOA1/pas/applications/install/PasSerializationManager.ear to targets pas_server1 (upload=false) ...
    <Dec 19, 2013 7:56:03 AM EST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, PasSerializationManager [archive: /u01/ORASOA/Middleware/Oracle_SOA1/pas/applications/install/PasSerializationManager.ear], to pas_server1 .>
    ....................................................................................................No stack trace available.
    This Exception occurred at Thu Dec 19 08:01:04 EST 2013.
    weblogic.management.scripting.ScriptException: Error occured while performing deploy : The action you performed timed out after 300,000 milliseconds.
    Error: Unable to deploy the Ear Files.
    Shutting down the AdminServer...
    Stopping the AdminServer...
    Finished stopping the AdminServer.
    Moving the Installed Files to the Install Directories...
    Finished moving files to install directory.
    Restoring Backup...
    Finished restoring backup.
    ERROR: Installation Failed!
    Note: Please review the above output buffer to determine what error(s)
          have occurred. You must fix any errors before attempting to
          retry the installation.
    WARNING: System failed to register the MDS Repository with WebLogic. It is likely
    that the MDS Repository has already been registered. Please verify the registered
    metadata repositories using Oracle's Enterprise Manager application. Once logged
    into Enterprise Manager, expand the Metadata Repositories node and verify an entry
    exists for mds-mds-ApplicationMDSDBDS. In addition, click on the repository and
    verify it is targeted to the appropriate servers.
    Exiting WebLogic Scripting Tool.
    <Dec 19, 2013 8:01:09 AM EST> <Warning> <JNDI> <BEA-050001> <WLContext.close() was called in a different thread than the one in which it was created.>
    In pas_server1.log file:
    Caused By: oracle.mds.exception.MDSExceptionList: MDS-01329: unable to load element "persistence-config"
    MDS-01370: MetadataStore configuration for metadata-store-usage "MAR_TargetRepos" is invalid.
    MDS-00929: unable to look up name "jdbc/mds/opsm" in JNDI context
    Unable to resolve 'jdbc.mds.opsm'. Resolved 'jdbc.mds'
            at oracle.mds.config.PConfig.loadFromBean(PConfig.java:1008)
            at oracle.mds.config.PConfig.<init>(PConfig.java:767)
            at oracle.mds.config.MDSConfig.loadFromBean(MDSConfig.java:1151)
            at oracle.mds.config.MDSConfig.loadFromElement(MDSConfig.java:1218)
            at oracle.mds.config.MDSConfig.<init>(MDSConfig.java:781)
            at oracle.mds.config.MDSConfig.<init>(MDSConfig.java:728)
            at oracle.mds.internal.lcm.deploy.DeployManager.deploy(DeployManager.java:529)
            at oracle.mds.internal.lcm.deploy.DeployManager.startDeployment(DeployManager.java:211)
            at oracle.mds.internal.lcm.MDSLifecycleListenerImpl.start(MDSLifecycleListenerImpl.java:215)
            at oracle.mds.lcm.weblogic.WLLifecycleListener.preStart(WLLifecycleListener.java:77)
            at weblogic.application.internal.flow.BaseLifecycleFlow$PreStartAction.run(BaseLifecycleFlow.java:282)
            at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
            at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
            at weblogic.application.internal.flow.BaseLifecycleFlow$LifecycleListenerAction.invoke(BaseLifecycleFlow.java:199)
            at weblogic.application.internal.flow.BaseLifecycleFlow.preStart(BaseLifecycleFlow.java:62)
            at weblogic.application.internal.flow.HeadLifecycleFlow.prepare(HeadLifecycleFlow.java:283)
            at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:648)
            at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
            at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
            at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:59)
            at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)
            at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
            at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:208)
            at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:98)
            at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
            at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
            at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
            at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
            at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
            at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
            at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
            at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
            at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
            at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
            at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
    Any one please  provide resolution to fix the issue. 
    Thanks
    skjb     

    Have you searched MOS website for (MDS-01370 AND MDS-00929) and go through the docs?
    If none of MOS docs help, then please log a SR.
    Thanks,
    Hussein

  • Equipment Master and Serialization

    Hi,
    Can anybody give me an overview/Definition on Equpment master and serialization in SAP. Where do we need them exactly and why? how does it relates to SD?
    Your early response will be highly appreciated.
    Thanks

    Hi Muhammad,
    Please check this links.
    http://help.sap.com/saphelp_erp2005/helpdata/en/01/d544ef4ab311d189740000e8322d00/frameset.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/dd/560d93545a11d1a7020000e829fd11/frameset.htm
    Hope this will help.
    Regards,
    Ferry Lianto
    Please reward points if helpful.

  • Comparable and Serializable interfaces

    Hi All,
    I have developed a program in java which implements Comparable and Serializable Interfaces. After, I decided to run the program in J2ME. But later on, I found that MIDP doesn't implement these interfaces.
    Some one can help me how to implement my own interfaces.
    Thank you

    Hi Supareno
    I need urgently your help.
    I developed Java program which works as predicitive text system for my mother tongue.I would like to move from Java to J2ME. But until now I have problems. please can u help me. the following code run in command line.
    I tried to develop my own interfaces as you told me but it doesn't work.
    Help me also for reading and writing text files.
    Thank you
    import java.util.*;
    import java.io.*;
    import java.util.Vector;
    import java.util.Enumeration;
    public class PredText {
    private Vector dict;
    public static final String dictionaryFile = "C:/java/words.txt";
    // convert a string to the corresponding signature
    public static String toNumeric (String word) {
    String lowerWord = word.toLowerCase();
    StringBuffer result = new StringBuffer("");
    for (int i = 0; i < lowerWord.length(); i++) {
    char c = lowerWord.charAt(i);
    if ("abc".indexOf(c) > -1) result.append("2");
    else if ("def".indexOf(c) > -1) result.append("3");
    else if ("ghi".indexOf(c) > -1) result.append("4");
    else if ("jkl".indexOf(c) > -1) result.append("5");
    else if ("mno".indexOf(c) > -1) result.append("6");
    else if ("pqrs".indexOf(c) > -1) result.append("7");
    else if ("tuv".indexOf(c) > -1) result.append("8");
    else if ("wxyz".indexOf(c) > -1) result.append("9");
    else if (" ".indexOf(c) > -1) result.append("9");
    else result.append("?");
    return result.toString();
    // find all the words corresponding to a signature
    public Vector findMatches(String sig) {
    WordSig ws = new WordSig(sig, "");
    WordSig newws;
    Vector results = new Vector();
    int index;
    index = Collections.binarySearch(dict, ws);
    if (index < 0){
    // no matches! :(
    // try to get the string that starts with a substring like ours.
    index=-1-index;
    if (((WordSig)dict.get(index)).getSig().startsWith(sig)) {
    // no word found. we return those starting with the
    // same signature
    newws = (WordSig) dict.get(index);
    results.addElement(newws.getWord().substring(0,sig.length()));
    return results;
    } else{
    //no match
    return results;
    } else {
    // go back to the first match
    while(((WordSig)dict.get(index)).getSig().equals(sig) && index>0)
    index--;
    if (index != 0)
    index++;
    while ((newws = (WordSig) dict.get(index)).equals(ws)){
    results.addElement( newws.getWord() );
    index++;
    return results;
    // intialises the dictionary
    public PredText () {
         String word;
    String sig;
    Vector dict = null;
    // first try to load dict.dat
    try {
    System.out.print("Trying to load dict.dat...");
    FileInputStream fileStream = new FileInputStream("C:/java/dict.dat");
    ObjectInputStream objectStream = new ObjectInputStream(fileStream);
    dict = (Vector) objectStream.readObject();
    fileStream.close();
    System.out.println(" done.");
    }catch (ClassNotFoundException classNotFoundException) {
         System.out.println("Unable to create an object");     
    catch (IOException e) {
    // exception: create the dictionary
    System.out.println("Error. I'm going to recreate the dictionary file");
    try {
    dict = createDict();
    catch (IOException ioe) {
    System.err.println("Error while creating dictionary file. Exiting." + e);
    System.exit(1);
    this.dict = dict;
    // create the dictionary serialised file
    public Vector createDict () throws IOException {
    String word;
    Vector dict = new Vector();
    //open the dictionary file
    System.out.print("Reading the dictionary... ");
    BufferedReader dictFile = new BufferedReader(
    new FileReader(dictionaryFile));
    //insert each word into the data structure
    while ((word = dictFile.readLine()) != null) {
    word = word.toLowerCase();
    dict.addElement(new WordSig(toNumeric(word), word));
    // List list = dict.subList(0, dict.size());
    List list = dict.subList(0, dict.size());
    Collections.sort(list);
    System.out.println("done.");
    System.out.print("Writing the dictionary... ");
    FileOutputStream fileStream = new FileOutputStream("C:/java/dict.dat");
    ObjectOutputStream objectStream = new ObjectOutputStream(fileStream);
    objectStream.writeObject(dict);
    objectStream.flush();
    fileStream.close();
    System.out.println("done.");
    return dict;
    public static void main (String args[]) {
         PredText pt = new PredText();
    if (args.length == 0) {
    // no arguments, find the largest clash
         Vector result;
         Enumeration e = pt.dict.elements();
    String currentSig = "";
    String prevSig = "";
    int clash = 0;
    int maxClash = 0;
    String clashSig = "";
    while (e.hasMoreElements()) {
    WordSig ws = (WordSig) e.nextElement();
    currentSig = ws.getSig();
    if (currentSig.equals(prevSig)) {
    // another word with the same signature
    clash ++;
    } else {
    // new signature: check if the previous one led
    // to a maximal clash
    if (clash > maxClash) {
    clashSig = prevSig;
    maxClash = clash;
    clash = 1;
    prevSig = currentSig;
    result = pt.findMatches(clashSig);
    System.out.println("The signature leading to most clashes is "
    + clashSig + " with " + result.size() +
    " number of clashes");
    for (int j = 0; j < result.size(); j++) {
    System.out.println((String)result.get(j));
    } else if ("0123456789".indexOf(args[0].charAt(0)) > -1){
    // numeric input: find the matches for the argument
    Vector result;
    result = pt.findMatches(args[0]);
    for (int j = 0; j < result.size(); j++) {
    System.out.println((String)result.get(j));
    } else {
    // convert each word to the corresponding signature
    for (int i = 0; i < args.length; i++) {
    System.out.print(toNumeric(args) + " ");
    class WordSig implements Comparable, Serializable {
    String word;
    String sig;
    public WordSig (String sig, String word) {
    this.sig = sig;
    this.word = word;
    public String getSig () {
    return this.sig;
    public String getWord() {
    return this.word;
    public int compareTo (Object ws) {
    return sig.compareTo(((WordSig) ws).getSig());
    public boolean equals (Object ws) {
    return sig.equals(((WordSig) ws).getSig());
    public String toString () {
    return sig + ", " + word;

  • Comparable and Serializable Interfaces in MIDP

    Hi All,
    I have developed a program in java which implements Comparable and Serializable Interfaces. After, I decided to run the program in J2ME. But later on, I found that MIDP doesn't implement these interfaces.
    Some one can help me how to implement my own interfaces.
    Thank you

    Thank you for replying to me.
    My problem is to compare to objects in MIDP.
    You know that in java is possible to implements directly the Comparable interface but in MIDP is not the same. So I think it requires to create your own. Is that my question.
    I need some to help me. just to avoid the implentation of comparable interface from the java lang package.
    Thank u.

  • What is serialization and serializable

    what is serialization and serializable,Can any body explain me please.

    hi
    Serialization in java is the process of making the object flat which can later be stored on your disk like a normal flat file. the serailized object can be found useful mainly when using RMI and EJB where we persist cobjects so that they can be sent online (thru cable) by this we mean for objects to be distributed the prerequiste is tht they should be serialized. For this we have a interfacein java called "Serializable". the class tht needs serialization of its object should implement this class. this is a marker interface(the interface tht contains nmo methods)
    hope the concept is clear if not please mail me to : [email protected]
    bye
    thnx and regards
    bhaskara navuluri

  • Inheritance and Serialization

    Dear forum members:
    I am facing some problem with one of my programs.
    I have once abstract superclass name LibraryItem and 2 other sub-classes named Book and CD both of which extends LibraryItem class.
    In the definition of all 3 classes I have mentioned 'implements serializable'
    Now I have also designed one driver class to test objects of Book.The program is running smooth except at the last part where I am trying to write one objects of Book class in a file named "item.dat".Actually I can't write the objects in the file and I am getting the following error message -
    java.io.NotSerializableException
    Code for LibraryItem class
    import cs1.*;
    import java.io.*;
    abstract public class LibraryItem implements Serializable{
    protected String callNo;
    protected String desc;
    protected String author;
    protected static int booksBorrowed = 0;
    protected static int toBeShelved = 0;
    protected static int onShelf = 0;
    protected static int booksHold = 0;
    protected boolean toShelf;
    protected boolean borrowed;
    protected boolean onHold;
    public LibraryItem( String newCallNo, String newDesc, String newAuthor ) {
         callNo = newCallNo;
         desc = newDesc;
         author = newAuthor;
         borrowed = false;
    onShelf++;
    toShelf = false;     
    onHold = false;
    System.out.println("\n\nA new library item created!");
    protected abstract String getCallNo();
    protected abstract String getDesc();
    protected abstract String getAuthor();
    protected void setCallNo() {
         System.out.print("\nPlease enter the new call number - ");
         callNo = Keyboard.readString();
    protected void setDesc() {
         System.out.print("\nPlease enter the new description for the item - ");
         desc = Keyboard.readString();
    protected void setAuthor() {
         System.out.print("\nPlease enter the new author for the item - ");
         author = Keyboard.readString();
    protected static int getBorrowed() {
         return booksBorrowed;
    protected static int getToBeShelved() {
         return toBeShelved;
    protected boolean getBorrowedStatus() {
         return borrowed;
    protected static int getonShelf() {
         return onShelf;
    protected static int getHold() {
    return booksHold;     
    protected boolean borrowed() {
    boolean valid = false;
    if( onHold == true ) {
    if( borrowed == false && toShelf == true ) {
         borrowed = true;
         System.out.println("\nItem has been issued for the member");
    booksBorrowed++;
    //onShelf--;
    onHold = false;
    booksHold--;
    valid = true;
    else if( borrowed == true && toShelf == false ) {
    System.out.println("\nSorry...!!!Item is already on hold!");
    valid = false;
    else if( borrowed == false && toShelf == false ) { 
    borrowed = true;
         System.out.println("\nItem has been issued for the member");
    booksBorrowed++;
    onShelf--;
    valid = true;
    else {
    System.out.println("\nSorry...!!!Item is either borrowed or not shelved!");
    valid = false;
    return valid;
    protected boolean returned() {
    boolean valid = false;
    if( borrowed == true ) {
    borrowed = false;
    System.out.println("\nItem is returned !");
    if( onHold == false )
    toBeShelved++;     
    toShelf = true;
    booksBorrowed--;
    valid = true;
         else {
         System.out.println("\nItem...!!!Book is not borrowed till now!");
    valid = false;
         return valid;
    protected void placeHold() {
    if( borrowed == false ) {     
    System.out.println("\nItem is on the shelf, it can be borrowed now!");
    else if( borrowed == false && onHold == true )
    System.out.println("\nItem already on hold!");
    else if( borrowed == true && onHold == false ) {
    onHold = true;
    System.out.println("\nItem of has been placed on hold for the member!");
    booksHold++;
    else if( borrowed == true && onHold == true )
    System.out.println("\nItem already on hold!");
    protected void placeOnShelve() {
    if( borrowed == false && toShelf == true && onHold == false ) {
    System.out.println("\nItem of choice has been shelved and ready to be borrowed");
    toBeShelved--;
    toShelf = false;
    onShelf++;
    else      
    System.out.println("\nEither the book is borrowed OR already on hold by some other member!");
    public boolean equals(Object otherObject) {
              boolean result = false;          // Assume different, unless we prove otherwise!
              try {
                   if (otherObject instanceof LibraryItem )
                        LibraryItem otherItem = (LibraryItem)otherObject;
                        result = (this.callNo.equals(otherItem.callNo));
              } catch (Exception e) {
                   System.err.println("An error occurred during Student.equals(): " + e.getMessage());
                   e.printStackTrace(System.err);
              return result;
    public abstract String toString();
    Code for Book class
    import java.io.*;
    import java.util.*;
    class Book extends LibraryItem implements Serializable{
         protected String category = "";
    protected BufferedReader input;     
    protected int year;
         public Book(String callNo, String description, String author, int year, String category) {
              super(callNo, description, author);
              this.category = category;     
              this.year = year;
              input = new BufferedReader(new InputStreamReader(System.in));
         protected String getCallNo() {
              return callNo;
    protected String getDesc() {
              return desc;
    protected String getAuthor() {
              return author;
    protected int getYear() {
              return year;
    public String toString() {
         return(desc+" by "+author+" belongs to "+category+" category");     
    protected void setCategory() throws IOException {
         String newCategory;
         System.out.println();
         System.out.print("Enter the new category for this book - ");
    newCategory = input.readLine();
    category = newCategory;
    System.out.println("The category of the book has been set to "+category);           
    Code for BookDriver class
    import java.io.*;
    import java.util.*;
    class BookDriver {
         public static void main( String args[] ) throws IOException {
              FileOutputStream file = new FileOutputStream("LibraryAndCard.dat");
    ObjectOutputStream outStream = new ObjectOutputStream(file);
              Book book = new Book("B123","C# made quiet easy","Rony", 2007, "Computer Books");
              System.out.println(book);
              book.setCategory();
         outStream.writeObject(book);      
         outStream.close();
    Pls do help me with your suggestions.when it is trying to write the object in the specified file in the statement outStream.writeObject(book), its throwing the above mentioned exception!
    thanx and regards
    RK

    What is the full error that is displayed in the console? It seems to me (although Im not too familiar with serialization) that its probably one of the class variables in Book that is not serializable (The BufferedReader doesn't seem to implement seriablizable???)
    If it is just this then you can presumably just write a new writeObject(inputstream) method to replace the defaultWriteObject in the inputstream? Just make it write the vital data about the reader instead of writing the object. Or you could write a little class extending bufferedreader and just adding serialization.
    You would need to do an equivalent readObject too.
    Hope that is of some help

  • Externalizable or Serializable

    Why or whynot should we use Externalizable insteard of Serializable?

    For a simple answer:
    If you implements Externalizable, you need to write your own codes.
    If you implements Serializable, you do need to do anything.
    You implements Externalizable if you want a customized serialization. (Write your own read and write methods).
    You implements Serializable if you want the system takes care everythings for you.
    --lichudang                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Web Application and Serialization

    Hi, i have a problem with a web application that is running on an Application server (BEA WebLogic 7.0). I have only the war file of the web application and i must know if in this war there is a class that is not serializable.
    How can i find it ? Is there a tool that can help me to find not serializable classes ?
    Thanks.
    claudiozx2006

    One way to do that is to decompile Java classes with Java decompiler and see which one doesn't implement Serializable interface. Here is a link to a good decompiler: http://www.kpdus.com/jad.html

  • 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

  • Drag and drop, transferable and serializable

    I am currently writing a drag and drop algorithm for a JTree.
    I mostly follow the example at http://www.oreilly.com/catalog/jswing/chapter/dnd.beta.pdf
    now i encountered the following problem:
    If my Nodes are not serializable they are changed to null when a path containing them is returned via the getTransferData method as defined in the Transferable interface.
    If they implement Serializable I get a java.io.NotSerializableException:
    pointing at a class that has nothing to do with this whole operation other then being in the same package. If i also try to make this class serializeable i get java.io.NotSerializableException: that points to java.lang.ref.WeakReference (there are WeakReferences in the second class but they are totally independent to anything i try to drag and drop).
    Does anyone have any knowledge in that field?

    Had the same problems until we made the objects Cloneable also - adding a public Object clone() method to the class being Transferable-ized, making sure it obeyed clone() semantics, and we started getting the right data flavors.

  • Interface/class hierarchy and serialization?

    Hi,
    I have an interface, base class that implements this interface and subclasses derived from base class that also implement this interface.
    I also have a method with this interface as an argument. My question is: how to do serialization of this argument in this method without using instanceof operator? Should interface extend Serializable and/or each class/subclass implement Serializable? Is it sufficient to just have common interface extend Serializable without classes/subclasses implementing it?
    thanks,
    sale

    How should I serialize for example if the argument in the method is subclass XYZ? Do I need to use instanceof operator?

Maybe you are looking for

  • Multiple files at sender File adapter

    Hi, I am new to XI and i am trying to do file to file scenario. My requirement is i want to send four files with different names from same directory to the receiver. Is it possible with one sender communication channel? If so can u please tell me how

  • Need to Generate a eText File for Payments

    Hi, I have a requirement to generate a eText Outbound file using Payment Process profile. I have understand the basic steps and template we need to use to generate the eTEXT output. Q1. But here is my question is that the XML tags will be repeated fo

  • Management IP unreachable

    Hello everyone!! I am facing this problem on different switches on my network on different days, the thing is that the switch is working fine and none of the users is facing in connection problem ,but I can not reach my switch (ping and telnet)from a

  • Is the guided point to point navigation really so ...

    I have tested Ovi maps 3 on my N82 for a week now here in Ireland.At least for using it here in Ireland I admit it's a nightmare. To get a distance of 800 meters from one corner of the road to another corner, I was suggested a 2.5 km route.(It's a ma

  • Can't put back external hard disk

    Hi, I can never put back my external hard disk (USB). There's an alert it was in use and can't be ejected. In use by which process? Thanks a lot! Peter