I'm not sure about the use of Reference and NamingManager (I do everything
through a Context), but you can create a
URLClassLoader to point at the port the webserver is running on to load
classes, and then set it to be the class loader for the current Thread
thanks to Tom Cook for pointing this out). Better yet, you can create the
class loader with the System class loader as its parent, so that classes
will be resolved locally as well:
URL urls[] = new URL[1];
urls[0] = new URL( "http://localhost:8083" );
ClassLoader cl = new URLClassLoader( urls,
ClassLoader.getSystemClassLoader() );
Thread.currentThread().setContextClassLoader( cl );
System.setSecurityManager( new RMISecurityManager() );
Anybody see any problems with this? I haven't actually tried this code, but
is seems reasonable....
joe
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Castro, David
Sent: Tuesday, February 13, 2001 9:29 AM
To: 'jBoss'
Subject: RE: [jBoss-User] Dynamic classloading
Forgive me if Im missing the obvious. Im new to JNDI, but I just dont see
how your code could work with nothing in the classpath.
You are directly referencing the SKILLSHome class in your code. Therefore,
the class loader that is trying to load the SKILLSHome is the system
classloader (since I see Dynamictest.main in your stack trace). And youve
just said that SKILLSHome is NOT in the system classpath. So you will
always get NoClassDefFoundError!
I think you must either: 1. have SKILLSHome in your classpath or 2. have
SKILLSHome implement an interface that is in your classpath or 3. Cast your
PRO.Narrow to an Object and use reflection to call methods on it. or 4.
reference SKILLSHome directly from a second class which is dynamically
loaded by a classloader that can see SKILLSHome.
However it is possible that I am missing something completely and what you
are trying to do is actually possible.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 12, 2001 5:20 AM
To: [EMAIL PROTECTED]
Subject: [jBoss-User] Dynamic classloading
Hi all
I have seen quite a bit of discussion on the issue of Dynamic classloading
I have spent several days trying to do it myself...but NO BANANA
On the client side I have jboss-client in the class path and also
jnp-client in that directory. I do not have my Ejb home & remote interfaces
on the client classpath
Here's my client code. Please anybody help...
//////////////////////////////////////////////////////////////////////
// Start of Dynamictest
//////////////////////////////////////////////////////////////////////
import java.util.*;
import java.io.*;
import javax.naming.*;
import com.argiley.ejb.cmp.contracting.*;
import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.CreateException;
import java.sql.SQLException;
import javax.rmi.PortableRemoteObject;
import java.rmi.RMISecurityManager;
import javax.naming.spi.*;
import java.net.URL;
import java.net.URLClassLoader;
import java.rmi.server.RMIClassLoader;
public class Dynamictest{
public Dynamictest(){
try{
System.setSecurityManager(new RMISecurityManager());
Reference ref = new Reference
("com.argiley.ejb.cmp.contracting.SKILLSHome", new StringRefAddr
("URL","jnp://dev_client4:1099/SKILLSHome"),
"org.jnp.interfaces.jnp.jnpURLContextFactory", "http://dev_client4:8083/");
System.out.println("Factoryclasslocation " +
ref.getFactoryClassLocation());
System.out.println("Factoryclassname " +
ref.getFactoryClassName());
Object homeref = NamingManager.getObjectInstance(ref, null,
null, null);
SKILLSHome home = (SKILLSHome)PortableRemoteObject.narrow(ref,
SKILLSHome.class);
SKILLS skills = home.create();
System.out.println("Commencing Test 4444");
skills.setSKILLSCATEGORYID(new Integer(1));
skills.setSKILL("TESTFROMTESTJBOSS 79842");
System.out.println("Test SUCCESfully Completed");
}catch(NoClassDefFoundError noe){
noe.printStackTrace();
System.out.println("NoClassDefFoundError " +noe.getMessage());
}catch(SQLException se){
System.out.println("NamingException " +se.getMessage());
}catch(CreateException ce){
System.out.println("NamingException " +ce.getMessage());
}catch(RemoteException re){
System.out.println("NamingException " +re.getMessage());
}catch(NamingException ne){
System.out.println("NamingException " +ne.getMessage());
}catch(Exception ex){
ex.printStackTrace();
System.out.println("Exception " +ex.getMessage());
}
}
public static void main(String args[]){
Dynamictest t = new Dynamictest();
}
}
//////////////////////////////////////////////////////////////////////
// End of Dynamictest
//////////////////////////////////////////////////////////////////////
This is a really cool aspect of JBoss and I would like to dig deeper into
this capability... But I first need to get this simple test working
PLEASE HELP
Ivanhoe Abrahams
Email : [EMAIL PROTECTED]
______________________________________________________________________
Ernst & Young South Africa - http://www.ey.com/southafrica
WARNING: this e-mail contains confidential information and any
unauthorised use or interception is illegal.
If this e-mail is not intended for you, you may not copy, distribute
or disclose the contents to anyone nor
take any action in reliance on the content. If you receive this in
error, please contact the sender and
delete the material from any computer.
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]