1 Reply Latest reply on Jul 30, 2007 5:08 PM by mgrouch

    hibernate session is not injected

      I have problem with injecting hibernate session.
      I have the following in my Seam component (which is session scoped)

      @In
      private Session productDatabase


      On first request it is injected properly and on second one (which is ajax request via quipukit 1.2 pagination control) it is not happening and the
      following exception is thrown:

      org.jboss.seam.RequiredException: In attribute requires non-null value: productList.productDatabase
      at org.jboss.seam.Component.getValueToInject(Component.java:2042)
      at org.jboss.seam.Component.injectAttributes(Component.java:1481)
      at org.jboss.seam.Component.inject(Component.java:1302)
      at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
      at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
      at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)


      My components.xml


      <components xmlns="http://jboss.com/products/seam/components"
       xmlns:core="http://jboss.com/products/seam/core"
      xmlns:persistence="http://jboss.com/products/seam/persistence"
       xmlns:transaction="http://jboss.com/products/seam/transaction"
       xmlns:drools="http://jboss.com/products/seam/drools"
       xmlns:web="http://jboss.com/products/seam/web"
       xmlns:security="http://jboss.com/products/seam/security"
       xmlns:framework="http://jboss.com/products/seam/framework"
       xmlns:mail="http://jboss.com/products/seam/mail"
       xmlns:pdf="http://jboss.com/products/seam/pdf"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation=
       "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
       http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
       http://jboss.com/products/seam/transaction http://jboss.com/products/seam/transaction-2.0.xsd
       http://jboss.com/products/seam/pdf http://jboss.com/products/seam/pdf-2.0.xsd
       http://jboss.com/products/seam/framework http://jboss.com/products/seam/framework-2.0.xsd
       http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.0.xsd
       http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
       <pdf:documentStore useExtensions="true" />
       <core:init debug="@debug@" jndi-pattern="@jndiPattern@" />
       <core:manager conversation-timeout="120000" concurrent-request-timeout="500" conversation-id-parameter="cid" />
       <persistence:hibernate-session-factory name="hibernateSessionFactory" />
       <persistence:managed-hibernate-session name="productDatabase" auto-create="true"
       session-factory-jndi-name="java:/productHibernateSessionFactory" />
       <drools:rule-base name="securityRules">
       <drools:rule-files>
       <value>/security.drl</value>
       </drools:rule-files>
       </drools:rule-base>
       <security:identity authenticate-method="#{authenticator.authenticate}" security-rules="#{securityRules}" remember-me="true" />
       <event type="org.jboss.seam.notLoggedIn">
       <action expression="#{redirect.captureCurrentView}" />
       </event>
       <event type="org.jboss.seam.postAuthenticate">
       <action expression="#{redirect.returnToCapturedView}" />
       </event>
      </components>


      What could be wrong? How can I troubleshoot this problem?
      Thanks


        • 1. Re: hibernate session is not injected

          I've found the reason. Code which uses this session was put into getter method and this getter was within ajax request which doesn't need or calls
          proxied action methods (so no injection happens).
          The query which used session should have been in
          @Create create() method instead of getter.