Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Siva Ram
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
karl koch
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the word "new" appear anywhere in your code?
 
Siva Ram
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic