使用 JPA 进行 Hibernate 搜索

发布于 2024-11-17 09:43:38 字数 19676 浏览 2 评论 0原文

我想在 ejb3 项目中使用 hibernate search +JPA,我正在使用 jboss 5 AS 并且出现部署错误,我不知道为什么......

我的实体:

package kz.edu.sdu.sea.apps.ejb.db;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Store;

@Entity
@Indexed
@Table(name="links")
public class Link {
private Long linkId;
private String link;
private String linkText;
private int priority;
private Page page;

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="link_id")
public Long getLinkId() {
    return linkId;
}
public void setLinkId(Long linkId) {
    this.linkId = linkId;
}

public String getLink() {
    return link;
}
public void setLink(String link) {
    this.link = link;
}

@Column(name="link_text")
@Field(index=Index.TOKENIZED, store=Store.NO)
public String getLinkText() {
    return linkText;
}
public void setLinkText(String linkText) {
    this.linkText = linkText;
}

public int getPriority() {
    return priority;
}
public void setPriority(int priority) {
    this.priority = priority;
}

@IndexedEmbedded
@OneToOne
@JoinColumn(name="link_id")
public Page getPage() {
    return page;
}
public void setPage(Page page) {
    this.page = page;
}

}

package kz.edu.sdu.sea.apps.ejb.db;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Store;


@Entity
@Table(name="pages")
public class Page {
private Long pageId;
private String content;
private String title;
private String description;
private Link link;

@Id
@Column(name="page_id")
public Long getPageId() {
    return pageId;
}
public void setPageId(Long pageId) {
    this.pageId = pageId;
}

@Column(columnDefinition="text")
@Field(index=Index.TOKENIZED, store=Store.NO)
public String getContent() {
    return content;
}
public void setContent(String content) {
    this.content = content;
}

@Field(index=Index.TOKENIZED, store=Store.NO)
public String getTitle() {
    return title;
}
public void setTitle(String title) {
    this.title = title;
}

@Column(columnDefinition="text")
@Field(index=Index.TOKENIZED, store=Store.NO)
public String getDescription() {
    return description;
}
public void setDescription(String description) {
    this.description = description;
}

@OneToOne(mappedBy="page")
public Link getLink() {
    return link;
}
public void setLink(Link link) {
    this.link = link;
}
}

错误: 错误 [AbstractKernelController] 安装到启动时出错:name=persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU state=Create java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider 在 org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:151) 在 org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198) 在 org.hibernate.event.EventListeners.processListeners(EventListeners.java:181) 在 org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194) 在 org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1338) 在 org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327) 在 org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867) 在org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669) 在org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132) 在 org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:301) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在 java.lang.reflect.Method.invoke(Method.java:597) 在 org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59) 在 org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150) 在 org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66) 在 org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241) 在 org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) 在org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109) 在 org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70) 在 org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221) 在 org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) 在 org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) 在 org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) 在 org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) 在 org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) 在 org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) 在 org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631) 在 org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) 在 org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082) 在 org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) 在 org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774) 在 org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540) 在org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121) 在 org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51) 在 org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62) 在 org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50) 在 org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171) 在 org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439) 在 org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157) 在 org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178) 在 org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210) 在 org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098) 在 org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) 在 org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631) 在 org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) 在 org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082) 在 org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) 在 org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822) 在 org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553) 在 org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781) 在 org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702) 在 org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117) 在 org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70) 在 org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53) 在 org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361) 在 org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) 在 org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631) 在 org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) 在 org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082) 在 org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) 在 org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822) 在 org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553) 在 org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306) 在 org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271) 在 org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461) 在 org.jboss.Main.boot(Main.java:221) 在 org.jboss.Main$1.run(Main.java:556) 在 java.lang.Thread.run(Thread.java:662) 引起:java.lang.ClassNotFoundException:来自 BaseClassLoader@f1c18{VFSClassLoaderPolicy@1fd96c5{name=vfszip:/opt/jboss-5.1.0.GA/server/default/deploy/ 的 org.hibernate.annotations.common.reflection.MetadataProvider海耳/域=ClassLoaderDomain@504ec1{name=DefaultDomainparentPolicy=BEFOREparent=org.jboss.bootstrap.NoAnnotationURLClassLoader@1de3f2d}根=[MemoryContextHandler@28669459[path=context=vfsmemory://5c4o12v-f20ynd-gpejvsex-1-gpejwdz8-2b real=vfsmemory://5c4o12v-f20ynd-gpejvsex-1-gpejwdz8-2b], DelegatingHandler@5956743[path=sea.ear context=file:/opt/jboss-5.1.0.GA/server/default/deploy/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear], DelegatingHandler@22116869[path=sea.ear/sea-client.jar context=file:/opt/jboss- 5.1.0.GA/服务器/默认/部署/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-client.jar], DelegatingHandler@2234728[path=sea.ear/sea-ejb.jar context=file :/opt/jboss-5.1.0.GA/server/default/deploy/ real=文件:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-ejb.jar], DelegatingHandler@11678023[path=sea.ear/sea-ejb.jar/hibernate- search-3.4.0.Final.jar context=文件:/opt/jboss-5.1.0.GA/server/default/deploy/真实=文件:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-ejb.jar/hibernate-search-3.4.0.Final.jar],DelegatingHandler@12673014[路径= sea.ear/sea-ejb.jar/jsoup-1.6.0.jar context=文件:/opt/jboss-5.1.0.GA/server/default/deploy/real=文件:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-ejb。 jar/jsoup-1.6.0.jar]] delegates=null 导出=[org.jsoup, org.hibernate.search.query.engine.impl, org.hibernate.search.query.engine.spi、org.jsoup.examples、org.hibernate.search、org.hibernate.search.backend.impl.lucene.works、org.hibernate.search.filter、org.hibernate。 search.jpa,org.hibernate.search.query.facet,org.hibernate.search.sandbox.standalone, org.hibernate.search.bridge、org.hibernate.search.backend.impl.jms、org.hibernate.search.backend、org.hibernate.search.spi.internals、org.hibernate.search.annotations、org.hibernate。 search.exception.impl,META-INF.maven.org.hibernate.hibernate-search, org.hibernate.search.store.optimization、kz.edu.sdu.sea.apps.ejb.beans、org.hibernate.search.filter.impl、org.hibernate.search.query.dsl、org.hibernate.search。 spi、kz.edu.sdu.sea.apps.ejb.util、org.hibernate.search.impl、 kz.edu.sdu.sea.apps.ejb.client、org.jsoup.helper、org.hibernate.search.backend.impl.lucene.overrides、org.hibernate.search.store、org.hibernate.search.backend。配置,org.hibernate.search.backend.impl.lucene,org.hibernate.search.exception,org.hibernate.search.query.engine, org.hibernate.search.query.dsl.impl、org.jsoup.parser、org.hibernate.search.engine、org.hibernate.search.backend.impl.blackhole、org.hibernate.search.stat、org.hibernate。 search.backend.impl.jgroups、org.hibernate.search.backend.impl.batchlucene、org.hibernate.search.engine.spi、 org.hibernate.search.jmx、org.jsoup.safety、org.hibernate.search.query.hibernate.impl、org.hibernate.search.util、org.hibernate.search.jpa.impl、org.hibernate.search。 query.collector、kz.edu.sdu.sea.apps.ejb.db、org.hibernate.search.event、 org.hibernate.search.backend.impl、org.jsoup.select、META-INF.maven.org.jsoup.jsoup、org.hibernate.search.bridge.util、org.hibernate.search.cfg、org.hibernate。 search.analyzer、org.hibernate.search.query.fieldcache、META-INF、org.hibernate.search.batchindexing、 org.hibernate.search.engine.impl、org.hibernate.search.query、org.hibernate.search.reader、org.hibernate.search.bridge.builtin、org.jsoup.nodes] NON_EMPTY}} 在 org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:448) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:248) ... 70 更多 04:09:30,231 信息 [TomcatDeployment] 部署,ctxPath=/sea 04:09:30,631 错误 [ProfileServiceBootstrap] 无法加载配置文件:不完整部署摘要(有关详细信息,请参阅以前的错误):

部署缺少依赖项: 部署“jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=ContentFetcherBean,service=EJB3”缺少以下依赖项: 依赖项“”(应处于“已描述”状态,但实际上处于“** UNRESOLVED Demands 'persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU' ”状态) 部署“jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=ContentFetcherBean,service=EJB3_endpoint”缺少以下依赖项: 依赖项“jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=ContentFetcherBean,service=EJB3”(应处于“已配置”状态,但实际上处于“预安装”状态) 部署“jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=ContentFetcherMDB,service=EJB3”缺少以下依赖项: 依赖项“”(应处于“已描述”状态,但实际上处于“未解析”状态要求“jndi:sea/WebCrawlerBean/local-kz.edu.sdu.sea.apps.ejb.client.IWebCrawlerLocal”<强>”) 部署“jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=SearcherBean,service=EJB3”缺少以下依赖项: 依赖项“”(应处于“已描述”状态,但实际上处于“ UNRESOLVED Demands 'persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU' ”状态) 部署“jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=SearcherBean,service=EJB3_endpoint”缺少以下依赖项: 依赖项“jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=SearcherBean,service=EJB3”(应处于“已配置”状态,但实际上处于“预安装”状态) 部署“jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=WebCrawlerBean,service=EJB3”缺少以下依赖项: 依赖项“”(应处于“已描述”状态,但实际上处于“ UNRESOLVED Demands 'persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU' ”状态) 依赖项“”(应处于“已描述”状态,但实际上处于“未解析”状态要求“jndi:sea/ContentFetcherBean/local-kz.edu.sdu.sea.apps.ejb.client.IContentFetcherLocal”* *") 部署“jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=WebCrawlerBean,service=EJB3_endpoint”缺少以下依赖项: 依赖项“jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=WebCrawlerBean,service=EJB3”(应处于“已配置”状态,但实际上处于“预安装”状态)

部署错误: 由于以下原因,部署“”出错: ** 未解决的需求 'persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU' *, * 未解决的需求'jndi:sea/ContentFetcherBean/local-kz.edu.sdu.sea.apps.ejb.client.IContentFetcherLocal' ** 由于以下原因,部署“”出错: ** 未解决的需求 'persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU' ** 由于以下原因,部署“”出错: ** 未解决的需求 'jndi:sea/WebCrawlerBean/local-kz.edu.sdu.sea.apps.ejb.client.IWebCrawlerLocal' ** 由于以下原因,部署“persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU”出现错误:java.lang.ClassNotFoundException:来自 org.hibernate.annotations.common.reflection.MetadataProvider BaseClassLoader@f1c18{VFSClassLoaderPolicy@1fd96c5{name=vfszip:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/domain=ClassLoaderDomain@504ec1{name=DefaultDomainparentPolicy=BEFORE父=org.jboss.bootstrap.NoAnnotationURLClassLoader@1de3f2d}根=[MemoryContextHandler@28669459[路径= context=vfsmemory://5c4o12v-f20ynd-gpejvsex-1-gpejwdz8-2b real=vfsmemory://5c4o12v-f20ynd-gpejvsex-1-gpejwdz8-2b], DelegatingHandler@5956743[path=sea.ear context=file:/opt/jboss-5.1.0.GA/server/default/deploy/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear], DelegatingHandler@22116869[path=sea.ear/sea-client.jar context=file:/opt/jboss- 5.1.0.GA/服务器/默认/部署/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-client.jar], DelegatingHandler@2234728[path=sea.ear/sea-ejb.jar context=file :/opt/jboss-5.1.0.GA/server/default/deploy/ real=文件:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-ejb.jar], DelegatingHandler@11678023[path=sea.ear/sea-ejb.jar/hibernate- search-3.4.0.Final.jar context=文件:/opt/jboss-5.1.0.GA/server/default/deploy/真实=文件:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-ejb.jar/hibernate-search-3.4.0.Final.jar],DelegatingHandler@12673014[路径= sea.ear/sea-ejb.jar/jsoup-1.6.0.jar context=文件:/opt/jboss-5.1.0.GA/server/default/deploy/real=文件:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-ejb。 jar/jsoup-1.6.0.jar]] delegates=null 导出=[org.jsoup, org.hibernate.search.query.engine.impl, org.hibernate.search.query.engine.spi、org.jsoup.examples、org.hibernate.search、org.hibernate.search.backend.impl.lucene.works、org.hibernate.search.filter、org.hibernate。 search.jpa,org.hibernate.search.query.facet,org.hibernate.search.sandbox.standalone, org.hibernate.search.bridge、org.hibernate.search.backend.impl.jms、org.hibernate.search.backend、org.hibernate.search.spi.internals、org.hibernate.search.annotations、org.hibernate。 search.exception.impl,META-INF.maven.org.hibernate.hibernate-search, org.hibernate.search.store.optimization、kz.edu.sdu.sea.apps.ejb.beans、org.hibernate.search.filter.impl、org.hibernate.search.query.dsl、org.hibernate.search。 spi、kz.edu.sdu.sea.apps.ejb.util、org.hibernate.search.impl、 kz.edu.sdu.sea.apps.ejb.client、org.jsoup.helper、org.hibernate.search.backend.impl.lucene.overrides、org.hibernate.search.store、org.hibernate.search.backend。配置,org.hibernate.search.backend.impl.lucene,org.hibernate.search.exception,org.hibernate.search.query.engine, org.hibernate.search.query.dsl.impl、org.jsoup.parser、org.hibernate.search.engine、org.hibernate.search.backend.impl.blackhole、org.hibernate.search.stat、org.hibernate。 search.backend.impl.jgroups、org.hibernate.search.backend.impl.batchlucene、org.hibernate.search.engine.spi、 org.hibernate.search.jmx、org.jsoup.safety、org.hibernate.search.query.hibernate.impl、org.hibernate.search.util、org.hibernate.search.jpa.impl、org.hibernate.search。 query.collector、kz.edu.sdu.sea.apps.ejb.db、org.hibernate.search.event、 org.hibernate.search.backend.impl、org.jsoup.select、META-INF.maven.org.jsoup.jsoup、org.hibernate.search.bridge.util、org.hibernate.search.cfg、org.hibernate。 search.analyzer、org.hibernate.search.query.fieldcache、META-INF、org.hibernate.search.batchindexing、 org.hibernate.search.engine.impl、org.hibernate.search.query、org.hibernate.search.reader、org.hibernate.search.bridge.builtin、org.jsoup.nodes] NON_EMPTY}} 由于以下原因,部署“”出错: ** 未解决的需求 'persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU' **

04:09:30,665 INFO [Http11Protocol] 开始Coyote HTTP/1.1,http-127.0.0.1-8080 04:09:30,706 INFO [AjpProtocol] 在 ajp-127.0.0.1-8009 上启动 Coyote AJP/1.3 04:09:30,722 INFO [ServerImpl] JBoss (微容器) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)] 开始于 1m:5s:228ms

谢谢!!!!

I want to use hibernate search +JPA in ejb3 project, i'm using jboss 5 AS and I have deployment error, i don't know why....

my entities:

package kz.edu.sdu.sea.apps.ejb.db;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Store;

@Entity
@Indexed
@Table(name="links")
public class Link {
private Long linkId;
private String link;
private String linkText;
private int priority;
private Page page;

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="link_id")
public Long getLinkId() {
    return linkId;
}
public void setLinkId(Long linkId) {
    this.linkId = linkId;
}

public String getLink() {
    return link;
}
public void setLink(String link) {
    this.link = link;
}

@Column(name="link_text")
@Field(index=Index.TOKENIZED, store=Store.NO)
public String getLinkText() {
    return linkText;
}
public void setLinkText(String linkText) {
    this.linkText = linkText;
}

public int getPriority() {
    return priority;
}
public void setPriority(int priority) {
    this.priority = priority;
}

@IndexedEmbedded
@OneToOne
@JoinColumn(name="link_id")
public Page getPage() {
    return page;
}
public void setPage(Page page) {
    this.page = page;
}

}

package kz.edu.sdu.sea.apps.ejb.db;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Store;


@Entity
@Table(name="pages")
public class Page {
private Long pageId;
private String content;
private String title;
private String description;
private Link link;

@Id
@Column(name="page_id")
public Long getPageId() {
    return pageId;
}
public void setPageId(Long pageId) {
    this.pageId = pageId;
}

@Column(columnDefinition="text")
@Field(index=Index.TOKENIZED, store=Store.NO)
public String getContent() {
    return content;
}
public void setContent(String content) {
    this.content = content;
}

@Field(index=Index.TOKENIZED, store=Store.NO)
public String getTitle() {
    return title;
}
public void setTitle(String title) {
    this.title = title;
}

@Column(columnDefinition="text")
@Field(index=Index.TOKENIZED, store=Store.NO)
public String getDescription() {
    return description;
}
public void setDescription(String description) {
    this.description = description;
}

@OneToOne(mappedBy="page")
public Link getLink() {
    return link;
}
public void setLink(Link link) {
    this.link = link;
}
}

Error:
ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU state=Create
java.lang.NoClassDefFoundError: org/hibernate/annotations/common/reflection/MetadataProvider
at org.hibernate.search.event.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:151)
at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1338)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132)
at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:301)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121)
at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)
at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
at org.jboss.Main.boot(Main.java:221)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.MetadataProvider from BaseClassLoader@f1c18{VFSClassLoaderPolicy@1fd96c5{name=vfszip:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/ domain=ClassLoaderDomain@504ec1{name=DefaultDomain parentPolicy=BEFORE parent=org.jboss.bootstrap.NoAnnotationURLClassLoader@1de3f2d} roots=[MemoryContextHandler@28669459[path= context=vfsmemory://5c4o12v-f20ynd-gpejvsex-1-gpejwdz8-2b real=vfsmemory://5c4o12v-f20ynd-gpejvsex-1-gpejwdz8-2b], DelegatingHandler@5956743[path=sea.ear context=file:/opt/jboss-5.1.0.GA/server/default/deploy/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear], DelegatingHandler@22116869[path=sea.ear/sea-client.jar context=file:/opt/jboss-5.1.0.GA/server/default/deploy/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-client.jar], DelegatingHandler@2234728[path=sea.ear/sea-ejb.jar context=file:/opt/jboss-5.1.0.GA/server/default/deploy/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-ejb.jar], DelegatingHandler@11678023[path=sea.ear/sea-ejb.jar/hibernate-search-3.4.0.Final.jar context=file:/opt/jboss-5.1.0.GA/server/default/deploy/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-ejb.jar/hibernate-search-3.4.0.Final.jar], DelegatingHandler@12673014[path=sea.ear/sea-ejb.jar/jsoup-1.6.0.jar context=file:/opt/jboss-5.1.0.GA/server/default/deploy/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-ejb.jar/jsoup-1.6.0.jar]] delegates=null exported=[org.jsoup, org.hibernate.search.query.engine.impl, org.hibernate.search.query.engine.spi, org.jsoup.examples, org.hibernate.search, org.hibernate.search.backend.impl.lucene.works, org.hibernate.search.filter, org.hibernate.search.jpa, org.hibernate.search.query.facet, org.hibernate.search.sandbox.standalone, org.hibernate.search.bridge, org.hibernate.search.backend.impl.jms, org.hibernate.search.backend, org.hibernate.search.spi.internals, org.hibernate.search.annotations, org.hibernate.search.exception.impl, META-INF.maven.org.hibernate.hibernate-search, org.hibernate.search.store.optimization, kz.edu.sdu.sea.apps.ejb.beans, org.hibernate.search.filter.impl, org.hibernate.search.query.dsl, org.hibernate.search.spi, kz.edu.sdu.sea.apps.ejb.util, org.hibernate.search.impl, kz.edu.sdu.sea.apps.ejb.client, org.jsoup.helper, org.hibernate.search.backend.impl.lucene.overrides, org.hibernate.search.store, org.hibernate.search.backend.configuration, org.hibernate.search.backend.impl.lucene, org.hibernate.search.exception, org.hibernate.search.query.engine, org.hibernate.search.query.dsl.impl, org.jsoup.parser, org.hibernate.search.engine, org.hibernate.search.backend.impl.blackhole, org.hibernate.search.stat, org.hibernate.search.backend.impl.jgroups, org.hibernate.search.backend.impl.batchlucene, org.hibernate.search.engine.spi, org.hibernate.search.jmx, org.jsoup.safety, org.hibernate.search.query.hibernate.impl, org.hibernate.search.util, org.hibernate.search.jpa.impl, org.hibernate.search.query.collector, kz.edu.sdu.sea.apps.ejb.db, org.hibernate.search.event, org.hibernate.search.backend.impl, org.jsoup.select, META-INF.maven.org.jsoup.jsoup, org.hibernate.search.bridge.util, org.hibernate.search.cfg, org.hibernate.search.analyzer, org.hibernate.search.query.fieldcache, META-INF, org.hibernate.search.batchindexing, org.hibernate.search.engine.impl, org.hibernate.search.query, org.hibernate.search.reader, org.hibernate.search.bridge.builtin, org.jsoup.nodes] NON_EMPTY}}
at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:448)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 70 more
04:09:30,231 INFO [TomcatDeployment] deploy, ctxPath=/sea
04:09:30,631 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

DEPLOYMENTS MISSING DEPENDENCIES:
Deployment "jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=ContentFetcherBean,service=EJB3" is missing the following dependencies:
Dependency "" (should be in state "Described", but is actually in state "** UNRESOLVED Demands 'persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU' ")
Deployment "jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=ContentFetcherBean,service=EJB3_endpoint" is missing the following dependencies:
Dependency "jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=ContentFetcherBean,service=EJB3" (should be in state "Configured", but is actually in state "PreInstall")
Deployment "jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=ContentFetcherMDB,service=EJB3" is missing the following dependencies:
Dependency "" (should be in state "Described", but is actually in state "
UNRESOLVED Demands 'jndi:sea/WebCrawlerBean/local-kz.edu.sdu.sea.apps.ejb.client.IWebCrawlerLocal' ")
Deployment "jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=SearcherBean,service=EJB3" is missing the following dependencies:
Dependency "" (should be in state "Described", but is actually in state "
UNRESOLVED Demands 'persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU' ")
Deployment "jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=SearcherBean,service=EJB3_endpoint" is missing the following dependencies:
Dependency "jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=SearcherBean,service=EJB3" (should be in state "Configured", but is actually in state "PreInstall")
Deployment "jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=WebCrawlerBean,service=EJB3" is missing the following dependencies:
Dependency "" (should be in state "Described", but is actually in state "
UNRESOLVED Demands 'persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU' ")
Dependency "" (should be in state "Described", but is actually in state "
UNRESOLVED Demands 'jndi:sea/ContentFetcherBean/local-kz.edu.sdu.sea.apps.ejb.client.IContentFetcherLocal' **")
Deployment "jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=WebCrawlerBean,service=EJB3_endpoint" is missing the following dependencies:
Dependency "jboss.j2ee:ear=sea.ear,jar=sea-ejb.jar,name=WebCrawlerBean,service=EJB3" (should be in state "Configured", but is actually in state "PreInstall")

DEPLOYMENTS IN ERROR:
Deployment "" is in error due to the following reason(s): ** UNRESOLVED Demands 'persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU' *, * UNRESOLVED Demands 'jndi:sea/ContentFetcherBean/local-kz.edu.sdu.sea.apps.ejb.client.IContentFetcherLocal' **
Deployment "" is in error due to the following reason(s): ** UNRESOLVED Demands 'persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU' **
Deployment "" is in error due to the following reason(s): ** UNRESOLVED Demands 'jndi:sea/WebCrawlerBean/local-kz.edu.sdu.sea.apps.ejb.client.IWebCrawlerLocal' **
Deployment "persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU" is in error due to the following reason(s): java.lang.ClassNotFoundException: org.hibernate.annotations.common.reflection.MetadataProvider from BaseClassLoader@f1c18{VFSClassLoaderPolicy@1fd96c5{name=vfszip:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/ domain=ClassLoaderDomain@504ec1{name=DefaultDomain parentPolicy=BEFORE parent=org.jboss.bootstrap.NoAnnotationURLClassLoader@1de3f2d} roots=[MemoryContextHandler@28669459[path= context=vfsmemory://5c4o12v-f20ynd-gpejvsex-1-gpejwdz8-2b real=vfsmemory://5c4o12v-f20ynd-gpejvsex-1-gpejwdz8-2b], DelegatingHandler@5956743[path=sea.ear context=file:/opt/jboss-5.1.0.GA/server/default/deploy/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear], DelegatingHandler@22116869[path=sea.ear/sea-client.jar context=file:/opt/jboss-5.1.0.GA/server/default/deploy/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-client.jar], DelegatingHandler@2234728[path=sea.ear/sea-ejb.jar context=file:/opt/jboss-5.1.0.GA/server/default/deploy/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-ejb.jar], DelegatingHandler@11678023[path=sea.ear/sea-ejb.jar/hibernate-search-3.4.0.Final.jar context=file:/opt/jboss-5.1.0.GA/server/default/deploy/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-ejb.jar/hibernate-search-3.4.0.Final.jar], DelegatingHandler@12673014[path=sea.ear/sea-ejb.jar/jsoup-1.6.0.jar context=file:/opt/jboss-5.1.0.GA/server/default/deploy/ real=file:/opt/jboss-5.1.0.GA/server/default/deploy/sea.ear/sea-ejb.jar/jsoup-1.6.0.jar]] delegates=null exported=[org.jsoup, org.hibernate.search.query.engine.impl, org.hibernate.search.query.engine.spi, org.jsoup.examples, org.hibernate.search, org.hibernate.search.backend.impl.lucene.works, org.hibernate.search.filter, org.hibernate.search.jpa, org.hibernate.search.query.facet, org.hibernate.search.sandbox.standalone, org.hibernate.search.bridge, org.hibernate.search.backend.impl.jms, org.hibernate.search.backend, org.hibernate.search.spi.internals, org.hibernate.search.annotations, org.hibernate.search.exception.impl, META-INF.maven.org.hibernate.hibernate-search, org.hibernate.search.store.optimization, kz.edu.sdu.sea.apps.ejb.beans, org.hibernate.search.filter.impl, org.hibernate.search.query.dsl, org.hibernate.search.spi, kz.edu.sdu.sea.apps.ejb.util, org.hibernate.search.impl, kz.edu.sdu.sea.apps.ejb.client, org.jsoup.helper, org.hibernate.search.backend.impl.lucene.overrides, org.hibernate.search.store, org.hibernate.search.backend.configuration, org.hibernate.search.backend.impl.lucene, org.hibernate.search.exception, org.hibernate.search.query.engine, org.hibernate.search.query.dsl.impl, org.jsoup.parser, org.hibernate.search.engine, org.hibernate.search.backend.impl.blackhole, org.hibernate.search.stat, org.hibernate.search.backend.impl.jgroups, org.hibernate.search.backend.impl.batchlucene, org.hibernate.search.engine.spi, org.hibernate.search.jmx, org.jsoup.safety, org.hibernate.search.query.hibernate.impl, org.hibernate.search.util, org.hibernate.search.jpa.impl, org.hibernate.search.query.collector, kz.edu.sdu.sea.apps.ejb.db, org.hibernate.search.event, org.hibernate.search.backend.impl, org.jsoup.select, META-INF.maven.org.jsoup.jsoup, org.hibernate.search.bridge.util, org.hibernate.search.cfg, org.hibernate.search.analyzer, org.hibernate.search.query.fieldcache, META-INF, org.hibernate.search.batchindexing, org.hibernate.search.engine.impl, org.hibernate.search.query, org.hibernate.search.reader, org.hibernate.search.bridge.builtin, org.jsoup.nodes] NON_EMPTY}}
Deployment "" is in error due to the following reason(s): ** UNRESOLVED Demands 'persistence.unit:unitName=sea.ear/sea-ejb.jar#SeaPU' **

04:09:30,665 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
04:09:30,706 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
04:09:30,722 INFO [ServerImpl] JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)] Started in 1m:5s:228ms

Thanks!!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼睛会笑 2024-11-24 09:43:38

在我看来,您缺少 hibernate-commons-annotations 依赖项。

Seems to me you are missing the hibernate-commons-annotations dependency.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文