My Solution consists of 3 different projects:
EJB project with Netbeans auto-generated Facades to manage Entity classes and the persistence.xml
Class-Library that holds all @Entity annotated and statically weaved database classes and the remote interfaces for the facade ejb's (shared between EJB and stand-alone client)
Stand-alone Client that consists mainly of Swing GUI classes
I use Glassfish 3.1.2, Eclipselink 2.3 as JPA-provider, Netbeans 7.1.1 and a MySQL database. I configured an Ant-task that statically weaves my entity classes on the basis of the persistence.xml.
I have several @OneToOne, @ManyToOne and @ManyToMany annotated relations between the entities decorated with fetch=FetchType.LAZY.
Now I get all along the following errors:
Exception in thread "Mainframe Loader" Local Exception Stack:
Exception [EclipseLink-7242] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException
Exception Description: An attempt was made to traverse a relationship using indirection that had a null Session. This often occurs when an entity with an uninstantiated LAZY relationship is serialized and that lazy relationship is traversed after serialization. To avoid this issue, instantiate the LAZY relationship prior to serialization.
at org.eclipse.persistence.exceptions.ValidationException.instantiatingValueholderWithNullSession(ValidationException.java:998)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:220)
at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:88)
at org.eclipse.persistence.indirection.IndirectList.buildDelegate(IndirectList.java:244)
at org.eclipse.persistence.indirection.IndirectList.getDelegate(IndirectList.java:414)
at org.eclipse.persistence.indirection.IndirectList.size(IndirectList.java:752)
at ch.lawsuite.gui.mail.PosteingangUI.updateDokumentTable(PosteingangUI.java:47)
at ch.lawsuite.gui.mail.MailboxUI.updateDokumentTables(MailboxUI.java:81)
at ch.lawsuite.gui.mail.MailboxUI.initMailboxes(MailboxUI.java:37)
at ch.lawsuite.gui.mail.MailboxUI.<init>(MailboxUI.java:23)
at ch.lawsuite.gui.MainframeUI.initModules(MainframeUI.java:191)
at ch.lawsuite.gui.login.LoginUI$MainframeLoader.run(LoginUI.java:131)
Any help is highly appreciated. I completely got deadlocked with this issue for more than a week now :-(
Many thanks in advance!