Hibernate JPA maven

时间:2013-05-21 14:47:18

标签: hibernate jpa glassfish

我想将Hibernate用作glassfish服务器的JPA提供程序。 我在maven中添加了hiberante-entitymanager依赖,但每次运行项目时我都会遇到此错误。我错过了另一种依赖。

  

严重:部署应用程序时出现异常[JobManager-ear]严重:   无效的ejb jar [JobManager-ejb-1.0-SNAPSHOT.jar]:它包含零   EJB。注意:   1.有效的ejb jar至少需要一个会话,实体(1.x / 2.x样式)或消息驱动的bean。   2. EJB3 +实体bean(@Entity)是POJO,请将它们打包为库jar。   3.如果jar文件包含使用EJB组件级别注释注释的有效EJB(@Stateless,@ Stateful,@ MessageDriven,   @Singleton),请检查server.log以查看是否有注释   处理得当。 java.lang.IllegalArgumentException:无效   ejb jar [JobManager-ejb-1.0-SNAPSHOT.jar]:它包含零ejb。   注意:   1.有效的ejb jar至少需要一个会话,实体(1.x / 2.x样式)或消息驱动的bean。   2. EJB3 +实体bean(@Entity)是POJO,请将它们打包为库jar。   3.如果jar文件包含使用EJB组件级别注释注释的有效EJB(@Stateless,@ Stateful,@ MessageDriven,   @Singleton),请检查server.log以查看是否有注释   处理得当。在   com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:76)     在   com.sun.enterprise.deployment.util.ApplicationValidator.accept(ApplicationValidator.java:128)     在   com.sun.enterprise.deployment.EjbBundleDescriptor.visit(EjbBundleDescriptor.java:730)     在   com.sun.enterprise.deployment.Application.visit(Application.java:1765)     在   com.sun.enterprise.deployment.archivist.ApplicationArchivist.validate(ApplicationArchivist.java:830)     在   com.sun.enterprise.deployment.archivist.ApplicationArchivist.openWith(ApplicationArchivist.java:277)     在   com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:240)     在   org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:175)     在   org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:94)     在   com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:827)     在   com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:769)     在   com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:368)     在   com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)     在   org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl $ 1.execute(CommandRunnerImpl.java:348)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl.access $ 1200(CommandRunnerImpl.java:95)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl $ ExecutionContext.execute(CommandRunnerImpl.java:1291)     在   com.sun.enterprise.v3.admin.CommandRunnerImpl $ ExecutionContext.execute(CommandRunnerImpl.java:1259)     在   com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)     在   com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)     在   com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)     在   com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)     在   com.sun.enterprise.v3.services.impl.ContainerMapper $ Hk2DispatcherCallable.call(ContainerMapper.java:354)     在   com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)     在   com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)     在   com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)     在   com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)     在   com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)     在   com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)     在   com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)     在   com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)     在   com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)     在   com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)     在   com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)     在com.sun.grizzly.ContextTask.run(ContextTask.java:71)at   com.sun.grizzly.util.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:532)     在   com.sun.grizzly.util.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:513)     在java.lang.Thread.run(Thread.java:722)

这是pom.xml内容:

<dependencies>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.1.10.Final</version>
    </dependency>
    <dependency>
        <groupId>antlr</groupId>
        <artifactId>antlr</artifactId>
        <version>2.7.7</version>
    </dependency>
    <dependency>
        <groupId>dom4j</groupId>
        <artifactId>dom4j</artifactId>
        <version>1.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.common</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>4.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.1.10.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.15.0-GA</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.1.0.GA</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.spec.javax.transaction</groupId>
        <artifactId>jboss-transaction-api_1.1_spec</artifactId>
        <version>1.0.0.Final</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
请帮忙。

1 个答案:

答案 0 :(得分:0)

<dependency>
    <groupId>org.hibernate.javax.persistence</groupId>
    <artifactId>hibernate-jpa-2.0-api</artifactId>
    <version>1.0.1.Final</version>
</dependency>

将以上Maven资源库用于JPA。