0 Replies Latest reply on Feb 1, 2006 3:09 PM by didier bravo

    How to use two jbossall-client.jar

    didier bravo Newbie

      hi! i develop 2 EJB's one in JBoss 4 and other in JBoss 3. my main app. do this:

      what i need is to add the class org.jnp.interfaces.NamingContextFactory into the InitialContext. this is because i need use different jbossall-client.

      urls[0] = new File ("C:\\jbossall-client.jar").toURL ();
      URLClassLoader urlcl = new URLClassLoader (urls);
      Class c= urlcl.loadClass ("org.jnp.interfaces.NamingContextFactory");

      Hashtable<String, Object> env2 = new Hashtable<String, Object>();
      env2.put ("org.jnp.interfaces.NamingContextFactory",c.newInstance ());
      env2.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      env2.put(Context.URL_PKG_PREFIXES,"org.jboss.naming org.jnp.interfaces");
      env2.put(Context.PROVIDER_URL,"localhost");

      InitialContext ctx2 = new InitialContext(env2);

      i also tried to bind the object. but didn't work

      InitialContext ctx2 = new InitialContext(env2);
      ctx2.rebind ("org.jnp.interfaces.NamingContextFactory",c.newInstance ());

      both methods showme this exception:
      javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
      at javax.naming.InitialContext.init(InitialContext.java:223)
      at javax.naming.InitialContext.(InitialContext.java:197)