I'm trying to create a scalable JSF application. I would like to save view states on client side but I have troubles with ViewScoped ManagedBean with CDI Injected attributes.
SomeService.java :
@Singleton
public class SomeService {
// ...
}
SomeBean.java
@ManagedBean
@ViewScoped
public class SomeBean implements Serializable {
@Inject
private SomeService someService;
}
Unfortunately glassfish fails to serialize someService
which I don't want to be serializabled but re-injected.
I tried to make it transient which ends up to a NullPointerException when accessing someService
after de-serialization.
What shall I do?
I'm aware that I could use CDI ViewScoped with Seam Faces or CODI but I want to minimize at most dependencies.
I could also wait for JEE7 which will provide @ViewScoped for CDI but we won't be using JEE7 before months.
UPDATE :
I just wanted to add that I was using embedded EJB bundled in a jar which is itself linked to my war.
NotSerializableException's stack trace has the following message :
com.company.core.service.__EJB31_Generated__SomeService__Intf____Bean__
@Inject
instead of EJB's@EJB
? – BalusC@EJB
in some cases. I tried to change from@Inject
to@EJB
without any improvement. Do you have any recommendation? – Alexandre Jacob