One thing you might consider is making all your beans implement a Pingable
interface with one method, ping().  Then you can just cast each bean to
that interface and call the method.

Then it'd be typesafe - and probably faster, too, without the overhead of
the introspection.....

Yours,

Tom Copeland
[EMAIL PROTECTED]
703-317-5193



                    Fred Loney
                    <loney@SPIRITEDSW        To:     [EMAIL PROTECTED]
                    .COM>                    cc:
                    Sent by: A               Subject:     Re: Servlet creating an EJB 
via reflection troubles
                    mailing list for
                    Enterprise
                    JavaBeans
                    development
                    <EJB-INTEREST@JAV
                    A.SUN.COM>


                    11/16/2001 02:01
                    PM
                    Please respond to
                    Fred Loney






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




 --------------------------------------------------------------------------


This email may contain confidential and proprietary information which is
for the sole use of the intended recipient.  If you received this email in
error, please notify the sender and delete this email from your computer.
Any review, distribution or retransmission of or reliance on this email by
anyone other than the intended recipient is forbidden.

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