ClassCastException:Hibernate Search上的Lucene40PostingsFormat

时间:2016-08-31 22:13:02

标签: lucene classcastexception hibernate-search java-ee-7 glassfish-4

我正在尝试使用Hibernate-Search添加全文搜索功能,但是当我尝试在glashfish应用服务器上部署ear proyect时,我得到了Lucene40PostingsFormat classCastException。

这是完整的服务器日志:

Información:   HHH000412: Hibernate Core {[WORKING]}
Información:   HHH000206: hibernate.properties not found
Información:   HHH000021: Bytecode provider name : javassist
Información:   HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
Información:   HHH000400: Using dialect: org.hibernate.dialect.DerbyDialect
WARN:   HHH000430: The DerbyDialect dialect has been deprecated; use one of the version-specific dialects instead
Información:   HSEARCH000034: Hibernate Search 5.5.4.Final
Información:   HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@50ae9aef'
Grave:   java.lang.ExceptionInInitializerError
    at org.apache.lucene.codecs.PostingsFormat.forName(PostingsFormat.java:112)
    at org.apache.lucene.codecs.lucene40.Lucene40Codec.<init>(Lucene40Codec.java:115)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at java.lang.Class.newInstance(Class.java:442)
    at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:67)
    at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:45)
    at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:37)
    at org.apache.lucene.codecs.Codec$Holder.<clinit>(Codec.java:47)
    at org.apache.lucene.codecs.Codec.getDefault(Codec.java:140)
    at org.apache.lucene.index.LiveIndexWriterConfig.<init>(LiveIndexWriterConfig.java:120)
    at org.apache.lucene.index.IndexWriterConfig.<init>(IndexWriterConfig.java:140)
    at org.hibernate.search.store.spi.DirectoryHelper.initializeIndexIfNeeded(DirectoryHelper.java:54)
    at org.hibernate.search.store.impl.DirectoryProviderHelper.createFSIndex(DirectoryProviderHelper.java:128)
    at org.hibernate.search.store.impl.FSDirectoryProvider.initialize(FSDirectoryProvider.java:53)
    at org.hibernate.search.store.spi.BaseDirectoryProviderService.initialize(BaseDirectoryProviderService.java:64)
    at org.hibernate.search.store.spi.BaseDirectoryProviderService.create(BaseDirectoryProviderService.java:52)
    at org.hibernate.search.indexes.spi.DirectoryBasedIndexManager.createDirectoryProvider(DirectoryBasedIndexManager.java:230)
    at org.hibernate.search.indexes.spi.DirectoryBasedIndexManager.initialize(DirectoryBasedIndexManager.java:90)
    at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:256)
    at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:513)
    at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManagers(IndexManagerHolder.java:482)
    at org.hibernate.search.indexes.impl.IndexManagerHolder.buildEntityIndexBinding(IndexManagerHolder.java:91)
    at org.hibernate.search.spi.SearchIntegratorBuilder.initDocumentBuilders(SearchIntegratorBuilder.java:358)
    at org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory(SearchIntegratorBuilder.java:199)
    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:364)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:490)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:878)
    at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:151)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:199)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:107)
    at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:223)
    at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
    at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:230)
    at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925)
    at org.glassfish.javaee.full.deployment.EarDeployer.prepareBundle(EarDeployer.java:309)
    at org.glassfish.javaee.full.deployment.EarDeployer.access$200(EarDeployer.java:88)
    at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:155)
    at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:152)
    at org.glassfish.javaee.full.deployment.EarDeployer.doOnBundles(EarDeployer.java:232)
    at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllTypedBundles(EarDeployer.java:241)
    at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllBundles(EarDeployer.java:267)
    at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:152)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:434)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
    at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(Abstra
Grave:   ctThreadPool.java:545)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: class org.apache.lucene.codecs.lucene40.Lucene40PostingsFormat
    at java.lang.Class.asSubclass(Class.java:3404)
    at org.apache.lucene.util.SPIClassIterator.next(SPIClassIterator.java:141)
    at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:65)
    at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:47)
    at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:37)
    at org.apache.lucene.codecs.PostingsFormat$Holder.<clinit>(PostingsFormat.java:49)
    ... 89 more
Grave:   Exception while preparing the app
Grave:   Exception during lifecycle processing
java.lang.ExceptionInInitializerError
    at org.apache.lucene.codecs.PostingsFormat.forName(PostingsFormat.java:112)
    at org.apache.lucene.codecs.lucene40.Lucene40Codec.<init>(Lucene40Codec.java:115)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at java.lang.Class.newInstance(Class.java:442)
    at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:67)
    at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:45)
    at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:37)
    at org.apache.lucene.codecs.Codec$Holder.<clinit>(Codec.java:47)
    at org.apache.lucene.codecs.Codec.getDefault(Codec.java:140)
    at org.apache.lucene.index.LiveIndexWriterConfig.<init>(LiveIndexWriterConfig.java:120)
    at org.apache.lucene.index.IndexWriterConfig.<init>(IndexWriterConfig.java:140)
    at org.hibernate.search.store.spi.DirectoryHelper.initializeIndexIfNeeded(DirectoryHelper.java:54)
    at org.hibernate.search.store.impl.DirectoryProviderHelper.createFSIndex(DirectoryProviderHelper.java:128)
    at org.hibernate.search.store.impl.FSDirectoryProvider.initialize(FSDirectoryProvider.java:53)
    at org.hibernate.search.store.spi.BaseDirectoryProviderService.initialize(BaseDirectoryProviderService.java:64)
    at org.hibernate.search.store.spi.BaseDirectoryProviderService.create(BaseDirectoryProviderService.java:52)
    at org.hibernate.search.indexes.spi.DirectoryBasedIndexManager.createDirectoryProvider(DirectoryBasedIndexManager.java:230)
    at org.hibernate.search.indexes.spi.DirectoryBasedIndexManager.initialize(DirectoryBasedIndexManager.java:90)
    at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:256)
    at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManager(IndexManagerHolder.java:513)
    at org.hibernate.search.indexes.impl.IndexManagerHolder.createIndexManagers(IndexManagerHolder.java:482)
    at org.hibernate.search.indexes.impl.IndexManagerHolder.buildEntityIndexBinding(IndexManagerHolder.java:91)
    at org.hibernate.search.spi.SearchIntegratorBuilder.initDocumentBuilders(SearchIntegratorBuilder.java:358)
    at org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory(SearchIntegratorBuilder.java:199)
    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:364)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:490)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:878)
    at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:151)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:199)
    at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:107)
    at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:223)
    at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:510)
    at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:230)
    at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925)
    at org.glassfish.javaee.full.deployment.EarDeployer.prepare

ejb模块的pom文件的依赖关系如下:

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.2.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-search-orm</artifactId>
        <version>5.5.4.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>5.0.9.Final</version>
    </dependency>
</dependencies>

如果我在hibernate-search工件上排除了工件lucene-backward-codecs,我会收到错误:

java.lang.ClassCastException: class org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat

<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-search-orm</artifactId>
   <version>${hibernate.search.version}</version>
   <exclusions>
     <exclusion>  <!-- declare the exclusion here -->
        <groupId>org.apache.lucene</groupId>
        <artifactId>lucene-backward-codecs</artifactId>
     </exclusion>
   </exclusions> 
</dependency>

持久性单元配置如下:

 <?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="ejercicio4_PU" transaction-type="JTA">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <jta-data-source>jdbc/books</jta-data-source>
    <class>models.Book</class>
    <class>models.Author</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
      <property name="hibernate.search.lucene_version" value="LUCENE_CURRENT"/>
      <property name="hibernate.search.default.directory_provider" value="filesystem"/>
      <property name="hibernate.search.default.indexBase" value="./lucene/indexes"/>
      <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.SunOneJtaPlatform"/>
      <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
    </properties>
  </persistence-unit>
</persistence>

我使用了plugin-finder duplicate-maven-plugin 找到可能的不同版本的lucene

<plugin>
  <groupId>com.ning.maven.plugins</groupId>
  <artifactId>maven-duplicate-finder-plugin</artifactId>
  <version>1.0.8</version>
  <executions>
     <execution>
          <phase>verify</phase>
          <goals>
             <goal>check</goal>
          </goals>
     </execution>
  </executions>
</plugin>

这是构建项目所得结果的摘录:

Checking compile classpath

    Found duplicate and different classes in [javax:javaee-api:7.0,org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final] :
      javax.persistence.Access
      javax.persistence.AccessType
      javax.persistence.AssociationOverride
      javax.persistence.AssociationOverrides
      javax.persistence.AttributeConverter
      javax.persistence.AttributeNode
      javax.persistence.AttributeOverride
      javax.persistence.AttributeOverrides
      javax.persistence.Basic
      javax.persistence.Cache
      javax.persistence.CacheRetrieveMode
      javax.persistence.CacheStoreMode
      javax.persistence.Cacheable
      javax.persistence.CascadeType
      javax.persistence.CollectionTable
      javax.persistence.Column
      javax.persistence.ColumnResult
      javax.persistence.ConstraintMode
      javax.persistence.ConstructorResult
      javax.persistence.Convert
      javax.persistence.Converter
      javax.persistence.Converts
      javax.persistence.DiscriminatorColumn
      javax.persistence.DiscriminatorType
      javax.persistence.DiscriminatorValue
      javax.persistence.ElementCollection
      javax.persistence.Embeddable
      javax.persistence.Embedded
      javax.persistence.EmbeddedId
      javax.persistence.Entity
      javax.persistence.EntityExistsException
      javax.persistence.EntityGraph
      javax.persistence.EntityListeners
      javax.persistence.EntityManager
      javax.persistence.EntityManagerFactory
      javax.persistence.EntityNotFoundException
      javax.persistence.EntityResult
      javax.persistence.EntityTransaction
      javax.persistence.EnumType
      javax.persistence.Enumerated
      javax.persistence.ExcludeDefaultListeners
      javax.persistence.ExcludeSuperclassListeners
      javax.persistence.FetchType
      javax.persistence.FieldResult
      javax.persistence.FlushModeType
      javax.persistence.ForeignKey
      javax.persistence.GeneratedValue
      javax.persistence.GenerationType
      javax.persistence.Id
      javax.persistence.IdClass
      javax.persistence.Index
      javax.persistence.Inheritance
      javax.persistence.InheritanceType
      javax.persistence.JoinColumn
      javax.persistence.JoinColumns
      javax.persistence.JoinTable
      javax.persistence.Lob
      javax.persistence.LockModeType
      javax.persistence.LockTimeoutException
      javax.persistence.ManyToMany
      javax.persistence.ManyToOne
      javax.persistence.MapKey
      javax.persistence.MapKeyClass
      javax.persistence.MapKeyColumn
      javax.persistence.MapKeyEnumerated
      javax.persistence.MapKeyJoinColumn
      javax.persistence.MapKeyJoinColumns
      javax.persistence.MapKeyTemporal
      javax.persistence.MappedSuperclass
      javax.persistence.MapsId
      javax.persistence.NamedAttributeNode
      javax.persistence.NamedEntityGraph
      javax.persistence.NamedEntityGraphs
      javax.persistence.NamedNativeQueries
      javax.persistence.NamedNativeQuery
      javax.persistence.NamedQueries
      javax.persistence.NamedQuery
      javax.persistence.NamedStoredProcedureQueries
      javax.persistence.NamedStoredProcedureQuery
      javax.persistence.NamedSubgraph
      javax.persistence.NoResultException
      javax.persistence.NonUniqueResultException
      javax.persistence.OneToMany
      javax.persistence.OneToOne
      javax.persistence.OptimisticLockException
      javax.persistence.OrderBy
      javax.persistence.OrderColumn
      javax.persistence.Parameter
      javax.persistence.ParameterMode
      javax.persistence.Persistence
      javax.persistence.PersistenceContext
      javax.persistence.PersistenceContextType
      javax.persistence.PersistenceContexts
      javax.persistence.PersistenceException
      javax.persistence.PersistenceProperty
      javax.persistence.PersistenceUnit
      javax.persistence.PersistenceUnitUtil
      javax.persistence.PersistenceUnits
      javax.persistence.PersistenceUtil
      javax.persistence.PessimisticLockException
      javax.persistence.PessimisticLockScope
      javax.persistence.PostLoad
      javax.persistence.PostPersist
      javax.persistence.PostRemove
      javax.persistence.PostUpdate
      javax.persistence.PrePersist
      javax.persistence.PreRemove
      javax.persistence.PreUpdate
      javax.persistence.PrimaryKeyJoinColumn
      javax.persistence.PrimaryKeyJoinColumns
      javax.persistence.Query
      javax.persistence.QueryHint
      javax.persistence.QueryTimeoutException
      javax.persistence.RollbackException
      javax.persistence.SecondaryTable
      javax.persistence.SecondaryTables
      javax.persistence.SequenceGenerator
      javax.persistence.SharedCacheMode
      javax.persistence.SqlResultSetMapping
      javax.persistence.SqlResultSetMappings
      javax.persistence.StoredProcedureParameter
      javax.persistence.StoredProcedureQuery
      javax.persistence.Subgraph
      javax.persistence.SynchronizationType
      javax.persistence.Table
      javax.persistence.TableGenerator
      javax.persistence.Temporal
      javax.persistence.TemporalType
      javax.persistence.TransactionRequiredException
      javax.persistence.Transient
      javax.persistence.Tuple
      javax.persistence.TupleElement
      javax.persistence.TypedQuery
      javax.persistence.UniqueConstraint
      javax.persistence.ValidationMode
      javax.persistence.Version
      javax.persistence.criteria.AbstractQuery
      javax.persistence.criteria.CollectionJoin
      javax.persistence.criteria.CommonAbstractCriteria
      javax.persistence.criteria.CompoundSelection
      javax.persistence.criteria.CriteriaBuilder
      javax.persistence.criteria.CriteriaDelete
      javax.persistence.criteria.CriteriaQuery
      javax.persistence.criteria.CriteriaUpdate
      javax.persistence.criteria.Expression
      javax.persistence.criteria.Fetch
      javax.persistence.criteria.FetchParent
      javax.persistence.criteria.From
      javax.persistence.criteria.Join
      javax.persistence.criteria.JoinType
      javax.persistence.criteria.ListJoin
      javax.persistence.criteria.MapJoin
      javax.persistence.criteria.Order
      javax.persistence.criteria.ParameterExpression
      javax.persistence.criteria.Path
      javax.persistence.criteria.PluralJoin
      javax.persistence.criteria.Predicate
      javax.persistence.criteria.Root
      javax.persistence.criteria.Selection
      javax.persistence.criteria.SetJoin
      javax.persistence.criteria.Subquery
      javax.persistence.metamodel.Attribute
      javax.persistence.metamodel.BasicType
      javax.persistence.metamodel.Bindable
      javax.persistence.metamodel.CollectionAttribute
      javax.persistence.metamodel.EmbeddableType
      javax.persistence.metamodel.EntityType
      javax.persistence.metamodel.IdentifiableType
      javax.persistence.metamodel.ListAttribute
      javax.persistence.metamodel.ManagedType
      javax.persistence.metamodel.MapAttribute
      javax.persistence.metamodel.MappedSuperclassType
      javax.persistence.metamodel.Metamodel
      javax.persistence.metamodel.PluralAttribute
      javax.persistence.metamodel.SetAttribute
      javax.persistence.metamodel.SingularAttribute
      javax.persistence.metamodel.StaticMetamodel
      javax.persistence.metamodel.Type
      javax.persistence.spi.ClassTransformer
      javax.persistence.spi.LoadState
      javax.persistence.spi.PersistenceProvider
      javax.persistence.spi.PersistenceProviderResolver
      javax.persistence.spi.PersistenceProviderResolverHolder
      javax.persistence.spi.PersistenceUnitInfo
      javax.persistence.spi.PersistenceUnitTransactionType
      javax.persistence.spi.ProviderUtil

我正在使用Glassfish服务器4.1和Netbeans 8.0.2。

我希望有人可以帮助我,谢谢。

1 个答案:

答案 0 :(得分:2)

您遇到的错误是尝试打开由Apache Lucene版本 4.0.x 编写的Lucene索引的结果。

如果您使用使用Lucene 4的旧版Hibernate Search迁移应用程序,那么我建议删除索引并使用MassIndexer重建它。

如果您因任何原因需要阅读旧的索引格式,可以将以下依赖项添加到您的应用程序中以便能够阅读它:

<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-backward-codecs</artifactId>
    <version>5.3.1</version>
</dependency>

另外 - 不相关但会给你带来麻烦 - 我看到你已经将 hibernate-core hibernate-entitymanager 设置为两个不同的版本:永远不要这样做! 由于Hibernate Search还不兼容Hibernate ORM 5.2.x,我建议将这两个版本设置为5.1.1.Final,这些版本与Hibernate Search 5.5.4.Final兼容。