0 Replies Latest reply on Nov 10, 2009 8:20 AM by vikram_khati

    Can't load remote interface of ejb in my client from jboss-e

      Hi,
      I had written a client which is trying to call the ejb dynamically using reflection api. Instead of putting the home and remote interfaces in the classpath of the client application I am trying to load these interfaces from jboss server using RMI codebase. For this i had also added the security manager in my client so that it can load the interfaces from jboss server. This thing is working in jboss-4.0.3SP1 completly, but it is not working in jboss-eap-4.2 completely.
      Client is loading the home interface but it is not loading the remote interface from jboss-eap-4.2 while Client is loading both home interface and remote interface from 4.0.3SP1. Those interfaces are present in RMI codebase URL(I am able to download those interfaces with the help of browser in that URL)


      My Client code is as follow:

      public class Client
      {
      public static void main(String args[])
      {
      System.setProperty("java.security.policy","D:\\VB\\policy.all");
      SecurityManager sm=new SecurityManager();
      System.setSecurityManager(sm);
      String jndiName="CFFESBean",homeInterfaceName="nsdg.client.CFFESHome",remoteInterfaceName="nsdg.client.CFFESRemote";
      String remoteMethodName="initialise";
      Properties ps=new Properties();
      ps.put(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      ps.put(InitialContext.PROVIDER_URL, "jnp://localhost:1099");
      ps.put(InitialContext.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
      try
      {
      Context ctx=new InitialContext(ps);
      System.out.println("1");
      Object homeObject=ctx.lookup(jndiName);
      System.out.println("2");
      EJBHome ejbHomeObject=(EJBHome)PortableRemoteObject.narrow(homeObject,EJBHome.class);
      EJBMetaData ejbMetaData=ejbHomeObject.getEJBMetaData();
      Class homeInterfaceClass=ejbMetaData.getHomeInterfaceClass();
      System.out.println("ejbHomeObject= "+ejbHomeObject);
      Class remoteInterfaceClass=ejbMetaData.getRemoteInterfaceClass();
      System.out.println("Remote Interface Class= "+remoteInterfaceClass);

      Method homeInterfaceMethod = homeInterfaceClass.getMethod("create",null);
      homeInterfaceMethod.setAccessible(true);
      System.out.println("3");
      EJBObject remoteObject=(EJBObject)homeInterfaceMethod.invoke(homeObject, null);
      System.out.println("4");

      Method remoteInterfaceMethod = remoteInterfaceClass.getMethod(remoteMethodName,null);
      remoteInterfaceMethod.setAccessible(true);
      Object returnObject=remoteInterfaceMethod.invoke(remoteObject, null);
      System.out.println("returning");
      }catch (NamingException e)
      {
      System.out.println("Inside Naming Exception");
      e.printStackTrace();
      }catch (Exception e)
      {
      System.out.println("Inside Exception");
      e.printStackTrace();
      }
      }

      }

      And the output is as follow:

      1
      2
      ejbHomeObject= CFFESBeanHome
      Remote Interface Class= interface nsdg.client.CFFESRemote
      3
      Inside Exception
      java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at cffes.client.Client.main(Client.java:45)
      Caused by: java.lang.reflect.UndeclaredThrowableException
      at $Proxy0.create(Unknown Source)
      ... 5 more
      Caused by: java.lang.ClassNotFoundException: nsdg.client.CFFESRemote
      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:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      at org.jboss.invocation.MarshalledValueInputStream.resolveProxyClass(MarshalledValueInputStream.java:159)
      at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
      at org.jboss.invocation.MarshalledValue.get(MarshalledValue.java:91)
      at org.jboss.invocation.unified.interfaces.UnifiedInvokerProxy.invoke(UnifiedInvokerProxy.java:195)
      at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:365)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:197)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
      at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:184)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
      ... 6 more


      What can be the solution of this problem so that it will work completly with
      jboss-eap-4.2