Announcement Announcement Module
Collapse
No announcement yet.
Spring-Flex 1.5 + Hibernate JPA 2 + Glassfish JNDI Lookup problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring-Flex 1.5 + Hibernate JPA 2 + Glassfish JNDI Lookup problem

    Today I'm using Gilead do deal if serialization problem, so I decided to try the new spring-flex (1.5.0.M1).
    In my application uses Hibernate 3.5.1 has JPA provider and Glassfish v3 as container, transaction management uses JTA.

    persistence.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
        <persistence-unit name="SeMAE_PU" transaction-type="JTA">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>jdbc/OracleAppDataSource</jta-data-source>
            <!-- class hidden -->
            <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
                <property name="hibernate.session_factory_name" value="hibernate/SessionFactory" />
                <property name="hibernate.connection.release_mode" value="auto" />
                <property name="hibernate.transaction.flush_before_completion"    value="true" />
                <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.SunONETransactionManagerLookup"/>            
            </properties>
        </persistence-unit>
    </persistence>
    And I get the persistent unit by jndi-lookup
    Code:
    <jee:jndi-lookup id="OracleEMF" jndi-name="persistence/Oracle_PU" />
    <jee:jndi-lookup id="sessionFactory" jndi-name="hibernate/SessionFactory" />
    The first time I've tried:
    Code:
    Caused by: java.lang.IllegalArgumentException: 
    Could not retrieve the underlying Hibernate SessionFactory from the provided EntityManagerFactory
    reading api-docs I found the way to manually insert the session factory:
    Code:
    <flex:message-broker>
        <flex:config-processor ref="jndiJpaHibernateConfigProcessor" />
        <flex:remoting-service default-channels="mySecureAMF, myAMF" />
        <flex:secured authentication-manager="_authenticationManager" access-decision-manager="flexAccessDecisionManager">
            <flex:secured-channel channel="mySecureAMF" access="IS_AUTHENTICATED_FULLY" />
        </flex:secured>
    </flex:message-broker>
    
    <bean id="jndiJpaHibernateConfigProcessor" class="org.springframework.flex.core.io.JpaHibernateConfigProcessor">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    After that, I got the same error again, to understand what is going on I checkout the source code of JpaHibernateConfigProcessor and, as far as I learned, to get the same error again my sessionFactory must be null.
    But I use the same code with gilead and works!
    I create another JpaHibernateConfigProcessor with minor changes, removing the the getEntityManagerFactory code, only works with sessionFactory, and change the error messages.

    But when I used my processor the same error happened YET AGAIN, so in conclusion I thought: Somehow the automatic post processor config is running, independent on the manually is set or not.

    Now I'm stuck in this problem, and returning to gilead. There is some workaround for this problem? Is it a bug or just misconfiguration from my part?

    Thanks for the help.

    P.S.: Sorry for the bad writing, english isn't my native language.
Working...
X