-->
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.  [ 11 posts ] 
Author Message
 Post subject: Hibernate Search on Seam
PostPosted: Tue Apr 10, 2007 3:40 am 
Newbie

Joined: Tue Dec 19, 2006 5:22 am
Posts: 4
Location: Karlstad, Sweden
A while ago I started working on a Hib. search / Seam solution. Everything seemed to work nicelly as far as I got. I needed to drop that project for some time I now when I got back to I can't get the listeners up and running.

I've added the following to my persistence.xml:
Code:
<property name="hibernate.search.default.directory_provider"   value="org.hibernate.search.store.FSDirectoryProvider"/>
<property name="hibernate.search.default.indexBase"            value="C:/luceneIndex"/>


Which I thought would be enough. No need for events or need to create a configuration instance in the code.

I get org.hibernate.HibernateException: Lucene event listener not initialized when I try to run the following:

Code:
       EntityManagerImpl emi = ((EntityManagerImpl) em.getDelegate());
        Session session = emi.getSession();
       
        FullTextSession fullTextSession = Search.createFullTextSession(session);
        Transaction tx = fullTextSession.beginTransaction();
       
        List<LogEntry> allLogs = em.createQuery("FROM LogEntry")
        .getResultList();
       
        for (LogEntry log : allLogs) {
            fullTextSession.index(log);
        }
        tx.commit();


I've got an entity with the @Indexed annotation and some @Field for testing.

It seems like the listeners are never initialized - the lucene index folder isn't created.

I've got the following jar files in my EAR:
    * hibernate-annotations.jar
    * hibernate-search.jar
    * lucene-core-2.1.0.jar
    * and a bunch of seam related stuff


The Hibernate and Lucene jars are registered in my application.xml file.

What am I missing out here?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 10, 2007 6:12 am 
Newbie

Joined: Mon Nov 13, 2006 11:22 am
Posts: 5
Location: Graz / Austria
maybe your missing hibernate-commons-annotations.jar


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 10, 2007 6:50 am 
Newbie

Joined: Tue Dec 19, 2006 5:22 am
Posts: 4
Location: Karlstad, Sweden
Thank you, it works like a charm now :-)

This is what I've done to make Hiberate Search to start indexing Seam stuff:

* Make sure you got the right versions of the jar-files in \jboss-4.0.5.GA\server\default\lib I had old hibernate files there, and needed to change them for new files. The compatibility matrix ( http://www.hibernate.org/6.html#A3 ) helped me.

* If you for some reason got the hiberate-all.jar file there - remove it

* Add the following files to your EAR: hibernate-search.jar, hibernate-commons-annotations.jar and lucene-core-2.1.0.jar and make sure to create references to them in application.xml

* Make changes to persistence.xml, add
<property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSDirectoryProvider"/>
<property name="hibernate.search.default.indexBase" value="C:\luceneIndex"/>

The folder wasn't created automatically for me, but after adding it myself, it worked nicelly.

* Add @Indexed and other annotations to your entities. Note! If you read the docs ( http://www.hibernate.org/hib_docs/searc ... figuration ) it says @Indexed(name="Status"), which is wrong. The correct syntax follows in the doc (@Indexed(index="Status"))

This is my experience and perhaps not the right way to, but it finally worked, perhaps this could be of help to someone else.

//Frippuz


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 5:24 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Nice,
Can you create a wiki page out of you experience. We plan to make HSearch work smoother with Seam but in the mean time...

_________________
Emmanuel


Top
 Profile  
 
 Post subject: trouble with seam + hibernate search
PostPosted: Mon May 07, 2007 8:50 pm 
Newbie

Joined: Mon May 07, 2007 8:37 pm
Posts: 15
Hi,

May I could get some help here. I tried to use Seam and Hibernate Search together but I couldn't get it to work. This is the Entity I am trying to index:


@Entity
@Name("user")
@Indexed(index="user")
public class User implements java.io.Serializable {
...

// used as a alias on the site (ok to have space, some punctuation)
@Column(name = "screenName", nullable = false, unique = true)
@NotNull
@Length(max = 30)
@Field(name="screenName", index= Index.UN_TOKENIZED, store = Store.YES)
private String screenName;
...
}

In persistence.xml:

<property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSDirectoryProvider"/>
<property name="hibernate.search.default.indexBase" value="C:\temp\luceneIndex"/>

According to the instruction on this thread, I put hibernate-search.jar (3.0.0.beta1), hibernate-commons-annotations.jar (3.0.0GA) and lucene-core-2.1.0.jar into ear file, and put their references in application.xml. The rest of hibernate jars are under jboss/server/default/lib. The hibernate core jar version is 3.2.2. I then manually created c:\temp\luceneIndex\user which was where the index was supposed to be. After I created a User from the app, nothing happens in the directory. There was no log indicating errors or indexing ever happened.

What did I do wrong?

Thanks.

Tux


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 08, 2007 5:48 am 
Newbie

Joined: Tue Dec 19, 2006 5:22 am
Posts: 4
Location: Karlstad, Sweden
did you forget the @DocumentId on your entity's primary key?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 08, 2007 8:55 am 
Newbie

Joined: Mon May 07, 2007 8:37 pm
Posts: 15
I did have @DocumentId, in the following form:


@Id @GeneratedValue
@Column(name = "id", unique = true, nullable = false)
@NotNull
@DocumentId
private Long id;


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 08, 2007 9:22 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Not working is pretty vague, but did you follow those 2 steps?

Code:
* Make sure you got the right versions of the jar-files in \jboss-4.0.5.GA\server\default\lib I had old hibernate files there, and needed to change them for new files. The compatibility matrix ( http://www.hibernate.org/6.html#A3 ) helped me.

* If you for some reason got the hiberate-all.jar file there - remove it

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 08, 2007 2:42 pm 
Newbie

Joined: Mon May 07, 2007 8:37 pm
Posts: 15
I was happy too early. After I switched to the latest hibernate jars, the index directory was created when I started the app (which was a step forward and I thought everything was fine and dandy). But no entity was indexed. For example, there would be a "user" directory under indexBase, but when I add user the new user would not get indexed.

I use EntityHome's persist() method which fires off PersistEvent, does Hibernate search listens to this event or how do I hook up this event to Hibernate search?

Thanks again.

Tux


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 13, 2007 3:58 pm 
Newbie

Joined: Sun May 13, 2007 3:55 pm
Posts: 1
Did you solve your problem? Because I'd like to know too. Thanks.

Erik


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 1:27 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
If the directory are created but nothing is indexed, it might be because you don't commit the transaction after persisting.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 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.