Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Hibernate LazyInitializationException...please help

    I could really use some help, I've been trying to sort this out for a week on my own.

    My setup:

    Container is JBoss AS 7.0.2 Final
    comes with Hibernate 4.0.0 CR2

    server.properties

    Any help would be greatly appreciated
    Last edited by jpappalardo; 24 Sep 2014, 09:43.

    #2
    Hi,

    As you can see from the logs - SC does following:
    a) JPADataSource acquires EM (EntityManager) and TX (transaction)
    b) JPADataSource executes query
    c) JPADataSource commits TX
    d) DataSource converts fetched entities to JS (and receives LazyInitializationException)
    e) JPADataSource releases EM

    To be exact: step e is NOOP - SC does absolutely nothing. SC expects java container to take care of closing EM.

    Now we know - it should be a problem in J2EE server configuration.
    I'm not an expert in JBoss. Let's try anyway.

    First I would remove following lines from you persistence.xml:
    <!--The built-in Hibernate connection pool is in no way intended for production use. It lacks several features found on any decent connection pool. -->
    <property name="hibernate.connection.pool_size" value="0"/>
    <!-- Enable Hibernate's automatic session context management -->
    <property name="hibernate.current_session_context_class" value="thread"/>
    <property name="hibernate.cache.provider_class" value="org.hibernate.cache.internal.NoCacheProvider"/>
    <property name="hibernate.connection.release_mode" value="on_close"/>
    Please tell me - does it have any effect.

    Regards,
    Alius

    Comment


      #3
      No it does not make any difference

      Comment


        #4
        While googling I've found suggestion: switch to eclipselink.

        Can you do that for testing purposes?
        By doing that you make sure that either ORM provider it not a cause or confirm it.

        Regards,
        Alius.

        Comment


          #5
          One more suggestion:

          try to add

          <persistence-context-type>Extended</persistence-context-type>

          to <persistence-context-ref> in web.xml.

          Regards,
          Alius

          Comment


            #6
            addint the Extended fixed it. Thank you so much.

            Comment

            Working...
            X