【问题标题】:Cannot deploy JavaEE application to Glassfish 4.1无法将 JavaEE 应用程序部署到 Glassfish 4.1
【发布时间】:2016-09-29 11:29:29
【问题描述】:

我使用 Netbeans 8.1、MySQL Server、Glassfish 4.1、Eclipselink 作为 JPA 提供者、Jersey 作为 JAX-RS 提供者,并尝试部署以下简单过程:

  • 使用 MySQL 连接池和数据源设置 Glassfish 4.1
  • 使用 EJB 和 WAR 模块生成标准 JavaEE 应用程序
  • 添加了一些 @Entity 注释类
  • 在 ejb 和 war-项目中添加了 persistence.xml
  • Netbeans 8.1 从我的实体类中自动生成的 RESTful 类

项目构建得很好。但是当尝试将 ear 文件部署到 Glassfish 4.1 应用服务器时,我在控制台中收到以下错误消息:

GlassFish Server 4.1, deploy, Can not read HTTP response, caught IOException, false
/Users/nicolas/Workspace (Java)/TestProject/nbproject/build-impl.xml:332: The module has not been deployed.
See the server log for details.

在 Glassfish 日志中,我读到以下内容:

Exception while preparing the app : Unable to load the EJB module. DeploymentContext does not contain any EJB. Check the archive to ensure correct packaging for /Users/nicolas/Workspace (Java)/OilImperium/dist/gfdeploy/TestProject/TestProject-war_war. If you use EJB component annotations to define the EJB, and an ejb or web deployment descriptor is also used, please make sure that the deployment descriptor references a Java EE 5 or higher version schema, and that the metadata-complete attribute is not set to true, so the component annotations can be processed as expected java.lang.RuntimeException: Unable to load the EJB module. DeploymentContext does not contain any EJB. Check the archive to ensure correct packaging for /Users/nicolas/Workspace (Java)/TestProject/dist/gfdeploy/TestProject/TestProject-war_war. If you use EJB component annotations to define the EJB, and an ejb or web deployment descriptor is also used, please make sure that the deployment descriptor references a Java EE 5 or higher version schema, and that the metadata-complete attribute is not set to true, so the component annotations can be processed as expected 
at org.glassfish.ejb.startup.EjbDeployer.prepare(EjbDeployer.java:190) 
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:270) 
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(AbstractThreadPool.java:545) 
at java.lang.Thread.run(Thread.java:745)

此外,war-project 似乎找不到 @Entity 类:

Class [ ch/baumgardt/model/Well ] not found. Error while loading [ class service.WellFacadeREST ]

...还有更多:

Class [ ch/baumgardt/model/Player ] not found. Error while loading [ class service.PlayerFacadeREST ]

有人知道我可能做错了什么吗?

【问题讨论】:

    标签: java jpa jakarta-ee glassfish ejb


    【解决方案1】:

    可能是您的服务器无法访问 netbeans 。使用有效的 .war 文件对其进行测试,以查看服务器是否给出相同的错误。

    【讨论】:

      【解决方案2】:

      重新启动 Glassfish 并清理战争和 WEB_INF/lib 文件夹,因为它有时会发生。 `Please Check out 或者您可以在 netbeans 的帮助下创建 Restful Web 服务。 然后创建一个java包 右键单击 CustomerDB 节点并选择新建 > 其他 > Web 服务 > 来自数据库的 RESTful Web 服务。 “新建 RESTful Web 服务”向导将在“数据库表”面板上打开。 我希望它的帮助

      【讨论】:

      • 感谢您的回复。我已经使用了 JDK 8 和 GF 4.1,我尝试了你的建议,但仍然是同样的问题......
      • 感谢您的更新。您发布的那个 sn-p 文本完全来自我完成的教程。但问题似乎出在 Netbeans 或 Glassfish 中……
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多