Issue Type: Bug Bug
Affects Versions: 4.1.1.Final
Assignee: Unassigned
Attachments: allbridge.zip
Components: engine
Created: 15/Jan/13 10:33 AM
Description:

I am not sure, if you consider this as a bug or as invalid usage.
But in my view (the view of a user) it is clearly a bug.

I have implemented a custom bridge, that collects all fields of associated classes, that are named "ALL". The goal is, to create an all-field, that spans the parent-class and all its associated classes.

The custom bridge works fine for all "normal" fields of the parent class and the first associated class.

But if the associated class contains another associated class, a LazyInitializationException is raised, when indexing with MassIndexer.startAndWait():

HSEARCH000116: Unexpected error during MassIndexer operation
org.hibernate.search.bridge.BridgeException: Exception while calling bridge#set
class: de.juplo.allbridge.test.b.Foo
path: bar
at org.hibernate.search.bridge.util.impl.ContextualExceptionBridgeHelper.buildBridgeException(ContextualExceptionBridgeHelper.java:97)
at org.hibernate.search.bridge.util.impl.ContextualExceptionBridgeHelper$OneWayConversionContextImpl.set(ContextualExceptionBridgeHelper.java:126)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.buildDocumentFields(DocumentBuilderIndexedEntity.java:533)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.getDocument(DocumentBuilderIndexedEntity.java:478)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.createAddWork(DocumentBuilderIndexedEntity.java:401)
at org.hibernate.search.batchindexing.impl.EntityConsumerLuceneWorkProducer.index(EntityConsumerLuceneWorkProducer.java:172)
at org.hibernate.search.batchindexing.impl.EntityConsumerLuceneWorkProducer.indexAllQueue(EntityConsumerLuceneWorkProducer.java:132)
at org.hibernate.search.batchindexing.impl.EntityConsumerLuceneWorkProducer.run(EntityConsumerLuceneWorkProducer.java:102)
at org.hibernate.search.batchindexing.impl.OptionallyWrapInJTATransaction.run(OptionallyWrapInJTATransaction.java:112)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: de.juplo.allbridge.test.b.Bar.foobars, no session or session was closed
at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:393)
at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:385)
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:378)
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:112)
at org.hibernate.collection.internal.PersistentSet.toString(PersistentSet.java:326)
at de.juplo.allbridge.AllBridge.handleField(AllBridge.java:185)
at de.juplo.allbridge.AllBridge.recursion(AllBridge.java:106)
at de.juplo.allbridge.AllBridge.set(AllBridge.java:65)
at org.hibernate.search.bridge.util.impl.ContextualExceptionBridgeHelper$OneWayConversionContextImpl.set(ContextualExceptionBridgeHelper.java:123)
... 10 more

I suspect, that the Exception might also be thrown, when indexing an not fully initalized entity asynchronously.

Nevertheless, the little project in the attachement calls MassIndexer.startAndWait() to demonstrate the issue.

This bug might be related to https://hibernate.onjira.com/browse/HSEARCH-689

Project: Hibernate Search
Labels: hibernate search massIndexer indexing
Priority: Major Major
Reporter: Kai Moritz
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira