3 Replies Latest reply on Apr 30, 2007 8:35 AM by Michael Hönnig

    EJB 3.0 client

    arvinda rajan Newbie

      hi,

      I am trying to execute a client for an EJB 3.0 program that I deployed using JBoss 4.0.4 RC2.

      there is some problem and am not able to figure it out.

      here is the exception

      javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.proxy.ejb.EJBMetaDataImpl (no security manager: RMI class loader disabled)]
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at client.CalculatorClient.main(CalculatorClient.java:45)
      Caused by: java.lang.ClassNotFoundException: org.jboss.proxy.ejb.EJBMetaDataImpl (no security manager: RMI class loader disabled)
      at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:371)
      at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
      at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
      at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
      at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
      at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1538)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
      at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
      at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
      at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:652)
      ... 3 more
      javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.proxy.ejb.EJBMetaDataImpl (no security manager: RMI class loader disabled)]



      this is my client program

      /**
      *
      */
      package client;

      import calc.Calculator;
      //import calc.CalculatorRemote;

      import javax.naming.Context;
      import javax.naming.InitialContext;

      import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;


      public class CalculatorClient {


      public static void main(String[] args) throws Exception
      {
      // Look up home interface

      Hashtable env = new Hashtable();
      //env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");

      //Host at which JBoss server is listening
      //env.put(Context.PROVIDER_URL, "localhost:11099");
      //env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      System.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      System.setProperty(Context.PROVIDER_URL, "localhost:1099");
      System.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");

      try

      {

      /* Context ctx = new InitialContext();
      Calculator calculator = (Calculator) ctx.lookup("leaving/StatelessCalculator/local");
      System.out.println("1 + 1 = " + calculator.add(1, 1));*/


      InitialContext ctx = new InitialContext();
      Calculator calculator = (Calculator) ctx.lookup("leaving/StatelessCalculator/remote");

      System.out.println("1 + 1 = " + calculator.add(1, 1));
      //System.out.println("1 - 1 = " + calculator.subtract(1, 1));
      }catch (Exception e)
      {
      e.printStackTrace();
      System.out.println(e);
      }
      }
      }


      can you please help me write a proper client program.

        • 1. Re: EJB 3.0 client
          Bill Burke Master

          what does your client classpath look like?

          • 2. Re: EJB 3.0 client
            Pete Bennett Newbie

            In order for a client to connect succesfully to a JEE server it requires several items to be on the classpath. If you look at the path id="classpath" element in one of the build.xml files for the examples supplied with the book, you can see that these are:

            1. all of the jar files in your JBOSS_HOME\client directory which contain all the additional classes beyond the J2SE 5 implementation that JEE clients require (actually this set is probably overkill for many clients as it includes many jars for services a simple client may not be using, but to get started this is the simplest way to go)

            2. a jndi.properties file (or in code equivalent as you have used) that tells the client how to obtain a reference to the JNDI (Java Naming) service. For a simple example this is a three property file that looks something like...
            java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
            java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
            java.naming.provider.url=localhost

            3. in the case of the example clients a log4j.properties file that configures the logging system (you do not need this in your example)

            From the information you have given in your client it looks as if you are missing one or more of the JBoss jars from your client's classpath (the root of the exception is a missing class: org.jboss.proxy.ejb.EJBMetaDataImpl).

            Can you confirm that you have followed step one?

            • 3. Re: EJB 3.0 client
              Michael Hönnig Newbie

              Hi Pete,

              Your answer is now over a year, but it still seems to be hard to find information on that issue.

              About which book are you talking? I have: "JBoss 4.0 - the official guide" (actually German version) from Marc, Scott and Norman, this has no EJB3 and "JBoss a developers notebook" from Norman and Sam, also no EJB3.

              I also would like to minimize the size of jars needed on the client. My client is a Swing app, mostly using EJB3 session beans and detached entity "beans". It seems it would help not to use annotations but XML deployment files, because annotations just call for more jars on the client side which are of no functional use there.

              > java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

              That line does not seem to be neccessary, even though frequently mentioned. It just seems to cause more jars to be needed on the client.

              Without this, my minimum set (without iiop) is:

              jboss-common-client.jar
              jboss-ejb3-client.jar
              jboss-ejb3x.jar
              jnp-client.jar
              jboss-j2ee.jar
              commons-logging.jar
              log4j.jar
              logkit.jar
              jboss-remoting.jar
              jboss-transaction-client.jar
              jbosssx-client.jar
              jboss-aop-jdk50-client.jar
              jboss-aspect-jdk50-client.jar
              concurrent.jar

              This is a total of 2.5 MB so far. If anybody has a guide how to minimize this, I am eager to get it.

              ... Michael