-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Configuring Spring with Hibernate Search
PostPosted: Tue Jul 29, 2008 2:26 pm 
Newbie

Joined: Tue Jul 29, 2008 2:01 pm
Posts: 5
Location: Brasil
Hi.
In my application I have spring-1.2.8, mysql 5, java 1.5, hs 3.0.1, maven 1.2, slackware 11.
My application did not have the follows files: hibernate.cfg.xml, persistence.xml, jpaContact.xml and when I try insert it, nothing happen.
Are ther configuration different of this http://www.hibernate.org/441.html to put my index directory with hibernate search?
My Application

File components.xml.
Code:
<beans>
   <!-- Bring in the HBM related beans beans -->
   <import resource="hibernate-hbms.xml" />

   <!-- Bring in the hibernate related beans -->
   <import resource="spring-hibernate.xml" />
<bean id="indexFactory"
       class="org.hibernate.search.store.FSDirectoryProvider">
       <property name="location">
          <value>/home/iuliana/lucene/index</value>
       </property>
              <property name="hibernate.search.default.indexBase"
       value="/home/iuliana/lucene/index" />

       <property name="hibernate.ejb.event.post-insert"
            value="org.hibernate.search.event.FullTextIndexEventListener" />
       <property name="hibernate.ejb.event.post-update"
            value="org.hibernate.search.event.FullTextIndexEventListener" />
       <property name="hibernate.ejb.event.post-delete"
            value="org.hibernate.search.event.FullTextIndexEventListener" />
    </bean>
</beans>

File hibernate.hbms.xml

Code:
<beans>

   <!-- Add our HBM files to the Sakai global session factory -->
   <bean
      id="org.sakaiproject.tidia.whiteboard.hibernate.AdditionalHibernateMappings"
      class="org.sakaiproject.springframework.orm.hibernate.impl.AdditionalHibernateMappingsImpl">
      <property name="mappingResources">
         <list>
            <value>org/sakaiproject/tidia/whiteboard/hbm/LearningActivityVO.hbm.xml</value>

      </list>
      </property>
   </bean>

</beans>


File spring-hibernate.xml
Code:
<beans>

   <bean id="baseClasses" abstract="true">
      <property name="persistentClasses">
         <list>
            <value>org.sakaiproject.tidia.whiteboard.model.LearningActivityVO</value>
         </list>
      </property>
   </bean>
      
   <!-- create a DAO bean, use the hibernate implementation -->
   <bean id="org.sakaiproject.tidia.whiteboard.dao.ILearningActivityDAOTarget"
         class="org.sakaiproject.tidia.whiteboard.dao.impl.HibernateLearningActivityDAO"
         parent="baseClasses">
      <property name="sessionFactory"
         ref="org.sakaiproject.springframework.orm.hibernate.GlobalSessionFactory" />
   </bean>

   <!-- This wraps our DAO so that the transactions are managed -->
   
   
   <bean id="org.sakaiproject.tidia.whiteboard.dao.ILearningActivityDAO"
         class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
      <property name="transactionManager"
         ref="org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager" />
      <property name="target"
         ref="org.sakaiproject.tidia.whiteboard.dao.ILearningActivityDAOTarget" />
      <property name="transactionAttributes">
         <props>
            <prop key="*">PROPAGATION_REQUIRED</prop>
         </props>
      </property>
   </bean>


Class LearningActivityVO.java
Code:
@Entity
@Indexed(index="indexed/LearningActivityVO")
public class LearningActivityVO extends ObjectVO {

    static final long serialVersionUID = 7858074839098277580L;


    @Field(index=Index.TOKENIZED,store=Store.NO)
    private String description;

    /** Learning activity objective. */
    @Field(index=Index.TOKENIZED,store=Store.NO)
    private String objective;
/* getters and setters */
}



Thanks.

_________________
--------------------
Iuliana Souza


Last edited by iuliana on Thu Aug 07, 2008 3:31 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 30, 2008 7:14 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

the example you are referring to is based on Spring 2.0.3 and you are using 1.2.8. It doesn't surprise me that things do not work out of the box. When you say nothing happens - what do you mean? Is there no log output at all?

I am also not sure about this bean configuration:

Quote:
<bean id="indexFactory"
class="org.hibernate.search.store.FSDirectoryProvider">


Why do you configure the directory provider as a bean? Have you seen this somewhere else? I don't think this is a valid configuration. The directory provider should be set via a simple property:

Code:
hibernate.search.default.directory_provider = org.hibernate.search.store.FSDirectoryProvider


--Hardy


Top
 Profile  
 
 Post subject: integrating spring 2.5 with hibernate search
PostPosted: Thu Jul 31, 2008 2:17 am 
Newbie

Joined: Thu Jul 31, 2008 2:15 am
Posts: 7
Location: LONDON
When i place the @Index annotation on my entity i get the following exception from Spring:

Caused by: org.hibernate.AssertionFailure: could not init listeners
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:199)
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1315)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1304)

I am assuming these are the listeners that update the Lucene Index when deleting, updating, adding an indexable entity? I have searched the and found the example:

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource"/>
<property name="annotatedClasses">
<list>
<value>us.mikedesjardins.persisted.Cheese</value>
<value>us.mikedesjardins.persisted.Milk</value>
<value>us.mikedesjardins.persisted.Origin</value>
<value>us.mikedesjardins.persisted.Texture</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.search.default.indexBase">/home/iuliana/lucene/index</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>
</props>
</property>
<property name="eventListeners">
<map>
<entry key="post-update">
<bean class="org.hibernate.search.event.FullTextIndexEventListener"/>
</entry>
<entry key="post-insert">
<bean class="org.hibernate.search.event.FullTextIndexEventListener"/>
</entry>
<entry key="post-delete">
<bean class="org.hibernate.search.event.FullTextIndexEventListener"/>
</entry>
</map>
</property>

</bean>


But the exception is still being thrown. What is the correct way to register the relevant hibernate event listeners with spring?

Many thanks
Jeremy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 31, 2008 3:56 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

the event configuration looks correct for spring? Since you are using annotations it should however not be required. The annotation jar contains some code which will check whether Hibernate Search is in the classpath and enable it if it is the case.

That said, this only works if you are using the right versions of the required libraries. Which version of Hibernate Core, Annotations and Search are you using? In which environment are you running?

This problem was reported before and in most cases related to version/classpath issues.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 07, 2008 3:50 pm 
Newbie

Joined: Tue Jul 29, 2008 2:01 pm
Posts: 5
Location: Brasil
hardy.ferentschik wrote:
Hi,

the example you are referring to is based on Spring 2.0.3 and you are using 1.2.8. It doesn't surprise me that things do not work out of the box. When you say nothing happens - what do you mean? Is there no log output at all?

I am also not sure about this bean configuration:

Quote:
<bean id="indexFactory"
class="org.hibernate.search.store.FSDirectoryProvider">


Why do you configure the directory provider as a bean? Have you seen this somewhere else? I don't think this is a valid configuration. The directory provider should be set via a simple property:

Code:
hibernate.search.default.directory_provider = org.hibernate.search.store.FSDirectoryProvider


--Hardy


Hi Hardy,

Thanks for your help.
Change a lot of thing starting to my config and .jar files.
I have add the following:
Code:
hibernate-commons-annotations.jar
hibernate3.jar
jboss-common.jar
commons-logging-1.0.4.jar
javassist.jar
commons-collections-2.1.1.jar
and other...
I change my spring version to 2.0.3.
I create the persistence xml like http://www.hibernate.org/441.html and initial give the error: javax.persistence.PersistenceException: No persistence provider for EntityManager named.... Then I put the persistence xml inside META-INF and insert it in .classpath.
Finished. Now its ok.

_________________
--------------------
Iuliana Souza


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.