1 Reply Latest reply on Oct 14, 2009 6:55 AM by mikhailov_kg

    java.lang.NoClassDefFoundError when accessing my EJBs

    kimba74

      Hi all,

      I have a slight problem, I try to create a reference Stateless SessionBean but for some reason each time my client tries to access the Bean after looking it up on JNDI I end up getting the following exception:

      Exception in thread "main" java.lang.NoClassDefFoundError: [Lorg/jboss/aop/advice/Interceptor;
       at java.lang.Class.getDeclaredFields0(Native Method)
       at java.lang.Class.privateGetDeclaredFields(Class.java:2232)
       at java.lang.Class.getDeclaredField(Class.java:1852)
       at java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1555)
       at java.io.ObjectStreamClass.access$600(ObjectStreamClass.java:47)
       at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:381)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:373)
       at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:268)
       at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:504)
       at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
       at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
       at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
       at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
       at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
       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.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)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at com.kimbasoft.reference.ejb.client.MyClient.main(MyClient.java:28)
       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:585)
       at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
      




      Here is my source:

      Remote Interface:
      package com.kimbasoft.reference.ejb.session;
      
      public interface TestRemote {
      
       public String sayHelloRemote();
      
      }
      


      Local Interface:
      package com.kimbasoft.reference.ejb.session;
      
      public interface TestLocal {
      
       public String sayHelloLocal();
      
      }
      



      Bean Implementation:
      package com.kimbasoft.reference.ejb.session;
      
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import javax.ejb.Local;
      
      @Stateless
      @Local({TestLocal.class })
      @Remote({TestRemote.class})
      public class TestBean implements TestRemote {
      
       public String sayHelloRemote() {
       return "Hello Remote World!!!";
       }
      
       public String sayHelloLocal() {
       return "Hello Local World!!!";
       }
      
      }
      


      Client Implementation:
      package com.kimbasoft.reference.ejb.client;
      
      import com.kimbasoft.reference.ejb.session.TestRemote;
      
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      
      public class MyClient {
      
      
       public static void main(String[] args) {
      
       Context ctx;
      
       try {
       ctx = new InitialContext();
       TestRemote obj = (TestRemote) ctx.lookup("TestBean/remote");
       System.out.println(">>" + obj.sayHelloRemote());
       } catch (NamingException e) {
       System.out.println("ERROR");
       e.printStackTrace();
       }
      
       }
      }
      



      First I compile everything and package it into a JAR file. Then I deploy it on JBoss. After deploying I check the JNDI content and can see my TestBean and it's remote and local interface. Now I start the client (I have the client JARs of JBoss in the path) on my local pc out of a local copy of the JAR file I deployed on the server and then I get the above mentioned exception. Can anybody help me and tell me what I'm doing wrong???

      Thanks,

      Kimba


      Configuration:
      JBoss 4.0.4 GA
      jboss-EJB-3.0_RC8-FD
      JDK 1.5.0