无法将JavaEE应用程序部署到Glassfish 4.1

时间:2016-05-31 12:33:58

标签: java jpa java-ee glassfish ejb

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

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

该项目建立得很好。但是当尝试将ear文件部署到Glassfish 4.1 Application Server时,我在控制台中收到以下错误消息:

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)

此外,战争项目似乎找不到@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 ]

有人有什么想法我可能做错了吗?

2 个答案:

答案 0 :(得分:1)

可能是您的服务器无法访问netbeans。使用.war文件进行测试,看看服务器是否也出错了。

答案 1 :(得分:0)

  

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