I have not yet experienced any serialization-related issues. But PMD and Findbugs detect a bunch of potential problems regarding seriazation. A typical case is an injected logge
I realize this is an old question, but I believe the only answer provided is incorrect.
will the fields, injected by @Inject and @PersistenceContext be reinjected on deserialization?
No, they will not. I personally experienced this with JBoss in a clustered environment. If the bean is passivation capable, then the container must inject a serializable proxy. That proxy gets serialized and deserialized. Once deserialized, it will locate the proper injection and rewire it. However, if you mark the field transient, the proxy is not serialized and you will see NPEs when the injected resource is accessed.
It should be noted that the injected resource or bean does not have to be Serializable, because the proxy will be. The only exception is for @Dependent scoped beans which have to be serializable or the injection transient. This is because a proxy is not used in this case.
should they be marked as transient?
No, see above.
or should I just ignore/switch off the code checks?
This is up to you, but it is what I would do.
should I really provide accessors to all those fields as PMD advises?
No, I would not. In our projects, we disable this check when we know we are using CDI.