Cool...BUT, it still doesn't work for me :-)
I'm trying to connect to a pretty simple Session bean called assetmgr.biz.UserMgmt. The getAllUsersHTML() method is intended for a web-based client, but I'm using it here to test--it just prints out some html generated from the entity beans that it in turn connects to. (I know, this should probably be in a JavaBean on the client end--so sue me) Here's my simple code attempt:
<code>
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import java.rmi.RMISecurityManager;
import assetmgr.biz.*;
public class test {
public static void main(String[] args) {
try {
System.setSecurityManager(new RMISecurityManager());
Context ctx = new InitialContext();
Object ref = ctx.lookup("UserMgmt");
UserMgmtHome home = (UserMgmtHome)PortableRemoteObject.narrow(ref, UserMgmtHome.class);
UserMgmt usermg = home.create();
System.out.println(usermg.getAllUsersHTML());
} catch (Exception e) {
System.out.println("Caught an exception: " + e);
e.printStackTrace();
}
}
}
</code>
Is it supposed to be that simple? Do I need to setup any special classloaders? Anyway here's the output:
<output>
Caught an exception: javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException
: org.jnp.interfaces.NamingContextFactory]
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory. Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces
.NamingContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:195)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:45)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:655)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246)
at javax.naming.InitialContext.init(InitialContext.java:222)
at javax.naming.InitialContext.<init>(InitialContext.java:178)
at test.main(test.java:11)
</output>
(a jndi.properties file is in the classpath so the url to the server should be known -- I also tried explicitly setting the properties with no difference. I've tried on both the localhost of the server and a remote machine)
Any ideas?
-jason
| Rickard �berg <[EMAIL PROTECTED]>
11/08/2000 09:46 AM
|
To: jBoss <[EMAIL PROTECTED]> cc: Subject: Re: [jBoss-User] DCL |
Hey
[EMAIL PROTECTED] wrote:
> Would anyone be able to provide a trivial example of how to use
> Dynamic Class Loading from a remote client?
>
> I've seen lots of talk about it on this list, but with no
> implementation details :-)
>
> I've tried simple code like this, but it doesn't seem to do anything:
> System.setSecurityManager(new RMISecurityManager());
>
> What else do I need to do?
As it happens this (=DCL) was turned off a while ago and hadn't set back
on.
I just changed this. Dynamic classloading is now enabled in the server.
I have also remove jboss-client.jar from "jbosstest" and updated all
"jbosstest" scripts to set the security manager and a policy file before
starting (so that DCL is enabled).
Fixes are in CVS, as usual (both "jboss" and "jbosstest" modules are
affected).
Thanks for pointing it out :-) Let me know if there are any problems
with this.
regards,
Rickard
--
Rickard �berg
Email: [EMAIL PROTECTED]
http://www.telkel.com
http://www.jboss.org
http://www.dreambean.com
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Problems?: [EMAIL PROTECTED]
