Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression Hibernate Search [SPR-10221] #14854

Closed
spring-issuemaster opened this issue Jan 27, 2013 · 3 comments
Closed

Regression Hibernate Search [SPR-10221] #14854

spring-issuemaster opened this issue Jan 27, 2013 · 3 comments
Assignees

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Jan 27, 2013

marc schipperheyn opened SPR-10221 and commented

I have a weird regression on Hibernate Search (4.2).
This occurs in the upgrade from 3.1.2 to 3.1.3. I ran into it upgrading from 3.1.1 to 3.1.4 and traced it down to 3.1.3.

The error message is

Caused by: org.hibernate.search.SearchException: Found invalid @IndexedEmbedded->paths configured on class nl.msw.project.model.Offer, member address: city.id,country.id,barrio.id
	at org.hibernate.search.engine.spi.AbstractDocumentBuilder.validateAllPathsEncountered(AbstractDocumentBuilder.java:901)
	at org.hibernate.search.engine.spi.AbstractDocumentBuilder.checkForIndexedEmbedded(AbstractDocumentBuilder.java:880)
	at org.hibernate.search.engine.spi.AbstractDocumentBuilder.initializeMemberLevelAnnotations(AbstractDocumentBuilder.java:489)
	at org.hibernate.search.engine.spi.AbstractDocumentBuilder.initializeClass(AbstractDocumentBuilder.java:391)
	at org.hibernate.search.engine.spi.AbstractDocumentBuilder.<init>(AbstractDocumentBuilder.java:174)
	at org.hibernate.search.engine.spi.DocumentBuilderContainedEntity.<init>(DocumentBuilderContainedEntity.java:60)
	at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:396)
	at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:222)
	at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:146)
	at org.hibernate.search.event.impl.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:130)
	at org.hibernate.search.hcore.impl.HibernateSearchIntegrator.integrate(HibernateSearchIntegrator.java:83)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:303)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1750)
	at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
	at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:287)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)

I haven't been able to trace this to its origin.


Affects: 3.1.3, 3.1.4

1 votes, 6 watchers

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 7, 2013

Juergen Hoeller commented

There have been a few refinements in JPA bootstrapping in 3.1.3, in particular with respect to handling a 'default' persistence unit. We haven't heard about any breakages yet though.

What does your LocalContainerEntityManagerFactoryBean definition and your persistence.xml look like, if any?

Juergen

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 7, 2013

marc schipperheyn commented

Persistence

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
	version="1.0">
	<persistence-unit name="ApplicationEntityManager"
		transaction-type="RESOURCE_LOCAL">
		<provider>org.hibernate.ejb.HibernatePersistence</provider>
		<properties>
			<property name="hibernate.hbm2ddl.auto" value="update"/>
            
			<property name="hibernate.generate_statistics" value="true"/>
			<property name="hibernate.cache.use_second_level_cache" value="true"/>
            <property name="hibernate.cache.use_query_cache" value="true"/>
            <property name="hibernate.cache.region_prefix" value="mercadosa"/>
            <property name="hibernate.cache.provider_configuration_file_resource_path" value="/ehcache.xml"/>
			<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory"/>
			<property name="hibernate.search.default.batch.merge_factor" value="1"/>

		</properties>
	</persistence-unit>
</persistence>

 <bean id="dataSource"
     class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
     <property name="targetDataSource">
         <ref local="mainDataSource" />
     </property>
 </bean>
  <bean id="mainDataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
    <property name="driverClass" value="${jdbc.driverClassName}"/>
    <property name="jdbcUrl" value="${jdbc.url}"/>
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
    <property name="idleMaxAgeInMinutes" value="3"/>
    <property name="idleConnectionTestPeriodInMinutes" value="2"/>
    <property name="maxConnectionsPerPartition" value="60"/>
      <property name="minConnectionsPerPartition" value="20"/>
      <property name="partitionCount" value="3"/>
      <property name="acquireIncrement" value="10"/>
      <property name="statementsCacheSize" value="100"/>
      <property name="releaseHelperThreads" value="3"/>
</bean>    
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
	version="1.0">
	<persistence-unit name="ApplicationEntityManager"
		transaction-type="RESOURCE_LOCAL">
		<provider>org.hibernate.ejb.HibernatePersistence</provider>
		<properties>
			<property name="hibernate.hbm2ddl.auto" value="update"/>
            
			<property name="hibernate.generate_statistics" value="true"/>
			<property name="hibernate.cache.use_second_level_cache" value="true"/>
            <property name="hibernate.cache.use_query_cache" value="true"/>
            <property name="hibernate.cache.region_prefix" value="mercadosa"/>
            <property name="hibernate.cache.provider_configuration_file_resource_path" value="/ehcache.xml"/>
			<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory"/>
			<property name="hibernate.search.default.batch.merge_factor" value="1"/>

		</properties>
	</persistence-unit>
</persistence>


   <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
        <property name="hibernateProperties">
            <value>
            	hibernate.bytecode.provider=javaassist
            	hibernate.connection.driver_class=${jdbc.driverClassName}
            	hibernate.connection.is-connection-validation-required=true
            	hibernate.query.factory_class=org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory
            	hibernate.jdbc.batch_size=30
                hibernate.dialect=${hibernate.dialect}
                hibernate.use_sql_comments=false
                hibernate.query.substitutions=true
               	hibernate.generate_statistics=${statistics}
                hibernate.search.default.directory_provider=filesystem
				hibernate.search.default.exclusive_index_use=false 
                hibernate.search.default.locking_strategy=native
                hibernate.search.default.indexBase=${hibsearch.hibernate_index_dir}
                hibernate.search.analyzer=nl.msw.compraventa.dao.hibernate.search.MyStandardAnalyzer
                hibernate.search.autoregister_listeners=true
                hibernate.search.jmx_enabled=true
                hibernate.connection.autoReconnect=true
            	hibernate.connection.autoReconnectForPools=true
            	hibernate.show_sql=${hibernate.show_sql}
	    		hibernate.format_sql=${hibernate.format_sql}
	    		hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
                hibernate.cache.provider_configuration_file_resource_path=/ehcache.xml 
				hibernate.cache.use_query_cache=true
                hibernate.cache.use_second_level_cache=true
                hibernate.cache.region_prefix=
                hibernate.cache.use_structured_entries=false
                hibernate.hbm2ddl.auto=update
            </value>
        </property>
		<property name="entityInterceptor">
			<bean class="nl.project.dao.hibernate.extension.UseIndexInterceptor"/>
		</property>
    </bean>

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jun 27, 2013

marc schipperheyn commented

I've reviewed the initialization process and the reason the occurs is that I had an entityManager reference to org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean and a sessionFactory reference to org.springframework.orm.hibernate4.LocalSessionFactoryBean. Before 3.1.4 the entityManager was being ignored but in 3.1.3 it took precedence of the sessionFactory. As a result only properties defined in persistence.xml are being passed to Hibernate and Hibernate Search. Any properties that are defined in your org.springframework.orm.hibernate4.LocalSessionFactoryBean bean definition are ignored. So, this was a latent configuration error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.