0 Replies Latest reply on Apr 3, 2007 6:04 PM by mgrouch

    Seam and query cache error

    mgrouch Expert

      I'm trying to get Seam to use query cache (ehcache). I've changed
      action (which was initially generated by seamGen) to the code below

      (extend HibernateEntityQuery and override getCacheable())

      Now I'm getting "Session is null" exception. What am I missing?

      Thanks

      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.framework.EntityQuery;
      import org.jboss.seam.framework.HibernateEntityQuery;
      
      import java.util.List;
      import java.util.Arrays;
      
      @Name("emailList")
      public class EmailList extends HibernateEntityQuery {
      
       private static final String[] RESTRICTIONS = {};
      
       private Email email = new Email();
      
       @Override
       public String getEjbql() {
       return "select email from Email email";
       }
      
       @Override
       public Integer getMaxResults() {
       return 25;
       }
      
       public Email getEmail() {
       return email;
       }
      
       @Override
       public List<String> getRestrictions() {
       return Arrays.asList(RESTRICTIONS);
       }
      
       @Override
       protected Boolean getCacheable() {
       return true;
       }
      }
      



      Caused by: java.lang.IllegalStateException: session is null
      at org.jboss.seam.framework.HibernateEntityQuery.validate(HibernateEntityQuery.java:32)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
      at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
      at org.jboss.seam.interceptors.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:34)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      at org.jboss.seam.interceptors.TransactionInterceptor$1.work(TransactionInterceptor.java:32)
      at org.jboss.seam.util.Work.workInTransaction(Work.java:37)
      at org.jboss.seam.interceptors.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:27)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
      at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
      at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
      at com.lehman.primeserv.pilotapp.data.entity.PmdbFailCommentList_$$_javassist_1.validate(PmdbFailCommentList_$$_javassist_1.java)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
      at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:123)
      at org.jboss.seam.Component.callComponentMethod(Component.java:1834)
      at org.jboss.seam.Component.callCreateMethod(Component.java:1757)
      at org.jboss.seam.Component.newInstance(Component.java:1746)
      at org.jboss.seam.Component.getInstance(Component.java:1643)
      at org.jboss.seam.Component.getInstance(Component.java:1610)
      at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:53)
      at org.apache.myfaces.config.LastVariableResolverInChain.resolveVariable(LastVariableResolverInChain.java:42)
      at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:574)
      at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
      at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:140)
      at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:383)