1 Reply Latest reply on Feb 25, 2013 11:01 AM by r035198x

    calling singleton bean from a session bean returns NullPointerException

      I am doing this

      public class ResourceBean {

      private void init()
      System.out.println("Resource Bean created successfully");

      public String returnString(String name) {
      String n=name;
      return n;

      and i call this singleton bean from a stateless session bean like this


      public class ClientBean {

      ResourceBean resource;

      public String create(String r)
      String res=resource.returnString(r);
      return res;

      But resource.returnString(r); gives a org.apache.jasper.JasperException: java.lang.NullPointerException I started the glassfish server in debug mode and found out that "resource" was null. but @PostConstruct in singleton does print which means singleton bean exists.

      Can we call singleton beans with no interface in such a way form a session bean? I actually want to acquire instance of singleton bean when a client invokes method in Client bean