Announcement Announcement Module
Collapse
No announcement yet.
LocalContainerEntityManagerFactoryBean recursion->StackOverflowError Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LocalContainerEntityManagerFactoryBean recursion->StackOverflowError

    I have a working test for a Hibernate JPA based DAO running with LocalEntityManagerFactoryBean. The test is a JUnit test based on AbstractTransactionalDataSourceSpringContextTests.

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    
        <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
            <property name="url" value="jdbc:hsqldb:mem:database" />
            <property name="username" value="sa" />
            <property name="password" value="" />
            <property name="defaultAutoCommit" value="false"></property>
        </bean>
    
        <!--bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
            <property name="persistenceUnitName" value="freelancer" />
            </bean-->
    
        <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="persistenceUnitName" value="freelancer" />
        </bean>
    
        <bean id="abstractDao" abstract="true">
            <property name="entityManagerFactory" ref="entityManagerFactory" />
        </bean>
    
        <bean id="projectDao" parent="abstractDao" class="at.martinahrer.freelancer.dao.jpa.JpaProjectDao">
            <property name="implementationClass" value="at.martinahrer.freelancer.model.Project" />
        </bean>
    
        <bean id="activityDao" parent="abstractDao" class="at.martinahrer.freelancer.dao.jpa.JpaActivityDao">
            <property name="implementationClass" value="at.martinahrer.freelancer.model.Activity" />
        </bean>
    
        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory" />
        </bean>
    </beans>
    As soon as I switch to the LocalContainerEntityManagerFactoryBean in order to explicitly set the dataSource the code starts a recursion and ends with a StackOverflowError!

    Is there any parameter missing that configures the LocalContainerEntityManagerFactoryBean - I only aim at overriding the dataSource as specified in persistence.xml!


    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext-jpa.xml]: Invocation of init method failed; nested exception is java.lang.StackOverflowError
    Caused by: java.lang.StackOverflowError
        at org.apache.xerces.util.URI.isConformantSchemeName(URI.java:1213)
        at org.apache.xerces.util.URI.setScheme(URI.java:904)
        at org.apache.xerces.util.URI.initializeScheme(URI.java:576)
        at org.apache.xerces.util.URI.initialize(URI.java:400)
        at org.apache.xerces.util.URI.<init>(URI.java:211)
        at org.apache.xerces.util.URI.<init>(URI.java:195)
        at org.apache.xerces.impl.XMLEntityManager.expandSystemId(XMLEntityManager.java:1140)
        at org.apache.xerces.impl.XMLEntityManager.resolveEntity(XMLEntityManager.java:581)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.xsdToXMLInputSource(XMLSchemaLoader.java:625)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(XMLSchemaLoader.java:580)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:489)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(XMLSchemaLoader.java:588)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:489)
        at ....

  • #2
    I am not sure it is mandatory, but I think you should inject the "jpaVendorAdapter" property into your "LocalContainerEntityManagerFactoryBean".

    Comment


    • #3
      Julien, I have tried a vendor adapter with no improvement - looking at the JavaDoc and the source I don't think that it is related to that problem.

      <property name="jpaVendorAdapter">
      <bean class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter">
      <property name="database" value="HSQL" />
      <property name="showSql" value="true" />
      <property name="generateDdl" value="true" />
      </bean>
      </property>

      The weird thing is that the recursion seems to occur when XmlSchemaLoader tries to load some XML ....

      Comment


      • #4
        Which version of Xerces are you using?

        I've heard there were some significant bugs in older Xerces releases, and it's the component that causes the StackOverflowError...

        Comment


        • #5
          Julien, you are just confirming what I was debugging now. In fact I had a xercesImpl-2.0.2. Upgrading to the latest version resolves this issue.

          Thanks

          Comment

          Working...
          X