eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
387 stars 146 forks source link

appclient lookup of remote ejb using ejb-link uses invalid jndi name #25219

Open starksm64 opened 1 week ago

starksm64 commented 1 week ago

Environment Details


Problem Description

The https://github.com/jakartaredhat/gf-appclient-jndi.git has an appclient that accesses a remote ejb using jndi. The reference to the ejb is specfified via the application-client.xml ejb-ref/ejb-link. The test launches the appclient using the target/glassfish8/glassfish/bin/appclient script and the unpackaged test ear contents. This mimics what is done in the EE platform tck appclient tests.

This fails with a jndi look up error that indicates although the ejb is found, the jndi name that is associated with the java:comp/env/ejb/StatelessVehicleBean local binding is "#ejb.VehicleIF" rather than the full name of "ejb_vehicle_StatelessVehicleBean#ejb.VehicleIF" as indicated in the server.log.

There is a target/appclient-0.log produced by running the test. The following can be found in that log:

[2024-11-20 08:52:05] F org.glassfish.naming Clearing map of proxies: {} 
[2024-11-20 08:52:05] F com.sun.enterprise.naming.impl.JavaURLContext lookup(name=java:comp/env/ejb/StatelessVehicleBean); this=JavaURLContext[] 
[2024-11-20 08:52:05] F com.sun.enterprise.naming.impl.JavaURLContext Computed fullname=java:comp/env/ejb/StatelessVehicleBean for name=java:comp/env/ejb/StatelessVehicleBean 
[2024-11-20 08:52:05] F com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl lookup(componentId=client_stateless_vehicle_client_client.RemoteEjbClient, name=java:comp/env/ejb/StatelessVehicleBean, ctx=javax.naming.InitialContext@1f3165e7) 
[2024-11-20 08:52:05] F com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl Found componentIdInfo=ComponentIdInfo[appName=jpa_core_EntityGraph_vehicle_client, module=jpa_core_EntityGraph_vehicle_client, componentId=client_stateless_vehicle_client_client.RemoteEjbClient, treatComponentAsModule=false] 
[2024-11-20 08:52:05] F com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl getNamespace(info, logicalJndiName=java:comp/env/ejb/StatelessVehicleBean) 
[2024-11-20 08:52:05] F com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl For java:comp/env/ejb/StatelessVehicleBean found object=com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbReferenceProxy@150ede8b in namespace.name=client_stateless_vehicle_client_client.RemoteEjbClient 
[2024-11-20 08:52:05] C com.sun.logging.LogDomains Registered new logger: com.sun.logging.LogDomainsLogger@26221bad[name=jakarta.enterprise.system.container.ejb.com.sun.ejb, level=null, bundleName=com.sun.logging.enterprise.system.container.ejb.LogStrings] 
[2024-11-20 08:52:05] F org.glassfish.common.util.GlassfishUrlClassLoader loadClass(name=ejb.VehicleIF, resolve=false) 
[2024-11-20 08:52:05] F org.glassfish.naming lookup(name=#ejb.VehicleIF level=0) 

Steps to reproduce

  1. git clone https://github.com/jakartaredhat/gf-appclient-jndi.git
  2. cd gf-appclient-jndi
  3. mvn test

Impact of Issue

This is a current block in the JPA platform tests that use an appclient vehicle

kaido207 commented 3 days ago

ejb-link can only access the EJB in the same application[]. ejb-link can reference another JAR using #, but that JAR must reside within the same application (within the EAR file). ) Eclipse GlassFish Application Development Guide """

  1. Deploy the calling application. The calling EJB or web component must specify in its glassfish-ejb-jar.xml or glassfish-web.xml file the JNDI name of the EJB component in the dependent application. Using an ejb-link mapping does not work when the EJB component being called resides in another application. """

As an alternative to using <lookup-name> mentioned in the original issue, there is <mapped-name> for resolving jndi names.

         <ejb-ref-type>Session</ejb-ref-type>
         <remote>ejb.VehicleIF</remote>
-        <ejb-link>StatelessVehicleBean</ejb-link>
+        <mapped-name>ejb_vehicle_StatelessVehicleBean</mapped-name>
     </ejb-ref>

With the above changes, the gf-appclient-jndi passes correctly.

[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]