EJB3 Dependency Injection call to remote server INS syntax problem - Websphere

This is a discussion on EJB3 Dependency Injection call to remote server INS syntax problem - Websphere ; I want to use DI (or manual JNDI lookup) in an EJB3 service to call another EJB3 service on another server. By default WAS generates short and long form interface bindings which include the package qualified interface. How can I ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: EJB3 Dependency Injection call to remote server INS syntax problem

  1. EJB3 Dependency Injection call to remote server INS syntax problem

    I want to use DI (or manual JNDI lookup) in an EJB3 service to call another EJB3 service on another server.
    By default WAS generates short and long form interface bindings which include the package qualified interface.
    How can I use such an interface name in my ejb-ref in ibm-ejb-jar-bnd.xml? Infocenter has a topic
    "EJB 3.0 application bindings overview" which says "To point to a location within a different WeSphere
    Application Server cell, a CORBAName-style name can be used instead of a standard JNDI name".

    Now I don't want to call just another cell but a different host altogether. So I tried this:

    {code}

    {code}

    However, this gives an error:

    {code}javax.naming.InvalidNameException: The name component "my.package2.EJBb.EJBServiceRemote" violates INS name syntax. There is more than one unescaped ID/KIND separator (".").{code}

    I suppose that's a valid error; corbaname INS syntax doesn't allow multiple dots in the name.
    So I tried to use the CORBA/LDAP escape character \ but it doesn't work either.
    Using this:

    {code}binding-name="corbaname:iiop:another.host.com:2809/NameServiceServerRoot#my\.package2\.EJBb\.EJBServi ceRemote"{code}

    I get the error:

    {code}javax.naming.InvalidNameException: Escape character (\) was followed by a character other than "/" or "\" in the name component, "my\.package2\.EJBb\.EJBServiceRemote".{code}

    That is odd, because if I do a manual lookup from a Java client project, using the escape char works.

    The only solution I've found is to use the simple-binding-name to specify a name without dots. But it seems that RAD7.5's Universal Test Client doesn't support short bindings. If I use simple-binding-name, I don't get a long binding at all. Also I would prefer not having to modify the default bindings in the first place.

    Actually, even if the bindings worked a little better, using them would still be problematic. If I have say 50 apps calling a service EJB and move it to another server, it seems I'd have to update each calling app's bindings file.

    I suppose I could use manual lookups instead of DI. A ServiceLocator could fetch the JNDI addresses of EJB's from say properties files or an UDDI registry. I actually did the former and it works from a Java client but for some reason I haven't been able to perform a manual JNDI lookup from my EJB3 service. It gives this error:

    {code}java.lang.ClassCastException: my.package2.EJBb_EJBServiceRemote_Stub incompatible with my.package2.EJBb.EJBServiceRemote{code}

    That's the same error one gets if one runs a Java client outside of the client container without using the stubs generated by createEJBStubs.bat. I even tried generating the stubs and adding them to EJBa's classpath but that didn't help.

  2. Re: EJB3 Dependency Injection call to remote server INS syntaxproblem

    The DI problem stands but I got my ServiceLocator to work. The problem
    is that a lookup with a corbaname URL like this doesn't work due to
    the dots in the default EJB3 long binding name WAS generates:

    {code}
    String jndiPath=corbaname:iiop:another.host.com:2809/NameServiceServerRoot#my.package2.EJBb.EJBServiceR emote
    Object o = ic.lookup(jndiPath);
    {code}

    However, this way the lookup works:

    {code}
    String jndiPath = "my.package2.EJBb.EJBServiceRemote";
    String provider = "corbaname:iiop:another.host.com:2809";
    my.package2.EJBb.EJBServiceRemote EJBbService;

    Properties jndiLookupProps = new Properties();
    jndiLookupProps.put(javax.naming.Context.INITIAL_C ONTEXT_FACTORY,
    com.ibm.websphere.naming.PROPS.INITIAL_CONTEXT_FAC TORY);
    jndiLookupProps.put(javax.naming.Context.PROVIDER_ URL, provider);
    InitialContext ic = new InitialContext(jndiLookupProps);
    EJBbService = (my.package2.EJBb.EJBServiceRemote) ic.lookup(jndiPath);
    {code}

+ Reply to Thread