4 Replies Latest reply on Mar 28, 2008 1:43 PM by Pete Muir

    pojoCache.get method gives NullPointerException

    Thiagu Mariappan Novice

      Hai every one


      i use the JbossCache  for improve the page load time.
      I use the s:cache for Page fragment caching in my xhtml page.
      Then I inject the org.jboss.cache.aop.PojoCache class in session bean side for implement the JBossCache.


      This is my xhtml code


      
      <s:cache key="#{subcategoryName}" region="PageFragments" enabled="true">
      
      <h:form>
      
      <rich:dataTable value="#{productList}" var="Product">
      
      <f:facet name="header">
      
      <rich:columnGroup>
      
      <h:column>
      
      <h:outputText value="SubcategoryName" />
      
      </h:column>
      
      <h:column>
      
      <h:outputText value="Product Name" />
      
      </h:column>
      
      </f:facet>
      
      </rich:columnGroup>
      
      <h:column>
      
      <h:outputText value="#{Product.subcat}" />
      
      </h:column>
      
      <h:column>
      
      <h:outputText value="#{Product.name}" />
      
      </h:column>
      
      </rich:dataTable>
      
      </h:form>
      
      </s:cache>
      
      



      This is my session bean class


      
      @Stateful
      
      @Name("search")
      
      public class ProductsAction  implements ProductsLocal,Serializable
      
      {
      
      @Out(required=false,scope = CONVERSATION )
      
      @RequestParameter
      
      String subcategoryName;
      
      
      @Out(required=false)
      
      List<TblProducts> productList;
      
      
         @In(create = true)
      
          PojoCache pojoCache;
      
      
      @Begin(join=true)
      
      public String selectFromRequest() {
      
      try
      
      {
      
            productList = (List<TblProducts>) pojoCache.get("productLiat", "hid");
      
            if (prodlis==null) 
      
            {
      
                productList =em.createQuery("select t from TblProducts t where t.subcat="+ subcategoryName).getResultList();
      
                pojoCache.put("productLiat", "subcategoryName", prodlis);
      
            }
      
      } catch(CacheException e){
      
          e.printStackTrace();
      
        }
      
      
      }
      
      }
      
      
      


      i got the Nullpointer error from my pojoCache.get method.
      i dont know how to fix this error , is there any mistake in my code .
      Any one, please help me to know what i need to do in my session bean side to prevent the frequently query execution.
      because i need to display the page by using the cache data , i need the query execution at beginning when i vist the page or after the cache expires


      By
      Thiagu.m

        • 2. Re: pojoCache.get method gives NullPointerException
          Thiagu Mariappan Novice

          i try to inject the org.jboss.cache.aop.PojoCache class in my session bean. Actually this class extend the get method from its super class org.jboss.cache.TreeCache


          if i try to use pojoCache instance anywhere in my session bean class,
          I can only access the parameters of that class, I cant access the method. If try to access the method it gives syntax error like this.


          “The type org.jboss.system.ServiceMBeanSupport cannot be resolved. It is indirectly referenced from required .class files”


          If try to build the project the search session bean instance should be null,
          How to fix this error,


          By
          Thiagu.m

          • 3. Re: pojoCache.get method gives NullPointerException
            Thiagu Mariappan Novice

            Here is the requested stack trace for this issue.


            javax.el.PropertyNotFoundException: Target Unreachable, identifier 'productsearch' resolved to null
                 at org.jboss.el.parser.AstValue.getTarget(AstValue.java:38)
                 at org.jboss.el.parser.AstValue.invoke(AstValue.java:95)
                 at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
                 at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:173)
                 at org.jboss.seam.navigation.Pages.callAction(Pages.java:636)
                 at org.jboss.seam.navigation.Pages.preRender(Pages.java:289)
                 at org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:549)
                 at org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:460)
                 at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:144)
                 at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114)
                 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
                 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                 at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
                 at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                 at 
            



            The problem I have is that I am trying not to execute the query if it is already in the cache,
            but i am not clear how to check that condition ,
            i try with above code , it give the mentioned issue.
            please help me how to do that.


            By
            Thiagu.m


            • 4. Re: pojoCache.get method gives NullPointerException
              Pete Muir Master

              The WHOLE stack trace!



              What application server?