Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 934089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:56:29+00:00 2026-05-15T20:56:29+00:00

I have spent the last few days attempting to integrate a Grails (version 1.3.2)

  • 0

I have spent the last few days attempting to integrate a Grails (version 1.3.2) application with an EJB 2.1 application that is deployed on WebSphere 6.1. Once our grails apps are in production, they will be deployed to WebSphere as well. The EJB 2.1 application is widely used across our company and, in anything except a local development environment, is deployed to its own cluster. The way we handle this in our existing Java EE applications (all of which are non-Spring, non-Grails) is to bind a CORBA CosNaming Naming Context within each of our other clusters that can then be used to obtain references to our shared EJB 2.1 application. So, up to this point, if one of our application needed to interact with this application, they would do so using an approach like this:

String cosNameBinding = "ejbApp.HighAvail.cluster";
InitialContext initial = new InitialContext();
Context fedContext = (javax.naming.Context) initialCtx.lookup(cosNameBinding);

Then do the normal EJB-style lookup/narrow/invoke using the federated/CosNaming context:

Object ejbHomeAsObject = fedContext.lookup(jndiNameOfService);        
EJBHome home = (EJBHome) PortableRemoteObject.narrow(ejbHomeAsObject, homeClass);
Object service = invokeMethod(homeClass, home, "create");

As you can see, there is a level of indirection that occurs here in order to go from the InitialContext to the federated naming Context that can be used to interact with the shared EJB application.

Running locally, I have both the Grails application and the EJB application deployed to the same server (non network deployment WAS, same profile&node). I have Spring configured like so:

beans = {
        ejbJndi(org.springframework.jndi.JndiTemplate) {
            environment = ["java.naming.factory.initial" : 
                           "com.ibm.websphere.naming.WsnInitialContextFactory"]
        }
        crewMemberService(org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean) {
            jndiName="hotelService/ejb/HotelService"
            businessInterface="com.company.appName.hotel.HotelService"
            lookupHomeOnStartup="false"
            cacheHome="false"
            refreshHomeOnConnectFailure="true"
            jndiTemplate = ref("ejbJndi")
        }
}

And I can successfully inject ejb references into my Grails controllers and invoke them. However, WebSphere can only resolve the JNDI lookup because they are both deployed on the same server. When we move it to one of our development environments, we’ll need jndi lookups for these services to go against the federated naming context.

So my questions are:

  1. Is there a way to do this with the classes that are provided within Spring and if so could you give me an idea of how I would need up modify my Spring config to do so?
  2. Given that there is no flexibility around how we deploy the other app or gain references to its services (we must use the federated context), should I consider extending JndiTemplate and do the necessary wiring myself?

If anyone has faced this situation I would be most appreciative for any insights you may be able to offer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:56:30+00:00Added an answer on May 15, 2026 at 8:56 pm

    In case anyone has this same question down the road, I ended up implementing an extension to Spring’s JndiTemplate and using that. Here is the code:

    public class FederatedJndiTemplate extends org.springframework.jndi.JndiTemplate
    {
        protected static final String JNDI_CONTEXT_BINDING_NAME = "fed.context.jndiName";
    
        /**
         * Obtain a JNDI naming context for the specified federated naming context.
         * 
         * @throws NamingException if no "fed.context.jndiName" has been specified in
         * the environment properties for the jndiTemplate or the container throws a naming
         * exception.
         */
        @Override
        protected Context createInitialContext() throws NamingException {
            Properties props = super.getEnvironment();
    
            if(!props.containsKey(JNDI_CONTEXT_BINDING_NAME)) {
                throw new NamingException("You must specify the federated naming context JNDI binding name");
            }
    
            String jndiBinding = props.getProperty(JNDI_CONTEXT_BINDING_NAME);
            InitialContext initCtx = new InitialContext();
            Context fedCtx = (Context) initCtx.lookup(jndiBinding);
            return fedCtx;
        }
    }
    

    Then inside my resources.groovy, I just used this JndiTemplate:

                ejbJndi(com.myCompany.spring.jndi.FederatedJndiTemplate) {
                        environment = [
                            "fed.context.jndiName":"myServices.HighAvail.Cluster"]
                }
                hotelService(org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean) {
                    jndiName="hotelService/ejb/HotelService"
                    businessInterface="com.mycompany.appName.hotel.HotelService"
                    homeInterface="com.mycompany.appName.hotel.HotelServiceHome"
                    lookupHomeOnStartup="false"
                    jndiTemplate = ref("ejbJndi")
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've spent the last few days banging my head and searching Google and have
I have spent the last few days playing around with Drupal for the first
I have spent the last few days trying to parse a SOAP response but
I've spent the last few days putting together a game that runs as an
I have spent the last few days trying to look up how to use
I have spent last 3 days until I got gps working on android using
I have spent the last couple of days to use Core Plot for the
I've spent the last few evenings researching version control applications, mostly here on SO
I've spent so much time the last few days trying to work out some
I have been searching through SO for the last few days and have found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.