本文介绍了如何将Netbeans的EJB模块部署到Glassfish的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! Netbeans如何从部署到Glassfish中,如何将 @Stateless 和 @Remote EJB模块? Netbeans能够这样做,但这是如何在IDE之外完成的? 服务器日志: thufir @ dur:〜$ thufir @ dur:〜$ tail glassfish-4.1 / glassfish / domains / domain1 / logs / server.log -n 34 at java.lang.Thread.run(Thread.java:744)]] [2014-09-22T01:41:57.266-0700] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid:_ThreadID = 42 _ThreadName = admin-listener(5)] [timeMillis :1411375317266] [levelValue:1000] [[部署应用程序时出现异常[HelloEJB]:无效的ejb jar [HelloEJB]:它包含零ejb。 注意: 1.有效的ejb jar需要至少一个会话,实体(1.x / 2.x样式)或消息驱动bean。 2. EJB3 +实体bean(@Entity)是POJO,请将它们打包为库jar。 3.如果jar文件包含用EJB组件级别注释(@Stateless,@Stateful,@MessageDriven,@Singleton)进行注释的有效EJB,请检查server.log以查看注释是否已正确处理。] ] [2014-09-22T03:52:08.027-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid:_ThreadID = 40 _ThreadName = admin-listener(3)] [timeMillis:1411383128027] [levelValue:800] [[访问未访问的引用]] [2014-09-22T03:52:08.067-0700 ] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid:_ThreadID = 40 _ThreadName = admin-listener(3)] [timeMillis:1411383128067] [levelValue:800] [[ 访问未访问引用]] [2014-09-22T03:52:08.511-0700] [glassfish 4.1] [INFO] [AS-EJB-00054] [javax.enterprise.ejb .container] [tid:_ThreadID = 40 _ThreadName = admin-listener(3)] [timeMillis:1411383128511] [levelValue:800] [[ EJB Hello的可移植JNDI名称Bean:[java:global / HelloEJB / HelloBean,java:global / HelloEJB / HelloBean!hello.HelloBeanRemote]]] [2014-09-22T03:52:08.513-0700] [glassfish 4.1] [INFO] [AS-EJB-00055] [javax.enterprise.ejb.container] [tid:_ThreadID = 40 _ThreadName = admin-listener(3)] [timeMillis:1411383128513] [levelValue:800] [[ Glassfish特定的(不可移植的)EJB HelloBean的JNDI名称:[hello.HelloBeanRemote#hello.HelloBeanRemote,hello.HelloBeanRemote]]] [2014-09-22T03:52:09.142-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid:_ThreadID = 40 _ThreadName = admin-listener(3)] [timeMillis:1411383129142] [levelValue:900] [[ WELD -000411:Observer方法[BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType< Object>)接收所有注释类型的事件。考虑限制使用@WithAnnotations的事件或带有界限的泛型。]] [2014-09-22T03:52:09.152-0700] [glassfish 4.1] [WARN] [] [org.jboss。 weld.Event] [tid:_ThreadID = 40 _ThreadName = admin-listener(3)] [timeMillis:1411383129152] [levelValue:900] [[ WELD-000411:Observer method [BackedAnnotatedMethod] private org.glassfish.jersey .gf.cdi.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType< Object>)接收所有注释类型的事件。考虑限制事件使用@WithAnnotations或带有界限的泛型。]] [2014-09-22T03:52:09.157-0700] [glassfish 4.1] [警告] [] [org.jboss。 weld.Event] [tid:_ThreadID = 40 _ThreadName = admin-listener(3)] [timeMillis:1411383129157] [levelValue:900] [[ WELD-000411:Observer method [BackedAnnotatedMethod] org.glassfish.sse。 impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType< Object> ;, BeanManager)接收所有注释类型的事件。考虑使用@WithAnnotations限制事件或带有限制的泛型类型。]] [2014-09-22T03:52:10.646-0700] [glassfish 4.1] [INFO] [] [javax.enterprise。 system.core] [tid:_ThreadID = 40 _ThreadName = admin-listener(3)] [timeMillis:1411383130646] [levelValue:800] [[ HelloEJB以2,783毫秒成功部署]] thufir @ dur:〜 包装hello; import javax.ejb.Stateless; @Stateless 公共类HelloBean实现了HelloBeanRemote { @Override public String hi(){ returnhello world; } @Override public String bye(){ returngoodbye; } } 包装你好; import javax.ejb.Remote; @Remote public interface HelloBeanRemote { public String hi(); public String bye(); 另请参阅: 如果EJB模块依赖于某些其他jar文件,则部署独立EJB模块不起作用 - 这些jar文件被忽略,并且未将部署到服务器,从而导致ClassNotFound EJB模块中的异常。类似的情况出现在AppClient中。 从未运行过,自早期的4.x NB 版本出现问题。 解决方法是在EAR 项目或命令行中部署EJB模块及其所需的JAR,例如。 部署独立EJB 模块的glassfishv3 / bin / asadmin部署 --library projs / JavaLibrary1 / dist / JavaLibrary1.jar projs / EJBModule2 / dist / EJBModule2.jarEJBModule2.jar及其所需库JavaLibrary1 .jar。 https://netbeans.org/bugzilla/show_bug.cgi?id=186331 是否影响HelloEJB的部署? HelloEAR的代码几乎完全一样,唯一的区别在于,它是在Netbeans中以 Enterprise Application 的形式在 EJB模块 HelloEAR-ejb 而不是 HelloEJB 作为 EJB模块。 如果模块不能部署到glassfish,它们用于什么?正在使用一个 EJB模块一个死胡同,一个错误的路径来部署 @Stateless 和 @Remote EJB?解决方案尝试执行相同的EJB模块,但通过Enterprise创建它应用。选择新建项目> Java EE>企业应用程序。您可以取消选择Web应用程序模块选项,只保留选中的创建EJB模块选项。编写EJB之后,在您的Entrerprise应用程序上单击左键并选择部署。 此视频可以为您提供帮助。 How is a Netbeans @Stateless and @Remote EJB deployed to Glassfish from an EJB module?Netbeans is able to do so, but how is this accomplished outside of the IDE?server log:thufir@dur:~$thufir@dur:~$ tail glassfish-4.1/glassfish/domains/domain1/logs/server.log -n 34 at java.lang.Thread.run(Thread.java:744)]][2014-09-22T01:41:57.266-0700] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=42 _ThreadName=admin-listener(5)] [timeMillis: 1411375317266] [levelValue: 1000] [[ Exception while deploying the app [HelloEJB] : Invalid ejb jar [HelloEJB]: it contains zero ejb.Note:1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean.2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar.3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.]][2014-09-22T03:52:08.027-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383128027] [levelValue: 800] [[ visiting unvisited references]][2014-09-22T03:52:08.067-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383128067] [levelValue: 800] [[ visiting unvisited references]][2014-09-22T03:52:08.511-0700] [glassfish 4.1] [INFO] [AS-EJB-00054] [javax.enterprise.ejb.container] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383128511] [levelValue: 800] [[ Portable JNDI names for EJB HelloBean: [java:global/HelloEJB/HelloBean, java:global/HelloEJB/HelloBean!hello.HelloBeanRemote]]][2014-09-22T03:52:08.513-0700] [glassfish 4.1] [INFO] [AS-EJB-00055] [javax.enterprise.ejb.container] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383128513] [levelValue: 800] [[ Glassfish-specific (Non-portable) JNDI names for EJB HelloBean: [hello.HelloBeanRemote#hello.HelloBeanRemote, hello.HelloBeanRemote]]][2014-09-22T03:52:09.142-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383129142] [levelValue: 900] [[ WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]][2014-09-22T03:52:09.152-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383129152] [levelValue: 900] [[ WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]][2014-09-22T03:52:09.157-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383129157] [levelValue: 900] [[ WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]][2014-09-22T03:52:10.646-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411383130646] [levelValue: 800] [[ HelloEJB was successfully deployed in 2,783 milliseconds.]]thufir@dur:~$package hello;import javax.ejb.Stateless;@Statelesspublic class HelloBean implements HelloBeanRemote { @Override public String hi() { return "hello world"; } @Override public String bye() { return "goodbye"; }}package hello;import javax.ejb.Remote;@Remotepublic interface HelloBeanRemote { public String hi(); public String bye();}see also: Deploying standalone EJB module does not work if EJB module depends on some other jar files - these jars files are ignored and not deployed to server which consequently will result in ClassNotFound exception from EJB module. Similar situation is in AppClient. This has never ever worked and the problem exists since early 4.x NB versions. The workaround is to deploy EJB module and its required JARs in EAR project or use command line, eg. "glassfishv3/bin/asadmin deploy --libraries projs/JavaLibrary1/dist/JavaLibrary1.jar projs/EJBModule2/dist/EJBModule2.jar" which deploys standalone EJB module EJBModule2.jar and its required library JavaLibrary1.jar.https://netbeans.org/bugzilla/show_bug.cgi?id=186331Is that bug effecting the deploy of HelloEJB? The code for HelloEAR is almost exactly the same, the only difference being that it was created in Netbeans as an Enterprise Application with an EJB module of HelloEAR-ejb rather than HelloEJB as an EJB module.If module's can't be deployed to glassfish, what are they used for? Is using an EJB module a dead-end, a false path towards deploying an @Stateless and @Remote EJB? 解决方案 Try to do the same EJB module but creating it through an Enterprise Application. Select New Project > Java EE > Enterprise Application. You can unselect the option "Web Application Module" and only leave selected the option "Create EJB Module". After to code your EJBs left click on your Entrerprise App and select "Deploy". This video can help you. 这篇关于如何将Netbeans的EJB模块部署到Glassfish的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-11 06:14