是否有可能使用GlassFish在domain1 / lib中拥有EJB? [英] Is it possible to have EJBs in domain1/lib using GlassFish?

查看:119
本文介绍了是否有可能使用GlassFish在domain1 / lib中拥有EJB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  @Local 
公用介面SomeService {
...
}

@Singleton
公共类SomeServiceBean实现SomeService {
...
}

当我将接口和类放入.war档案(即在domain1 / autodeplay中)时,一切正常。然而,当我把接口和类放入单独的.jar文件(即在domain1 / lib中)时,我部署了war应用程序:

  java.lang.RuntimeException:无法解析引用Local ejb-ref name = com.temp.MyServlet / someService,Local 3.x interface = com.temp.SomeService,ejb-link = null,lookup =,mappedName =,jndi -name =,refType = Session 
at com.sun.enterprise.deployment.util.ComponentValidator.accept(ComponentValidator.java:374)〜[dol.jar:na]
at com.sun.enterprise .deployment.util.DefaultDOLVisitor.accept(DefaultDOLVisitor.java:78)〜[dol.jar:na]
at com.sun.enterprise.deployment.util.ComponentValidator.accept(ComponentValidator.java:123)〜[ dol.jar:na]
at com.sun.enterprise.deployment.util.ApplicationValidator.accept(ApplicationValidator.java:152)〜[dol.jar:n
...

我不使用任何xml描述符。那么,是否有可能在domain1 / lib中拥有EJB,如果是,如何让EJB容器找到它们?附:我尝试在GF 4中完成 - 结果是一样的。

解决方案

EJB不能作为库添加到GlassFish中,库只是添加到类路径中,并且它们上的任何注释都将被忽略,并且它们不会通过EJB容器。如果您确实希望将EJB作为单独的JAR,则可以像WAR或EAR文件一样部署它们。




<= c $ c> add-library 命令的Glassfish参考手册它说它将库添加到类加载器目录,而对于 deploy 命令,它说应用程序可以是...... EJB模块。



另外,通过查看 Glassfish的源代码,可以发现,所有库都可以在启动时简单地添加到Classloader中(参见这里这里 ),或者如果在applib中,那么当应用程序被部署时(参见他重新)。


I use GlassFish 4 web profile and I have the following interface and class.

@Local
public interface SomeService {
...
}

@Singleton
public class SomeServiceBean implements SomeService {
...
}

When I put interface and class in .war archive (that is in domain1/autodeplay) everything works fine. However, when I put interface and class in separate .jar archive (that is in domain1/lib) then deploying war application I get:

java.lang.RuntimeException: Cannot resolve reference Local ejb-ref name=com.temp.MyServlet/someService,Local 3.x interface =com.temp.SomeService,ejb-link=null,lookup=,mappedName=,jndi-name=,refType=Session
    at com.sun.enterprise.deployment.util.ComponentValidator.accept(ComponentValidator.java:374) ~[dol.jar:na]
    at com.sun.enterprise.deployment.util.DefaultDOLVisitor.accept(DefaultDOLVisitor.java:78) ~[dol.jar:na]
    at com.sun.enterprise.deployment.util.ComponentValidator.accept(ComponentValidator.java:123) ~[dol.jar:na]
    at com.sun.enterprise.deployment.util.ApplicationValidator.accept(ApplicationValidator.java:152) ~[dol.jar:n
    ...

I don't use any xml descriptors. So, is it possible to have EJBs in domain1/lib and if yes, how to make EJB container find them? P.S. I tried in GF 4 full - result is the same.

解决方案

EJBs cannot be added as a library to GlassFish, libraries are just added to the classpath and any annotations on them are ignored and they do not go through the EJB container. If you do want your EJBs as a seperate JAR, they can be deployed just like a WAR or EAR file.


In the Glassfish reference manual for the add-library command it says that it "adds the library to the class loader directory", while for the deploy command it says that "Applications can be...EJB modules".

Also by looking at the source code for Glassfish it can be worked out that all libraries are simply added to the Classloader either at launch (See here and here) or if in applibs then when the application is deployed (See here).

这篇关于是否有可能使用GlassFish在domain1 / lib中拥有EJB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆