简体   繁体   中英

Adding hibernate-search to dependencies of existing system causes NoSuchFieldException

I am currently in the process of adding hibernate-search to a big, existing project, but have already encountered a problem I can't seem to figure out.

My problem boils down to being introduced only by adding the maven dependencies for hibernate-search:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-search-orm</artifactId>
  <version>5.5.5.Final</version>
</dependency>
<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-entitymanager</artifactId>
  <version>5.0.11.Final</version>
</dependency>

As soon as I add this to my pom.xml, build the project and try to run it, I get the following exception (this is only the last part):

Caused by: java.lang.NoSuchFieldError: LATEST
at org.hibernate.search.cfg.Environment.<clinit>(Environment.java:213)
at org.hibernate.search.spi.SearchIntegratorBuilder.createCleanFactoryState(SearchIntegratorBuilder.java:280)
at org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory(SearchIntegratorBuilder.java:186)
at org.hibernate.search.spi.SearchIntegratorBuilder.buildSearchIntegrator(SearchIntegratorBuilder.java:117)
at org.hibernate.search.hcore.impl.HibernateSearchSessionFactoryObserver.sessionFactoryCreated(HibernateSearchSessionFactoryObserver.java:75)
at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:520)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:465)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:416)
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:401)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1641)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
... 123 more

So, first I just tried to google it, but it seems nobody else has ever encountered this problem in this setting before. So instead I try to dig into the code and see what this LATEST might be.

Following the exception, I find the following code:

    static {
        DEFAULT_LUCENE_MATCH_VERSION = Version.LATEST;
        DEFAULT_SERVICES_MAP = CollectionHelper.newHashMap(1);
        DEFAULT_SERVICES_MAP.put(IndexManagerFactory.class, DefaultIndexManagerFactory.class.getName());
    }

Then I check out Versions.LATEST, and it turns out there is no LATEST defined in Versions.

So my question is, since I assume this is a problem with my configuration, is there something i'm missing or have incorrectly configured?

Since I can't find anything about this problem anywhere so far, I'm guessing I need something else / more set up before this works, but I can't seem to find out what. I've tried following the getting started guide on the hibernate-search website without any luck.

Anyone have any ideas?

问题发生在Hibernate Search 5.11.1上,我通过从3.6.2版到5.5.5更新到Apache Lucene解决了这个问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM