access a Local Session Bean from another EAR?

前端 未结 3 1438
深忆病人
深忆病人 2020-12-18 14:05

How can I call a Local Session Bean inside an EAR from another EAR, both deployed in the same Glassfish v3 domain?

This is the structure:

G         


        
相关标签:
3条回答
  • 2020-12-18 14:26

    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.)

    0 讨论(0)
  • 2020-12-18 14:40

    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

    0 讨论(0)
  • 2020-12-18 14:47

    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).

    0 讨论(0)
提交回复
热议问题