2 Answers
2

Don't keep a reference to GenericCrudService as a field (nor the InitialContext instance). Refactor the lookup code to a method, and retrieve it every time you need the service. You can reuse it, but keep it to local (variables) or request scope.

AFAIK, there's no guarantee that EJBs returned from a JNDI lookup will be serializable, even if they implement the interface and follow the serialization rules. The container will probably return a proxy, not the object instance directly.

Since Wicket will serialize stateful pages after requests, they can't have non-serializable attributes. This is the cause of the error you're getting.

You can also mark your GenericCrudService field transient and initialize instance in Component onAttach/onConfigure method. When using Spring there is a dedicated annotation @SpringBean in Wicket, which will make your non-serializable service field a proxy and handle instance setting for you.