aspose file tools*
The moose likes Beginning Java and the fly likes NULL Pointer Exception from the class which extends Hash Map. urgent help please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NULL Pointer Exception from the class which extends Hash Map. urgent help please" Watch "NULL Pointer Exception from the class which extends Hash Map. urgent help please" New topic
Author

NULL Pointer Exception from the class which extends Hash Map. urgent help please

Siva Ram
Ranch Hand

Joined: Apr 04, 2002
Posts: 66
Hi,
I have written a class(TestClass) which extends HashMap.
As HashMap already implements serializable interface. I am using this class in EJB trasactions which lead me to NULL Pointer exception.
When ever I am calling the ejb method , I am getting the NULL Pointer exception. Then I called the dao without ejb. It works fine. But the problem is when I set the particular dao output (i.e TestClass object) to HttpSession, it again throws NULL Pointer exception.
It is throwing NULL Pointer exception in put method of the Hashtable.
Can any one please help me to solve this issue please.
Thanks & Regards,
Sivaram


Thanks and Regards,<br />Siva Ram .NR
karl koch
Ranch Hand

Joined: May 25, 2001
Posts: 388
hi
can you post some code (your Hashmap extension and also the code that throws the exception and the stacktrace).
k
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

Does the word "new" appear anywhere in your code?


Please ignore post, I have no idea what I am talking about.
Siva Ram
Ranch Hand

Joined: Apr 04, 2002
Posts: 66
This is the code which I am using now.
public class TestClass extends java.util.HashMap {
private java.util.ArrayList internalOrder;
/**
* TestClass constructor comment.
*/
public TestClass() {
super();
internalOrder = new java.util.ArrayList();
}
/**
* TestClass constructor comment.
* @param initialCapacity int
*/
public TestClass(int initialCapacity) {
super(initialCapacity);
internalOrder = new java.util.ArrayList(initialCapacity);
}
/**
* put method
*
* @return java.lang.Object
* @param key java.lang.Object
* @param value java.lang.Object
*/
public Object put(Object key, Object value) {
internalOrder.add(value);
return super.put(key,value);
}
}
Can you help now please ..
The error happens when I try to set this Test class object into http Session and also while removing from the httpsession.
The error is as follows :
at java.util.HashMap.readObject(Compiled Code)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Compiled Code)
at java.io.ObjectInputStream.invokeObjectReader(Compiled Code)
at java.io.ObjectInputStream.inputObject(Compiled Code)
at java.io.ObjectInputStream.readObject(Compiled Code)
at java.io.ObjectInputStream.inputClassFields(Compiled Code)
at java.io.ObjectInputStream.defaultReadObject(Compiled Code)
at java.io.ObjectInputStream.inputObject(Compiled Code)
at java.io.ObjectInputStream.readObject(Compiled Code)
at java.io.ObjectInputStream.inputClassFields(Compiled Code)
at java.io.ObjectInputStream.defaultReadObject(Compiled Code)
at java.io.ObjectInputStream.inputObject(Compiled Code)
at java.io.ObjectInputStream.readObject(Compiled Code)
at java.io.ObjectInputStream.readObject(Compiled Code)
at java.util.Hashtable.readObject(Compiled Code)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Compiled Code)
at java.io.ObjectInputStream.invokeObjectReader(Compiled Code)
at java.io.ObjectInputStream.inputObject(Compiled Code)
at java.io.ObjectInputStream.readObject(Compiled Code)
at java.io.ObjectInputStream.readObject(Compiled Code)
at com.ibm.servlet.personalization.sessiontracking.BackedHashtable.getValue()
Thanks & Regards,
Ravisankar.N
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NULL Pointer Exception from the class which extends Hash Map. urgent help please