• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.io.NotSerializableException: java.io.RandomAccessFile is not serializable

 
naga eswar
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody help me please....
 
Rob Spoor
Sheriff
Pie
Posts: 20545
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
naga eswar
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Saloon Keeper
Posts: 15354
39
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
naga eswar
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your clarification Jesper
 
Campbell Ritchie
Sheriff
Pie
Posts: 49361
62
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the Logger is transient, you will have to re‑initialise it when you un‑serialise the object.
 
naga eswar
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK fine. Thank you Campbell Ritchie..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic