1

i have managed bean, for example:

    @Named(value = "GrassBean")
    @SessionScoped
    public class GrassBean implements Serializable {

        @EJB
        private transient GrassLocal grass;

        public String getName() {
            return grass.getName(); /*NullPointerException*/
        }
    }

and stateless session bean:

    @Stateless
    public class Grass implements GrassLocal {
        @Override
        public String getName() {
            return "Name";
        }
    }

i use transient for ejb attribute, because session restore fail after autoredeploy in NetBeans. With transient after redeploy session restore valid, but ejb is NULL. How to resolve?

Server: GlassFish 4.1
IDE: NetBeans 8.0.2

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
hekko
  • 292
  • 1
  • 2
  • 6
  • Possible duplicate of [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – thegauravmahawar Nov 02 '15 at 16:33
  • 2
    Fields marked by `transient` are not serializable which EJBs are not part of. EJBs do not have to be `transient` because they themselves are already serializable without implementing the `java.io.Serializable` interface as they use serializable proxies. The problem persists somewhere else which is not visible in the current question and needs to be debugged and analysed further. – Tiny Nov 02 '15 at 16:55
  • Which import are you using for the `@SessionScoped` annotation? – perissf Nov 02 '15 at 16:57
  • I use javax.enterprise.context.* – hekko Nov 02 '15 at 17:53
  • As I understand when i use local interface, bean not serializable and session fail when restore. Also when I use transient attribute. – hekko Nov 02 '15 at 17:56
  • 2
    EJBs are absolutely not supposed to be `transient`. Remove that modifier. That problem with "session restore fail after autodeploy in Netbeans" needs to be solved differently. You may want to reframe your question on that in order to get answers. – BalusC Nov 02 '15 at 19:00
  • Perhaps I misunderstood, but I have been guided by this: http://stackoverflow.com/questions/11256587/ejb-not-serialized-in-managed-bean – hekko Nov 03 '15 at 02:33
  • i reasked question, with primary problem http://stackoverflow.com/questions/33495343/ioexception-while-loading-persisted-sessions-java-io-ioexception-on-glassfish-4 – hekko Nov 03 '15 at 09:26

0 Answers0