I'm using VAJava 3.5 and WebSphere 3.5.
I've asked all our EJB developers to supply a ping() method in any deployed
EJB so that we can test remote connectivity.
I've written a main() method that works fine from within VAJava. Below is
the code.
I've also written a servlet that is basically identical but gets the
parameters for the PROVIDER_URL and beanJndiLookupName from the request
object.
The strange thing is, I've taken the same exact code, pasted it into a
servlet and it fails on the
        java.lang.reflect.Method m =
obHome.getClass().getDeclaredMethod("create", new Class[0]);
Even more strange is that the servlet used to work.

Any ideas?

        String PROVIDER_URL = "iiop:///";
        String beanJndiLookupName = "some/bean/jndiName";
        java.util.Hashtable properties = new java.util.Hashtable(2);
        properties.put(javax.naming.Context.PROVIDER_URL, PROVIDER_URL);
        properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.ejs.ns.jndi.CNInitialContextFactory");

        // IBM name services
        javax.naming.InitialContext initContext = new
javax.naming.InitialContext(properties);

        // get ref to remote interface
        Object objref = initContext.lookup(beanJndiLookupName);

        // get a ref to the home
        EJBHome obHome = (EJBHome)
javax.rmi.PortableRemoteObject.narrow(objref, EJBHome.class);

        //invoke the create() method
        java.lang.reflect.Method m =
obHome.getClass().getDeclaredMethod("create", new Class[0]);
        Object obj = m.invoke(obHome, new Object[0]);

        m = obj.getClass().getDeclaredMethod("ping", new Class[0]);
        Object pingObj = m.invoke(obj, new Object[0]);
        System.out.println(pingObj.toString());


Anthony Catalfano
Information Technology Analyst
Deere & Company
309-748-5201

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to