Hey

[EMAIL PROTECTED] wrote:
> <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?  

There's no policy file set above. Have you set that properly?

> 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

Have you included jnp-client.jar in your clients classpath? 

In its basic form dynamic classloading only works for jboss-client.jar
and any EJB bean interfaces and classes. Due to the workings of JNDI DCL
does not work the way you have done it above. A workaround for this is
to use a Reference which points out the factory and codebase from where
the classes can be loaded. There are more detailed postings on this (by
me) in the archives for this list.

You can also set a URLClassLoader as context classloader for this to
work, which might be simpler:
Thread.currentThread().setContextClassLoader(new URLClassLoader(new
URL[] { new URL("http://localhost:8083/") }));
This will allow JNDI to find the JNP classes properly.

> (a jndi.properties file is in the classpath so the url to the server
> should be known 

Yes, but not the JNDI implementation codebase.

/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]

Reply via email to