You're on the right track.  The call Class.forname should take a full
package path to work.  For instance,

Class.forname("java.lang.String");

It's also the case that this call should be made inside of a try block:

try
{
    Class c = Class.forName("java.lang.String");
    PortableRemoteObject.narrow(name,c);
}
catch (Exception e) 
{
        // !!! couldn't find java.lang.String
}

Reference Java in a Nutshell page 148 for more info on this form of
reflection.

Jeff Mc.

p.s. - this page also gives cool information about invoking methods if you
know the name.  This could come in handy for setting up generic clients to
call get and set methods.


-----Original Message-----
From: Sascha Matzke [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 20, 2000 1:42 PM
To: jBoss
Subject: [jBoss-User] dynamically get a class


Hello,

I have some stateless Sessionbeans which are all named after a
specific pattern [XML_DOCTYPE]Update{Bean|Home}. They all "implement" a
remoteinterface named Update.

How can I dynamically (depending of the DocumentType of the input) get
the right class for the "PortableRemoteObject.narrow(name, class)"
command? I tried something like that:

PortableRemoteObject.narrow("catalogUpdateHome",Class.forname("catalogUpdate
Home.class"))

but it only gives a ClassNotFoundException.

Sascha
-- 
.-> Sascha Matzke - [EMAIL PROTECTED] ------------------------.
|   Eure Moral, Eure MGs werden nicht ewig regier'n...       |
|                                         Anarchist Academy  |
`-- On this earth for  24 years,  343 days  <----------------'


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to