Unclear NotSerializableException

Hello!

I am involved in a complex Java EE project of our customer for more than six month now. The project is a 3-tier design, where the application server is a JBoss 7.1.1 over an Oracle 11g database. The GUI designers do not access directly the database, so it is unimportant which database is used at all. On the GUI site, JGoodies makes the bindings. The server side uses annotations and uses CDI to inject properties. The design is rather complex: All the code is subdivided in around 90 eclipse projects.

As usual, access to database tables is done using JPA entities. Currently, I am working to make the connection to the server of a previously designed dialog that used CSV data before, but I run into problems. Unfortunately, all the knowing personal is on vacation, so I wanted to bother you with my problem.

The error message I get seems to be straightforward. It reads:

[30.08.2013 10:53:05.628] INFO  [Class:RmTracer Thread:AWT-EventQueue-0] - WriteAbortedException: writing aborted; java.io.NotSerializableException: net.atos.roman.tmtbl.jpa.dao.train.adjunct.JPATrainType

Open in new window


I searched the Internet and found out the answer that in this case, it is advisable to make the object serializable. However, all JPA entities in this project are not serializable. So, my

First question:
How can I find out why the system wants a serialization on this class?

If I follow the advise found above, I get another error message:

[30.08.2013 11:26:12.789] INFO  [Class:RmTracer Thread:AWT-EventQueue-0] - ClassNotFoundException: net.atos.roman.tmtbl.jpa.dao.train.adjunct.JPATrainType

Open in new window


Although the location has not been changed and the persistence.xml files of the project are the same, the server cannot find the serialized class. This results in my

Follow-up question:
What can be the reason that this class becomes unfindable?

Thank you for your help.
Concise-JPATrainType.java
LVL 1
Ahmet Ekrem SABANSenior IT consultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

girionisCommented:
Currently, I am working to make the connection to the server of a previously designed dialog that used CSV data before, but I run into problems

How do you connect to the server? If you're sending the object itself across the wire then you need to serialise it.

What can be the reason that this class becomes unfindable?

If you recompiled the class and put it in a jar file you need to add this file to the classpath.
0
Ahmet Ekrem SABANSenior IT consultantAuthor Commented:
Thank you for your reply!

All the JPA entities do not use the serializable interface in this project. I searched in the code the usage of JPATrainType and other JPA entities & found out that it is used in the same way.

The recompilation is done automatically by the eclipse IDE. I didn't change any settings, so I have to assume that no new JAR file location is in use.

I continue with my search. Unfortunately, I am not allowed to send you parts of the code, so making a diagnosis is very difficult.
0
girionisCommented:
You don't need to serialise the JPA entities, unless you need to send them to another system (to another JVM). You said earlier that you're making a connection to the server. You need to look where you're connecting, this is where you probably need the serialisation.

The recompilation is done automatically by the eclipse IDE. I didn't change any settings, so I have to assume that no new JAR file location is in use.

There must be, otherwise it wouldn't fail.
0
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Ahmet Ekrem SABANSenior IT consultantAuthor Commented:
Interesting! How do you explain then that the WriteAbortedException occurs iff changing the JPATrainType to serialisable & adding a serialVersionUID constant? The class is found before this step, as the system finds out that it is not serialisable.

(The JPA entity JPATrainType is a relational attribute of JPATrainClass. A second JPA entity, JPAProduct, which is used to fill a second table in the dialog does not have such a relational attribute & reads the data without problems. It is - like all other JPA entities in this project - not serialisable.)
0
girionisCommented:
I thought the error you're getting after adding the Serializable interface was ClassNotFoundException.
0
Ahmet Ekrem SABANSenior IT consultantAuthor Commented:
That's correct. But when I remove this interface, the class is there again, as the error this time says that the class "is" not serialisable. In order not to be serialisable, it first must be. :->
0
girionisCommented:
How do you run your project (the one that has the JPATrainType)? Is it web based? Do you install it as a jar or ear file? If yes, do you also have this jar file in other projects as well?
0
Ahmet Ekrem SABANSenior IT consultantAuthor Commented:
It is a 3-tier project with the GUI with JGoodies, the JBoss 7.1.1 AS, & Oracle 11g. It is rather large (89 projects appear in eclipse). I start first the server & then the main dialog for some customer.

I thank you very much for your support, but today my colleague who was ill returned. He worked more than an hour and found out the problem. The JPA entity that seemed to cause the error (JPATrainType that represented a foreign key object in JPATrainClass, the main entity of the train class dialogue) called in a data transfer object POJO a method called acceptAttributes. This method called also another method called acceptRelations, which was the reason.

Our Java EE expert with three years of experience who worked now for more than half a year for this project needed about an hour to find it out. So, you or anybody else here had no chance.

I will give you some points for your contribution. Thank you!
0
ajayPratapsinghCommented:
There was a minor change in the DTO's. during accepting the attributes, I removed the acceptRelations method which was setting the TrainClass
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java App Servers

From novice to tech pro — start learning today.