The stock response is to check your classpaths, descriptors, etc. but I
assume you did that. The intervention of a web container occasionally
introduces bizarre introspection class loader side effects. E.g. I
resolved a similar problem by moving the class to a different
package--don't ask me why that worked. Another problem similar to yours
is reported at
http://www.mail-archive.com/[email protected]/msg00665.html
. There was no resolution AFAIK, and related problems were reported by
others.

This is not a pat answer to your question, but it could provide a clue.
A start is to fiddle with the introspection--which classes & methods are
discoverable? I am reluctantly arriving at the conclusion that
introspection in servlet invocations is flaky and should be avoided.

Fred Loney
Spirited Software, Inc.
www.spiritedsw.com

----- Original Message -----
From: "Catalfano Anthony" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 16, 2001 10:06 AM
Subject: Servlet creating an EJB via reflection troubles


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

===========================================================================
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