WAS CE: JNDI lookup for standalone EJB client - Websphere

This is a discussion on WAS CE: JNDI lookup for standalone EJB client - Websphere ; Server: WAS CE 2.0 I can't for the life of me do a lookup for an EJB I have deployed using a standalone EJB client. Its a simple "HelloWorld" style EJB. I have included an openejb-jar.xml file that looks like ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: WAS CE: JNDI lookup for standalone EJB client

  1. WAS CE: JNDI lookup for standalone EJB client

    Server: WAS CE 2.0



    I can't for the life of me do a lookup for an EJB I have deployed using a standalone EJB client. Its a simple "HelloWorld" style EJB.

    I have included an openejb-jar.xml file that looks like this:



    ?xml version= "1.0" encoding= "UTF-8"
     
    openejb-jar xmlns= "http://www.openejb.org/xml/ns/openejb-jar-2.2"
    xmlns:dep= "http://geronimo.apache.org/xml/ns/deployment-1.2"
    xmlns:naming= "http://geronimo.apache.org/xml/ns/naming-1.2"
    xmlns:security= "http://geronimo.apache.org/xml/ns/security-1.2"
    xmlnskgen= "http://www.openejb.org/xml/ns/pkgen-2.0"
     


    LocalTest
    bs
    test


     

     
    !-- Begin configuration for
    !-- Repeat for

     
    !-- End configuration for

     






    Here are my classes and client code

    package bs.dk.ejb;
     
    import javax.ejb.Stateless;
     
    @Stateless (name= "Myejb" )
    public class HelloBean implements Hello {

    public String hello() {
    System.out.println( "hello" );
    return "HELLO" ;
    }
    }


    package bs.dk.ejb;
     
    import javax.ejb.Remote;
     
    @Remote
    public interface Hello {
    public String hello();
    }


    package bs.dk.client;
     
    import java.util.Properties;
     
    import javax.naming.Context;
    import javax.naming.InitialContext;
     
    import bs.dk.ejb.Hello;
     
     
    public class EJBClient {

    public static void main(String[] args) throws Exception {
    Properties prop = new Properties();
    prop.put(Context.INITIAL_CONTEXT_FACTORY,
    "org.openejb.client.RemoteInitialContextFactor y" );
    prop.put(Context.PROVIDER_URL, "ejbd://localhost:4201" );
    Context ctx = new InitialContext(prop);
    System.out.println (ctx.getEnvironment());
    Hello hello = (Hello) ctx.lookup( "bs/Myejb/bs.dk.ejb.Hello" );
    hello.hello();

    }
    }




    A few points I'd like to mention.



    Here is how the JNDI tree looks like in the admin console after deployment.

    +EJBModule
    +LocalTest/bs/test/jar
    +SessionBeans
    +Myejb
    +java:comp/HandleDelegate
    +java:comp/ORB
    +java:comp/TimerService
    +java:comp/TransactionManager
    +java:comp/TransactionSynchronizationRegistry
    +java:comp/env/dummy




    Here is the info the JMX viewer gives



    deploymentid = bs/Myejb




    As per the documentation, I ought to be able to look it up.



    Link: http://publib.bo ulder.ibm.com/wasce/V2.0.0/en/jndi.html



    Here is the exact trace when I run the client

    { java.naming.provider.url=ejbd: //localhost:4201, java.naming.factory.initial=org.openejb.client.Rem oteInitialContextFactory}
    Exception in thread "main" javax.naming.NameNotFoundException: /bs/Myejb/bs.dk.ejb.Hello does not exist in the system. Check that the app was successfully deployed.
    at org.apache.openejb.client.JNDIContext.lookup(JNDIC ontext.java:239)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at bs.dk.client.EJBClient.main(EJBClient.java:20)




    I've spent a day on this simple thing. Any ideas what the problem is? Find attached my code in case you want to try it out.

  2. Re: WAS CE: JNDI lookup for standalone EJB client

    Okay here's the answer. I changed the client code to look like this



    public class EJBClient {

     
    public static void main(String[] args) throws Exception {
    Properties prop = new Properties();
     
    prop.put(Context.INITIAL_CONTEXT_FACTORY,
     
    "org.openejb.client.RemoteInitialContextFactor y" );
     
    prop.put(Context.PROVIDER_URL, "ejbd://localhost:4201" );
     
    Context ctx = new InitialContext(prop);
     
    System.out.println (ctx.getEnvironment());
     
    Hello hello = (Hello) ctx.lookup( "MyejbRemote" );
     
    hello.hello();
     

     
    }
    }




    The change is Hello hello = (Hello) ctx.lookup("MyejbRemote");



    Apparently WAS CE exposes the bean on JNDI as Remote and Home. I don't know where this is documented though.

+ Reply to Thread