Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-1636

Cannot inject Spring-bound HibernateSessionFactory to Seam-managed Hibernate Session


    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 2.0.0.CR1
    • Component/s: Spring
    • Labels:
    • Environment:

      Tomcat 6.0.13, Spring 2.0.6, Seam CVS 08072007


      Filling this PR as requested by Mike.
      For a full story please read related topic. As you requested I tried to reproduce environment from my previous unsuccessful attempts. It's a little bit frustrating but after assembling it once again now Spring EL resolver seams to working somewhat in some aspects. But let's try to report step by step.

      1. Spring-EL approach: Spring-bound session factory, referenced in components, Spring EL resolver put into faces-config. There are two cases:
      1.a. I have Seam-session-scoped bean that in @Create tries to get Hibernate session and retrieve some information from RDBMS. I have abstracted Seam-managed-hibernate-session access, and this additional layer simply invokes Component.instance(NAME_OF_SEAM_MANAGED_HIBERNATE_SESSION_COMPONENT_DECLARED_IN_COMPONENTSXML) instead of relying in @In. This layer is completely pluggable and allows to select HibernateSession manager (Seam, Spring OSIV, custom one for Test) and inject it into data access layer.
      Ok, so this @Create call renders a bunch of extremely huge stacktreace (WORKED in Microncontainer/Seam 1.3 combo flawlessly). You can see these stracktraces in springELResolverStackTrace.txt.zip file.
      1.b. Every following HibernateSession access seams to WORK now (I swear It didn't ). Strange... Anyway I cannot use it because of 1.a.

      1.1 components.xml
      <persistence:managed-hibernate-session name="seamManagedHibernateSession" auto-create="true"

      <transaction:hibernate-transaction session="#{seamManagedHibernateSession}"/>

      2. Spring namespace approach: Spring-bound session factory, referenced in components.xml, <seam:component> added to Factory definition in application context:

      <bean id="pecpHibernateSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" scope="prototype">
      <seam:component class="org.hibernate.impl.SessionFactoryImpl"/>
      <property name="dataSource" ref="dataSource" />
      <property name="configLocation" value="classpath:conf/hibernate/hibernate.cfg.xml" />
      <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
      <property name="namingStrategy">
      <bean class="egd.persistence.hibernate.extensions.UnderscoreAwareNamingStrategy"/>

      Spring listener put AFTER Seam listener in web.xml. App contexts configured from Spring listener. Result: java.lang.IllegalStateException: No active application scope. See seamComponentNamespaceStackTrace.txt.zip.

      2.1. components.xml like in 1.1.

      3. <spring:context-loader> approach. Everything like in point 2., but Spring listener removed from web.xml.
      Result: "Seam cannot wrap JDK proxied IoC beans. Please use CGLib or Javassist proxying instead" - stracktrace in

      3.1. components.xml
      <core:init transaction-management-enabled="true" debug="true"/>
      <core:manager conversation-timeout="120000"
      <spring:context-loader config-locations="classpath:conf/spring/core.xml,
      <persistence:managed-hibernate-session name="seamManagedHibernateSession" auto-create="true"

      <transaction:hibernate-transaction session="#



      That's all info I can get about this. Having a model example of such integration that I was struggling with would be a quite nice POC.
      Now I need to get back to code, because I lost a lot of time lately . Will happy live with my current workaround for a while .

        Gliffy Diagrams




              • Assignee:
                youngm youngm
                przemjaskier Przemyslaw Jaskierski
              • Votes:
                0 Vote for this issue
                0 Start watching this issue


                • Created: