| Author |
java.io.NotSerializableException: java.io.RandomAccessFile is not serializable
|
naga eswar
Ranch Hand
Joined: Jan 25, 2012
Posts: 102
|
|
hi everybody,
We are facing an issue regarding the properties file. We have a property file "ExceptionMessages_en_EX.properties" which contains list of exceptions
for example
p4154=User not terminated. Please select terminated user.
This property file is placed in IBM\WebSphere\AppServer\properties.
Here the senerio is that we got one situation that, the application should check whether the user is terminated or not.
If user is not terminated then we are calling user defined exception using throw. in this method we connecting to "ExceptionMessages_en_EX.properties" and fetching the error message and alterting at JSP level.
But the issue is that while trying yo connect to property file we are getting below message
CORBA BAD_PARAM 0x4f4d0006 Maybe; nested exception is:
java.io.NotSerializableException: java.io.RandomAccessFile is not serializable
and alerting the message as "could not create Remote Reference"
Please help me and let me know if anything required
|
 |
naga eswar
Ranch Hand
Joined: Jan 25, 2012
Posts: 102
|
|
|
can anybody help me please....
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
You, or Websphere, is trying to send a RandomAccessFile object across the network. That's not going to work, since that class does not implement Serializable.
Can you perhaps use a java.util.Properties object instead? You fill it from the existing file, but a Properties object is serializable and will therefore not cause the same problem.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
naga eswar
Ranch Hand
Joined: Jan 25, 2012
Posts: 102
|
|
Thanks for your reply Rob.
Still its not clarified.
Rob Spoor wrote:You, or Websphere, is trying to send a RandomAccessFile object across the network. That's not going to work, since that class does not implement Serializable. Can you perhaps use a java.util.Properties object instead? You fill it from the existing file, but a Properties object is serializable and will therefore not cause the same problem.
We are not sending any RandomAccessFile object across the network. How can a Websphere send this RandomAccessFile (because i am working first time on websphere). Can you please elaborate please.
|
 |
naga eswar
Ranch Hand
Joined: Jan 25, 2012
Posts: 102
|
|
At last we resolve the problem
int above code, EElixirException class is trying to create an instance of Logger through getInsatnce method.
if we declare static as below in EElixirException class then we are not getting any problem otherwise its showing unable to serialize.
private static Logger log = Logger.getInstance(Constants.CHM_MODULE_ID);
why it is not serilizable if it is not static....???
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12911
|
|
You were trying to serialize EElixirException, which contains a Logger object. That means that if you serialize an EElixirException object, it will also try to serialize the Logger object that the EElixirException is referring to, and all objects that are referred to by the Logger, etc. Logger probably somewhere has a RandomAccessFile, which isn't Serializable.
You most likely don't want to serialize the Logger, so you could make it static or transient.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
naga eswar
Ranch Hand
Joined: Jan 25, 2012
Posts: 102
|
|
|
Thank you for your clarification Jesper
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
|
|
|
If the Logger is transient, you will have to re‑initialise it when you un‑serialise the object.
|
 |
naga eswar
Ranch Hand
Joined: Jan 25, 2012
Posts: 102
|
|
OK fine. Thank you Campbell Ritchie..
|
 |
 |
|
|
subject: java.io.NotSerializableException: java.io.RandomAccessFile is not serializable
|
|
|