Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
starksm64 opened this issue Nov 20, 2024 · 1 comment
Open
Assignees
Labels
8.0 Issues that happen only on GlassFish 8 and not in version 7

Comments

@starksm64
Copy link
Member

Environment Details

  • GlassFish Version (and build number): 8.0.0-JDK17-M7
  • JDK version: Temurin-17.0.4.1+1
  • OS: macos 12.7.6

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

@dmatej dmatej self-assigned this Nov 24, 2024
@kaido207
Copy link
Contributor

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
"""
4. 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] 

@OndroMih OndroMih added the 8.0 Issues that happen only on GlassFish 8 and not in version 7 label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.0 Issues that happen only on GlassFish 8 and not in version 7
Projects
None yet
Development

No branches or pull requests

4 participants