-->
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.  [ 6 posts ] 
Author Message
 Post subject: hibernate-search + hibernate-ogm + infinispan + wildfly 10.1
PostPosted: Tue Mar 21, 2017 8:55 pm 
Newbie

Joined: Mon Mar 20, 2017 7:40 am
Posts: 6
Hello,

I'm trying to use hibernate-search for searching mongodb entries using an infinispan directory provider for the index on wildfly 10.1. https://docs.jboss.org/hibernate/stable/ogm/reference/en-US/html_single/?v=5.1#ogm-configuration-jbossmodule did not work for me (module hibernate.search:5.6 not found). I only got the stack running following the example found on: https://forum.hibernate.org/viewtopic.php?f=31&t=1043482. My current configuration:

POM:
Code:
<version.wildfly>10.1.0.Final</version.wildfly>
<version.wildfly.bom>${version.wildfly}</version.wildfly.bom>
<version.wildfly.hibernate.ogm>5.0.4.Final</version.wildfly.hibernate.ogm>
<version.wildfly.hibernate.orm>5.2.8.Final</version.wildfly.hibernate.orm>
<version.wildfly.infinispan>8.2.5.Final</version.wildfly.infinispan>
...
<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>wildfly-javaee7-with-tools</artifactId>
                <version>${version.wildfly.bom}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>${version.javaee}</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.hibernate.ogm</groupId>
                <artifactId>hibernate-ogm-bom</artifactId>
                <version>${version.wildfly.hibernate.ogm}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.infinispan</groupId>
                <artifactId>infinispan-directory-provider</artifactId>
                <version>${version.wildfly.infinispan}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
...
<plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>${version.maven.dependency.plugin}</version>
                        <inherited>false</inherited>
                        <executions>
                            <execution>
                                <id>unpack</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.hibernate</groupId>
                                            <artifactId>hibernate-orm-modules</artifactId>
                                            <version>${version.wildfly.hibernate.orm}</version>
                                            <classifier>wildfly-10-dist</classifier>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                            <outputDirectory>${jboss.home}/modules</outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.hibernate.ogm</groupId>
                                            <artifactId>hibernate-ogm-modules-wildfly10</artifactId>
                                            <version>${version.wildfly.hibernate.ogm}</version>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                            <outputDirectory>${jboss.home}/modules</outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.infinispan</groupId>
                                            <artifactId>infinispan-as-embedded-modules</artifactId>
                                            <version>${version.wildfly.infinispan}</version>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                            <outputDirectory>${jboss.home}/modules</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

PU:
Code:
<persistence-unit name="seed" transaction-type="JTA">
        <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
        <jar-file>seed-model.jar</jar-file>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="hibernate.search.default.directory_provider"
                      value="infinispan"/
            <property name="hibernate.ogm.datastore.provider"
                      value="mongodb"/>
            <property name="hibernate.ogm.datastore.database"
                      value="seed"/>
        </properties>
</persistence-unit>

MANIFEST
Code:
Dependencies: org.hibernate.ogm:5.0 services, org.hibernate.ogm.infinispan:5.0 services, org.hibernate.ogm.mongodb:5.0 services, org.hibernate.search.orm:5.6 services, org.hibernate.search.engine:5.6 services


Now persisting and searching works as long as I don't restart.

The following should re-index the previously persisted:
Code:
@Singleton
@Startup
public class SeedIndexService {

    private static final Logger logger = Logger.getLogger(SeedService.class.getName());

    private FullTextEntityManager em;

    @PostConstruct
    public void index() {
        try {
            logger.info("Starting indexer for Seed Database...");
            Long start = System.nanoTime();
            this.em.createIndexer().startAndWait();
            Long end = System.nanoTime();
            logger.info("Finished indexing of Seed Database in " + (end - start) * Math.pow(10, -9) + " seconds.");
        } catch (InterruptedException e) {
            logger.severe("Exception during indexing of Seed Database: " + e.getMessage());
        }
    }

    @Inject
    public void setEntityManager(@SeedDatabase FullTextEntityManager entityManager) {
        this.em = entityManager;
    }
}

It runs, stops, does not complain but does not index anything...

Finally my questions:
  • What could be the reason that the "on the fly" indexer knows how to index and the batch indexer does not?
  • Could somebody please provide a working configuration (ogm, search, infinispan, wildfly10.1) with the latest version of ogm?

Thanks!


Top
 Profile  
 
 Post subject: Re: hibernate-search + hibernate-ogm + infinispan + wildfly 10.1
PostPosted: Wed Mar 22, 2017 1:17 pm 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Hi,
can you try to specify the type when you create the indexer?

Like this:
Code:
            this.em.createIndexer( Seed.class ).startAndWait();


Other than that, everything else seems fine


Top
 Profile  
 
 Post subject: Re: hibernate-search + hibernate-ogm + infinispan + wildfly 10.1
PostPosted: Wed Mar 22, 2017 10:50 pm 
Newbie

Joined: Mon Mar 20, 2017 7:40 am
Posts: 6
Hi,

thank you very much. Although the Indexer logs something different (HSEARCH000028: Reindexed 0 entities) I get the expected results now - almost. I get proxies which I have to map manually. Otherwise I get:

Code:
com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.ArrayList[0]->com.serenditree.branch.seed.model.entities.Seed_$$_jvst174_4["handler"])


The method without mapping looks like this:

Code:
public List<Seed> retrieveByRadius(Double radius, Unit unit, Double latitude, Double longitude) {

        logger.fine("Retrieving seeds by radius r:" + radius + " lat:" + latitude + " lon:" + longitude);

        Query searchQuery = this.buildSearchQuery()
                .spatial()
                .within(radius, unit)
                .ofLatitude(latitude)
                .andLongitude(longitude)
                .createQuery();

        return this.em
                .createFullTextQuery(searchQuery, Seed.class)
                .initializeObjectsWith(ObjectLookupMethod.SKIP, DatabaseRetrievalMethod.FIND_BY_ID)
                .getResultList(); //TODO use cache (ObjectLookupMethod.SECOND_LEVEL_CACHE)
    }

    private QueryBuilder buildSearchQuery() {
        return this.em
                .getSearchFactory()
                .buildQueryBuilder()
                .forEntity(Seed.class)
                .get();
    }


This is more or less taken 1:1 from a book on Hibernate 5... What am I missing?


Top
 Profile  
 
 Post subject: Re: hibernate-search + hibernate-ogm + infinispan + wildfly 10.1
PostPosted: Mon Mar 27, 2017 10:28 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
It seems there is a problem with the dependecies.

ORM 5.2 is not compatible with OGM 5.0, I would recommend to pickj Hibernate OGM 5.1.0.FInal with Hibernate ORM 5.1.4.Final.

WildFly 10 also won't use a different ORM version by default, you will need to set the following property to make sure that the right version of ORM and Hibernate Search is picked up correctly:

Code:
wildfly.jpa.hibernate.search.module = org.hibernate.search.orm:5.6.1.Final-orm51


This part of the documentation should give more details about the dependencies to use: https://docs.jboss.org/hibernate/stable ... bossmodule

By the way, instead of Inifinipsan could let me know if with a different indexing provider it works? Filesystem for example.

Thanks,
Davide


Top
 Profile  
 
 Post subject: Re: hibernate-search + hibernate-ogm + infinispan + wildfly 10.1
PostPosted: Mon Mar 27, 2017 3:50 pm 
Newbie

Joined: Mon Mar 20, 2017 7:40 am
Posts: 6
Hi,

I have followed the instructions you pointed at in combination with the same section of the hibernate search docs. I still haven't found a working configuration with orm/ogm 5.1.x... I don't know why, but the combination of ogm 5.0.4 and orm 5.2.8 works... I have to stash this issue for now:

Code:
+<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
+    <deployment>
+        <dependencies>
+            <module name="org.hibernate.ogm" slot="5.1" services="export" />
+            <module name="org.hibernate.ogm.mongodb" slot="5.1" services="export" />
+            <module name="org.hibernate.ogm.infinispan" slot="5.1" services="export" />
+            <module name="org.hibernate.search.orm" slot="5.6" services="export" />
+            <module name="org.hibernate.search.engine" slot="5.6" services="export" />
+        </dependencies>
+        <exclusions>
+            <module name="org.javassist" />
+        </exclusions>
+    </deployment>
+</jboss-deployment-structure>


pom:
Code:
-        <version.wildfly.hibernate.ogm>5.0.4.Final</version.wildfly.hibernate.ogm>
-        <version.wildfly.hibernate.orm>5.2.8.Final</version.wildfly.hibernate.orm>
+        <version.wildfly.hibernate.ogm>5.1.0.Final</version.wildfly.hibernate.ogm>
+        <version.wildfly.hibernate.orm>5.1.4.Final</version.wildfly.hibernate.orm>
+        <version.wildfly.hibernate.search>5.6.1.Final</version.wildfly.hibernate.search>
         <version.wildfly.infinispan>8.2.5.Final</version.wildfly.infinispan>
         <version.wildfly.arquillian.container.managed>8.2.1.Final</version.wildfly.arquillian.container.managed>

@@ -351,21 +352,31 @@
                                         <artifactItem>
                                             <groupId>org.hibernate</groupId>
                                             <artifactId>hibernate-orm-modules</artifactId>
-                                            <version>${version.wildfly.hibernate.orm}</version>
                                             <classifier>wildfly-10-dist</classifier>
+                                            <version>${version.wildfly.hibernate.orm}</version>
                                             <type>zip</type>
                                             <overWrite>false</overWrite>
                                             <outputDirectory>${jboss.home}/modules</outputDirectory>
                                         </artifactItem>
                                         <artifactItem>
                                             <groupId>org.hibernate.ogm</groupId>
-                                            <artifactId>hibernate-ogm-modules-wildfly10</artifactId>
+                                            <artifactId>hibernate-ogm-modules</artifactId>
+                                            <classifier>wildfly-10-dist</classifier>
                                             <version>${version.wildfly.hibernate.ogm}</version>
                                             <type>zip</type>
                                             <overWrite>false</overWrite>
                                             <outputDirectory>${jboss.home}/modules</outputDirectory>
                                         </artifactItem>
                                         <artifactItem>
+                                            <groupId>org.hibernate</groupId>
+                                            <artifactId>hibernate-search-modules</artifactId>
+                                            <classifier>wildfly-10-dist</classifier>
+                                            <version>${version.wildfly.hibernate.search}</version>
+                                            <type>zip</type>
+                                            <overWrite>false</overWrite>
+                                            <outputDirectory>${jboss.home}/modules</outputDirectory>
+                                        </artifactItem>
+                                        <artifactItem>
                                             <groupId>org.infinispan</groupId>
                                             <artifactId>infinispan-as-embedded-modules</artifactId>
                                             <version>${version.wildfly.infinispan}</version>


persistence
Code:
+            <property name="jboss.as.jpa.providerModule"
+                      value="org.hibernate:5.1"/>
+            <property name="wildfly.jpa.hibernate.search.module"
+                      value="org.hibernate.search.orm:5.6"/>


I've also tried your version (org.hibernate.search.orm:5.6.1.Final-orm51):
NameNotFoundException: ---PlaceHolderDSForOGM---

With org.hibernate.search.orm:5.6:
java.util.ServiceConfigurationError: org.hibernate.integrator.spi.Integrator: Provider org.hibernate.search.hcore.impl.HibernateSearchIntegrator not a subtype

The indexing without specifying the class also did not work with filesystem directory provider... I've already tried that before.

Thank you very much for your help. At least I have a configuration I can work with at the moment.


Top
 Profile  
 
 Post subject: Re: hibernate-search + hibernate-ogm + infinispan + wildfly 10.1
PostPosted: Tue Mar 28, 2017 5:05 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Would you be able to publish this project on GItHub?
This way I can have a look


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