access a Local Session Bean from another EAR?

人盡茶涼 提交于 2019-11-29 08:35:18

Per 3.2.2 of the EJB 3.1 specification:

Access to an enterprise bean through the local client view is only required to be supported for local clients packaged within the same application as the enterprise bean that provides the local client view. Compliant implementations of this specification may optionally support access to the local client view of an enterprise bean from a local client packaged in a different application. The configuration requirements for inter-application access to the local client view are vendor-specific and are outside the scope of this specification. Applications relying on inter-application access to the local client view are non-portable.

Here is the GlassFish FAQ: I have an EJB component with a Local interface. Can I access it from a web component in a different application?

(That said, you could try packaging your interface such that it is loaded by a ClassLoader that is common to both applications.)

You really don't want to do that. as another answer stated, it's not required to be supported. one of the many reasons it's problematic is because it can cause classloader issues. if you have classes in one ear with references to classes in another ear, all kinds of bad things can happen (e.g. having cross-classloader references which will become invalid if the other ear gets redeployed).

This is the first message I post on Stackoverflow but I admit I read it often. By the way, sorry in advance for my english.

I think I found an alternative solution to this issue :

I have annotated my EJB with @Remote and here's my sun-ejb config.

sun-ejb-jar.xml

  <ejb>
    <ejb-name>XXX</ejb-name>

    <ior-security-config>
        <transport-config>
            <integrity>required</integrity> 
            <confidentiality>required</confidentiality>
            <establish-trust-in-target>supported</establish-trust-in-target>
            <establish-trust-in-client>required</establish-trust-in-client>
        </transport-config>

        <sas-context>
            <caller-propagation>supported</caller-propagation>
        </sas-context>
    </ior-security-config>
  </ejb>

After some tests, it appears that the EJB is not accessible by a client without a known certificate. The others EARs can access to this EJB without any authentication.

Edit: I tried the ClassLoader solution but it's not viable for my project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!