Hashtable imcompletely deserialized?!

If anyone could help me with this I would be most appreciative.
I appear to have a situation where a serializable class with an internal Hashtable is not deserilizing correctly. The class containing the Hashtable is called PropDb. In PropDb I have this method...
protected Hashtable  m_names = new Hashtable();
public synchronized String getStringVal(String key) {
  if ((key != null) && (key.length() != 0))
    return (String)m_names.get(key);
  else
    return null;
}Now here is the exception that is sometimes thrown...
java.lang.NullPointerException
        at java.util.Hashtable.get(Unknown Source)
        at util.PropertyDB.getString(PropertyDB.java:635)Given that the key is not null, and looking at the source for Hashtable... the only other entities in Hashtable.get() that could throw the NullPointer are the internal data array or one of the data items in the data array!
The reason I'm suspecting the serializing/deserializing is because it this NullPointer seems to come up "randomly"-- often enough to be a problem, but with no identifiable pattern!! So, can anyone tell me there are know issues with Hashtables deserializing in an incorrect state?
Thank you very much.

Hi there,
I just wanted to mention that Hashtable's actions are strongly
dependent by the hashcodes of the keys. Let's say that your
KEY objects don't have constant hashCodes. Then the result of
get() method is often wrong 'cause of the formula
     int hash = key.hashCode();
     int index = (hash & 0x7FFFFFFF) % tab.length;
   So if you want to serialize /deserialize Hashtable , I recommend you
to override the hashCode() method of you Keys and write it in a way
that gives you assurance that your key's hashcodes will remain constant after serialize/deserialize
regards, Kaloyan

Similar Messages

  • How do we get a hashtable from a webservice?

    Hi,
    I want to get a Hashtable result from a webservice. I want to develop a webservice which recieves some company name, It has to display the list of users in that company and the result should be Hashtable. So I have to get a Hashtable as my webservice result?
    Actually I tried with apache axis, eclipse, tomcat giving the following error as no Deserializor found.
    So help to solve this problem....
    Regards,
    Kumar.
    [email protected]
    Client Code is as follows:
    String targetNamespace = "http://192.168.1.165:8080/GP_USER/services/Validation";
              try {
                   /* Service lookup */
                   ServiceFactory serviceFactory = ServiceFactory.newInstance();
                   javax.xml.rpc.Service service = serviceFactory
                             .createService(new QName(targetNamespace,
                                       "UserValidationService"));
                   Call call = (Call) service.createCall();
                   QName qn = new QName("http://bean.getprice.hgv.com", "tns1:UserDetails");
                   call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "");
                   call.setProperty(Call.OPERATION_STYLE_PROPERTY, "document");
                   // call.setProperty(Call.SOAPACTION_USE_PROPERTY, "literal");
                   call.setTargetEndpointAddress("http://192.168.1.165:8080/GP_USER/services/Validation");
                   call.removeAllParameters();
                   call.setPortTypeName(new QName(targetNamespace, "Validation"));
                   call.setOperationName(new QName(targetNamespace, "displayUsers"));
                   if (call.isParameterAndReturnSpecRequired(call.getOperationName())) {
                        call.addParameter("in0", new QName(
                                  "http://www.w3.org/2001/XMLSchema", "string"),
                                  String.class, javax.xml.rpc.ParameterMode.IN);
                        call.registerTypeMapping(UserDetails.class, qn, new BeanSerializerFactory (UserDetails.class, qn),
                        new BeanDeserializerFactory (UserDetails.class, qn));
                        //call.setReturnType(new QName("http://www.w3.org/2001/XMLSchema", "struct"));
                        QName qVec=new QName("http://www.w3.org/2001/XMLSchema","mapItem");
                        call.setReturnType(qVec);
                   /* Service invocation */
                   comp_name ="ggp";
                   //Hashtable ht = (Hashtable) call.invoke(new Object[] {comp_name});
                   System.out.println(call.invoke(new Object[] {comp_name}));
                   Enumeration e = ht.keys();
                   UserDetails ud;
                   while( e. hasMoreElements() ){
                   ud = (UserDetails) e.nextElement();
                   System.out.println(ud);

    You have to remember that when sending data over a WS using SOAP, you are essentially sending the objects as XML (text). Therefore, when you want to transfer a java Hashtable or any other java object, it must be serialized into into text form at serverside, sent over the network, and finally deserialized from text into the Hashtable at the clientside.
    You cannot just send arbitrary Java objects over a WS and expect Axis to understand them. Axis only maps a subset of XML basic datatypes of java objects. For example, Axis understands boolean, int, byte, etc. But for any object that Axis does not natively understand, you must create a custom serializer/deserializer to transfer complex java objects.
    The issue at hand is interoperability. Look at the link below. In particular, look at the section called "What Axis can send via SOAP with restricted Interoperability"
    http://ws.apache.org/axis/java/user-guide.html#XMLJavaDataMappingInAxis

  • How can i get the all values from the Property file to Hashtable?

    how can i get the all values from the Property file to Hashtable?
    ok,consider my property file name is pro.PROPERTIES
    and it contain
    8326=sun developer
    4306=sun java developer
    3943=java developer
    how can i get the all keys & values from the pro.PROPERTIES to hashtable
    plz help guys..............

    The Properties class is already a subclass of Hashtable. So if you have a Properties object, you already have a Hashtable. So all you need to do is the first part of that:Properties props = new Properties();
    InputStream is = new FileInputStream("tivoli.properties");
    props.load(is);

  • Unable to reference items in a hashtable

    HI,
    I'm having a bad PowerShell day today!
    My sample script to read in a text file and put the data into a hash table works just fine:
    $InputFile=Get-Content C:\Out\ktf06011.REQ
    $CurrentUserHashTable = @{}
    ForEach ($Line in $InputFile)
    $Data=$Line.Split("=")
    $Label=$Data[0].Trim()
    $Label=$Label.Insert(($Label.Length),"`"")
    $Label=$Label.Insert(0,"`"")
    $Value=$Data[1].Trim()
    $Value=$Value.Insert(($Value.Length),"`"")
    $Value=$Value.Insert(0,"`"")
    $CurrentUserHashTable.Add($Label,$Value)
    $CurrentUserHashTable 
    However, when I use this within a script that uses a file system watcher event to discover the presence of the text file, I cannot get anything from the hash table. I can see my variables being created, ready to pass on to the .add statement. I have found
    a workaround for now - not using a hash table - but would love to know why I see this behaviour and suggestions for getting at the data.
    Here is the code that I'm having trouble with.
    $folder = 'c:\In'
    $OutFolder = 'c:\Out'
    $filter = '*.*'
    $CurrentUserHashTable = $NULL
    $FileSystemWatcher = New-Object IO.FileSystemWatcher $folder, $filter -Property @{IncludeSubdirectories = $false;NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'}
    Register-ObjectEvent $FileSystemWatcher Created -SourceIdentifier FileCreated -Action {
    $name = $Event.SourceEventArgs.Name
    $InputFile=Get-Content $folder\$name
    ForEach ($Line in $InputFile)
    #Write-Host $Line
    $CurrentUserHashTable = @{}
    $Data=$Line.Split("=")
    #Write-Host "Data: " $Data
    $Label=$Data[0].Trim()
    $Label=$Label.Insert(($Label.Length),"`"")
    $Label=$Label.Insert(0,"`"")
    #Write-Host "Label: " $Label
    $Value=$Data[1].Trim()
    $Value=$Value.Insert(($Value.Length),"`"")
    $Value=$Value.Insert(0,"`"")
    #Write-Host "Value: " $Value
    $CurrentUserHashTable.Add($Label,$Value)
    $CurrentUserHashTable
    Move-Item $folder\$name $OutFolder -Force
    #Label: "ID"
    #Value: "abc00001"
    #Label: "PID"
    #Value: "00001"
    #Label: "Title"
    #Value: "Mr"
    #Label: "Initials"
    #Value: "XY"
    #Label: "Forename"
    #Value: "Mickey"
    #Label: "Surname"
    #Value: "Mouse"
    #Label: "Siteabbrev"
    #Value: "UK"
    #Label: "Status"
    #Value: "STAFF"
    #Label: "BUabbrev"
    #Value: "NOBU"
    #Label: "Department"
    #Value: "Finance"
    Note the commented bits at the bottom are the output of
    Write-Host "Value: " $Value
     and
    Write-Host "Label: " $Label
    Also, if the following are placed within the loop, I see all data items being returned, so I know that they are added to the hash table. If they are added outside the loop, I just get the final entry "Department"
    Write-Host "Keys:" $CurrentUserHashTable.Keys
    Write-Host "Values:" $CurrentUserHashTable.Values
    Many thanks,
    Jon

    Rhys,
    Thanks that was so obvious, I couldn't see it!
    I knew the answer would be simple.
    Made the amendment to my script and can now get at the data in the hashtable, via (e.g.)
    $Department=$CurrentUserHashTable.'"Department"'
    Thanks again.
    Jon

  • Difference Between HashMap and HashTable

    Difference Between HashMap and HashTable
    Please explain with an example

    I have a situation in Java Collection and i am not
    able to figure a good solution. I am scared about the
    performance and memory that wil be used
    I have 5 List objects with thousands and thousands of
    records in it. The List is populated by a database
    query using jdbcTemplate which return like 200,000
    records
    Each record is identified by POLICY_ID. They may be
    List with multiple records for a POLICY_ID
    I want to extract each POLICY_ID from all the 5 List
    and make a single List object for each POLICY_ID and
    for each List and pass it to a print job which will
    print the data for a POLICY_ID
    Example
    Let say we have POLICY_ID = 15432
    List1 has one record for 15432
    List2 has one record for 15432
    List3 has one record for 15432
    List4 has three record for 15432
    List5 has three record for 15432
    From the 200,000 records in List1 i want to generate
    a seperate list with 1 record for policy id 15432 and
    let name is Listperpolicy
    after this logic we have
    Listperpolicy1
    Listperpolicy2
    Listperpolicy3
    Listperpolicy4
    Listperpolicy5
    call print job ( Listperpolicy1, Listperpolicy2,
    Listperpolicy3, Listperpolicy4, Listperpolicy5)
    Please let me know
    Thanks a Lotttttttttdon't worry about performance until you've got a working application. second-guessing what the performance bottlenecks will be is futile

  • How can I get the total "values" in a hashtable ?

    i know that i can get the total values in a hashtable by hash.elements() method. It returns an
    enumeration with all the values present in this hashtable. this is fine upto here.
    Now the preoblem is:
    According to what rule this enumeration will be returned. I mean..
    If i added in key A with value a,
    then key B with value b;
    then key C with value c;
    then key D with value d;
    (They all are objects of type String)
    now i call ... hash.elements(); Suppose it returns Enumeration enum;.
    Now in what order they all are present in this hashtable.
    Meaning is that if i move arond this enum in what sequence they all will be returned.
    option A ) In the same order as they were inserted in hashtable.
    option B ) According to LIFO;
    option C) There is no fix rules , simply it return all the elements and u cannot judge that the first element in enum was really the first element inserted in the hashtable and the second element of enum was really the second element inserted in the hashtable.
    What do u think..which option is correct ?
    Ny idea will highly appreciated.
    Thanks in advance.
    Sanjeev Dhiman

    hi, i am again..
    boss ! this is not true..u just change the order and or change the keys and something like ...
    "Sanjeev", "hello"
    "Dhiman", "hi"
    "Technosys" ,"Services"
    u will find that its not LIFO..really i was thinking before coding my project that option A is correct and with knowledge i wrote 3 - 4 classes but when i run the programm its starts throwing errors.
    so, i posted this question. I think "apppu" is right.
    I think , firstly hash is calculated for each value and that value is returned which can be received in a fastest way and hence not necessarily in LIFO and FIFO..
    Thanks to u also as u gave ur precious time for me.
    Once again.
    Thank you very much.
    Sanjeev Dhiman

  • Problem in Jtree while retrieving values from a hashtable

    Hi
    I am trying to show some values in a Jtree.I am receiving the values in a hashtable.The hashtable contains unique key but duplicate values.i want to show that values of that hashtable in a tree(but unique values)and under each value show all the key of it.can you please tell me how to do that.
    thanks

    If i understand right, you want to do something like this:
                   Hashtable values = yourhashtable;        
              DefaultMutableTreeNode root = new DefaultMutableTreeNode("Values");
              HashMap<Object, DefaultMutableTreeNode> nodes = new HashMap<Object, DefaultMutableTreeNode>();
              Iterator ii = values.keySet().iterator();
              while (ii.hasNext()) {
                   Object key = ii.next();
                   Object value = values.get(key);
                   if (nodes.containsKey(value)) {
                        DefaultMutableTreeNode node = nodes.get(value);
                        DefaultMutableTreeNode child = new DefaultMutableTreeNode(key);
                        node.add(child);
                   } else {
                        DefaultMutableTreeNode node = new DefaultMutableTreeNode(value);
                        DefaultMutableTreeNode child = new DefaultMutableTreeNode(key);
                        node.add(child);
                        nodes.put(value, node);
                        root.add(node);
              JTree tree = new JTree(root);Hope this helps,
    Alex.

  • Reading Values from a Hashtable.Please guideu

    Chaps,
    I am in a strange situation
    I am having a hashtable with the flwg values
    Entertainment Games
    Entertainment Video
    PIM Calculator
    Entertainment Jump
    Settings Set
    Entertainment Poker
    Now,I need to search this hashtable for the
    Object 'Entertainment' and whatever is the
    value of this,is put in an Array
    for this I am using:
    String s[];
    Enumeration e;
    for(int i=0; i<ht.size(); i++){
    String s = (String)ht.get("Entertainment");
    // I am stuck after this? Can some one please help?       
             

    Object value = ht.get("Entertainment");
    But if you are doing this (I can't tell if this is what you're doing from your first post, though):
    ht.put("Entertainment", onething);
    ht.put("Entertainment", anotherthing);
    ht.put("Entertainment", athirdthing);
    Then there will only be athirdthing in the table, cuz it'll overwrite the previous values.

  • Need help in using hashtable as a property of a form bean

    Hi,
    Is it possible to use a hashtable as a property of the bean.
    Well this is the problem i have
    I am using a hashtable as property and i want it to store from(/retrive into} form as ints/strings
    I have a
    JSP Page
    SampleAction --Action
    SampleForm --ActionForm
    Sample(bean)
    =============
    JSP Page
    (within the html:form tag)
    <html:text property="sample.number" />
    ====================
    struts-config links to
    SampleAction
    SampleForm
    ==============
    SampleForm
    Sample sample = new Sample();
    reset(){ ...impl...}
    validate(){.... impl.....}
    =================
    Sample.java
    private Hashtable prop = new Hashtable();
    public int getNumber()
       return ((Integer)prop.get("number")).intValue();
    public void setNumber(int number)
       prop.put("number",new Integer(number));
    ====================================
    this setup understandbly gives me a error like this
    no getter method for property sample.number
    PLEASE DO remember that i have a large number of mixed types in my form that needs to be populated into the bean and i detest using that many variables(in the bean)
    I NEED TO A KNOW A SOLN. PLEASE
    Thanx in advance
    cheers
    Ash

    Hi,
    I think the solution for your problem is
    put a form tag in your jsp page.
    name it as your form name defined in the struts-config.xml.
    in your case
    it is 'sample'.
    And make changes in the html:text tag like,
    <html:text name="sample" property="number" />
    Hope it will work.. have fun !!!

  • How to put data into a hashtable from a text file

    I need some help to put the words in a text file to a hashtable.The text file
    consist of words and the following set of punctuation marks {, . ; : } and spaces.
    thanks in advance.

    Navy_Coder wrote:
    6 zebras.But you must marry his eldest daughter as well, for that dowry.

  • Need to run a prog on 1.4 which is running on 1.5. .....using two hashtable

    hello,
    I've developed a program which is prefectly working on java 1.5.0 version.
    but when run on java1.4.0. it gives run time error in this code.
    first i'm getting error in second hashtable. put function where i'm using key as an integer.this is running on 1.5 version but have to change key as string on 1.4. but after that it is still not working properly.
    I want that when i clicked on open then it must show both file
    1. that have hdr extension
    2. that have same name as the corrseponding .hdr file but without extension.
    this program show desired result on 1.5 but on 1.4 it display only .hdr file.
    pls. help me regarding this .
    // class hdr file filter
    import java.io.File;
    import java.util.Hashtable;
    import java.util.Enumeration;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    public class hdrFileFilter extends FileFilter {
    private Hashtable filters = null;
    private Hashtable noextensionfilter = null;
    private String noextensionname=null;
    private String extensionname = null;
    private String description = null;
    private String fullDescription = null;
    private boolean useExtensionsInDescription = true;
    private String fname = null;
    public File noextensionarray[];
    int count=0;
    int counthdr=0;
    int i=0;     
         //all files are accepted.
    public hdrFileFilter()
         this.filters = new Hashtable();
         //Creates a file filter that accepts files with the given extension.
    public hdrFileFilter(String extension)
         this(extension,null);
         //Creates a file filter that accepts the given file type.
    public hdrFileFilter(String extension, String description)
         this();
         if(extension!=null)
         addExtension(extension);
         if(description!=null) setDescription(description);
         //Return true if this file should be shown in the directory pane,false if it shouldn't.
    public boolean accept(File f) {
         if(f != null) {
         if(f.isDirectory()) {
              return true;
         String extension = getExtension(f);
         if(extension != null && filters.get(getExtension(f)) != null)
              fname=f.getName();
              extensionname=fname.substring(0,fname.lastIndexOf('.'));
              counthdr+=1;
              return true;
         if(extension == null)
              noextensionfilter=new Hashtable(20);
              noextensionname=f.getName();          
              noextensionfilter.put(count,noextensionname);
              count=count + 1;
              if(noextensionfilter.get(count) == extensionname)
                   noextensionarray=new File[20];
                   noextensionarray=f
                   System.out.println("file:" +noextensionarray[i]);
                   i++;
                   return true;               
         return false;
         //Return the extension portion of the file's name .
    public String getExtension(File f)
              if(f != null)
                   String filename = f.getName();
                   int i = filename.lastIndexOf('.');
                   if(i>0 && i<filename.length()-1)
                        return filename.substring(i+1).toLowerCase();
              return null;
         //Adds a filetype "dot" extension to filter against.
    public void addExtension(String extension)
         if(filters == null)
         filters = new Hashtable(20);
         filters.put(extension.toLowerCase(), this);
         fullDescription = null;
    public String getDescription()
              if(fullDescription == null)
                   if(description == null || isExtensionListInDescription())
                        fullDescription = description==null ? "(" : description + " (";
                        // build the description from the extension list
                        Enumeration extensions = filters.keys();
                        if(extensions != null)
                             Object nn=extensions.nextElement();
                             fullDescription += "." + nn;     
                             while (extensions.hasMoreElements())
                                  fullDescription += ", ." + nn;
                        fullDescription += ")";
                   else
                        fullDescription = description;
              return fullDescription;
    public void setDescription(String description)
         this.description = description;
         fullDescription = null;
    public void setExtensionListInDescription(boolean b) {
         useExtensionsInDescription = b;
         fullDescription = null;
              public boolean isExtensionListInDescription()
              return useExtensionsInDescription;

    Might be fixable if you do something like
    javac -target 1.4
    Bytecodes are different in 1.5 and thus not backward compatible

  • How can I use active user session that's in an application scope Hashtable?

    First of all, is it possible to use the same session after a user exits and then returns?
    Second, if it is possible, then please tell me what I need to do. So far, this is what I have been doing...
    1.) The user submits login credentials
    2.) The user is authenticated.
    3.) The user does not have an existing session, so a new one is created.
    4.) The user closes the browser.
    5.) The user returns to login page and submits login credentials.
    6.) The user is authenticated.
    7.) The user has an existing session, so it should be used.
    This is where I'm having trouble. All active sessions for my application are stored in a Hashtable. I have been using <%@ page session="false" %> so that a new session is not automatically created. Each time before I create a new session, I check my Hashtable to see if that user has an existing session. If a session exists for that user, then I would like to continue using that session if possible. I have used the methods request.getSession() and request.getSession(false), but a new session is always returned.
    I could create a new session, copy the attributes from the old session(which is stored in my Hashtable) to the new session, and then invalidate the old session, but I'd rather not do that.
    Is there a way that I can use existing sessions that I have stored in my Hashtable?

    First of all, is it possible to use the same session after a user exits and then returns?No, I don't think so. Let me explain why. When the server creates a session object for each client, it needs to know which client is making the request. Remember that HTTP is a stateless protocol. Every time a client makes a request, it sends some sort of session id to the server to let the server know who is trying to make the request. The server will then check to see if a session object exists for that particular client and if so, it will make sure that the max inactive interval (maximum time alloted for that client's session) has not been exceeded. If every thing is okay, then the client can access the session object to get values that were previously placed there. There are many ways that servers try to keep track of clients. One way is to have the clients write the session ID using cookies. But, many people like disallow cookies. So some servers do what is known as URL rewriting. That is, they will write the session ID on the end of the query string. This can also be accomplished programmatically, but it can be taxing to do. Anways, the point is that the client and the server have to have some sort of link between each other and that link is the session ID. So, if the browser is closed, the session ID is lost. That particular client will be forced to get a new session ID the next time the following code is executed:
    //create a session object and set its values
    HttpSession session = request.getSession(true);>
    Second, if it is possible, then please tell me what I
    need to do. So far, this is what I have been doing...
    1.) The user submits login credentials
    2.) The user is authenticated.
    3.) The user does not have an existing session, so a
    new one is created.
    4.) The user closes the browser.
    5.) The user returns to login page and submits login
    credentials.
    6.) The user is authenticated.
    7.) The user has an existing session, so it should
    be used.If you really want to do something like this, you could make up your own ID and store it as a cookie on the client. I've never tried anything like this before so you would have to do your own research. Are you sure you want to do something like this. There is a reason why it works the way it does. There is also a reason why you want to keep the session timeout value some what small. Let me give you an example of some craziness with sessions. A client we once had wanted to keep their sessions open for 4 hours because they said there clients simply did not like to log in all the time. I nearly gasped when I was told we needed to do this. When you make the session time out large (i.e. the maxInactiveInterval( )), then session objects stick around longer in the server. Let's say a client logs into the server and receives a session object. Then, the client makes a few requests. The server knows to keep the session alive as long as the time between requests has not exceeded 4 hours. Then the client closes the browser. How is the server suppose to know that the browser was closed. Well, it doesn't. It just knows to check times between requests. So, that particular session object won't be garbage collected until the session times out. What if a whole bunch of clients did this. Yucko. The server would have a whole bunch of session objects living in memory. What a waste. This is all above and beyond the typical security problems that can arise from having a session open for so long. To make a long story short, you really shouldn't do what you are trying to do unless it is the nature of the app.
    >
    This is where I'm having trouble. All active sessions
    for my application are stored in a Hashtable. I have
    been using <%@ page session="false" %> so that a new
    session is not automatically created. Each time
    before I create a new session, I check my Hashtable
    to see if that user has an existing session. If a
    session exists for that user, then I would like to
    continue using that session if possible. I have used
    the methods request.getSession() and
    request.getSession(false), but a new session is
    always returned.
    I could create a new session, copy the attributes from
    the old session(which is stored in my Hashtable) to
    the new session, and then invalidate the old session,
    but I'd rather not do that.
    Is there a way that I can use existing sessions that I
    have stored in my Hashtable?

  • Getting the value from a hashtable

    Hi all,
    Can I get the value from a Hashtable by passing vector.toString() , in the get method?
    I am storing the key value pair using the key as vector.toString() as the key and a string value. When i am using the get method by passing vector.toString() I am getting an exception
    found : Object
    required : String.
    Thanks and regards
    Tanmoy

    Exception? "found: X required: Y" sounds more like a compiler error to me.
    You need to post the lines of code that cause the error so we can see what's going on.

  • Problem with doubleValue() method and hashtable

    Hi,
    I made a type double variable named tempNumber.
    and I used this to put that number in a hashtable
    CODE 1 : hash.put(key, new Double(tempNumber));
    Then I wrote this code to retrieve it.
    CODE 2: (hash.get(st.sval)).doubleValue();
    Note: I am using streamtokenizer to get the nexttoken, so st.sval is a string representation of the token.
    Now my problem is when I compile CODE 2, I get an error message saying that "method doubleValue() not found in java.lang.Object". Whats going on here??
    I am using java 1.1 by the way.
    Thanks in advance...

    Hash table stored and returns objects. You have to typecast the return value of get() method to Double and then call doubleValue() on it.
    Its something as follows
    ((Double)hash.get(key)).doubleValue()

  • Deserializing obj on network drive take a long time -- any ideas to improve

    Good morning!
    Deserializing objects from a network drive is taking way too long, much slower than deserializing the same object files stored on the local hard drive of the development PC. How I can reduce the time??
    The size of the serialized objects is small (72K and 17K).
    The PC access network drives quickly enough (word processing, text editing, etc). The PC JVM is 1.5.0_09 and the OS is Windows XP.
    Here is the background.
    I had the idea to create objects and serialized them on my server (an AS400) and let client applications deserialize them.
    Now that I have it running I find that deserializing the objects off the server take way too long! Does anyone have any ideas how to improve this.
    If I copy the serialized objects off the server onto the local hard drive of the development PC and access them from the local hard drive the speed is fine.
    To my mind that eliminates the potential for incompatibility between the JVM which serialized the objects and the JVM which descerialized the object. That is, the deserialize fast on the local drive, slow over the network.
    Used both UNC and mapped drive to access the server and I can't see any performance difference. That is
    filename = "//server/java/ftpaudit/SerializedObject.ser"
    and
    filename = "J:/ftpaudit/SerializedObject.ser"
    where J: is mapped to //server/java
    This is the code which deserialize the objects.
    try {
         File file = new File(filename);
         FileInputStream f = new FileInputStream(file);
         ObjectInputStream ois = new ObjectInputStream(f);
         Object returnObj = ois.readObject();
         ois.close();
         f.close();
         return returnObj;
    } catch (InvalidClassException ice) {
         ....Thank you for your time and help.
    BillB

    Could the file be locked on the server?I don't believe it is. It eventually (minutes loads). The delay is consistent. I haven't put the logging to see what part of the deserialize method is chewing up the time yet.
    Putting in code to copy the file from the server to the local hard drive then deserializing performs much, much faster (milliseconds, almost as fast as deserializing directly from the local drive).
    I modified this from another post to this forum
    try {
            FileChannel srcChannel = new FileInputStream(file).getChannel();
            FileChannel dstChannel = new FileOutputStream(dir+file).getChannel();
            dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
            srcChannel.close();
            dstChannel.close();
        } catch (IOException e) {
            e.printStackTrace();
        }I was wondering if there was a more efficient way to deserialize an object than the one in my original post. Or if there were hidden aspects to consider such as buffer size.
    Here's an alternative approach: since the server side
    is written in Java (I'm assuming, since you say that
    it writes a file containing serialized data), why not
    create an RMI interface for retrieving the
    information? The current approach, of opening a file
    over the network, is very fragile -- what happens in
    the network mount point or share name changes?Thank you. Good suggestion.

Maybe you are looking for