7 Replies Latest reply: Aug 2, 2012 3:41 AM by gimbal2 RSS

    java.lang.reflect.InvocationTargetException

    hkcoder
      Hi,

      I am new to EJB. i've developed my first EJB Program using Netbeans.

      Here are my classes :


      package ejb;

      import javax.ejb.Stateless;


      @Stateless(mappedName="Bean30")
      public class Bean30Bean implements Bean30Remote
      {
      public String getResult()
      {
      return "This is EJB 3.0 Bean";
      }
      }

      Remote Interface :

      package ejb;

      import javax.ejb.Remote;

      @Remote
      public interface Bean30Remote {

      String getResult();

      }


      Calling EJB :

      InitialContext ctx = new InitialContext();
      Bean30Remote br = (Bean30Remote) ctx.lookup("Bean30#ejb.Bean30Remote");
      System.err.println("EJB message is: " + br.getResult());

      While lookup, it is throwing me an 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 org.glassfish.appclient.client.acc.AppClientContainer.launch(AppClientContainer.java:438)
      at org.glassfish.appclient.client.AppClientFacade.main(AppClientFacade.java:165)
      Caused by: javax.naming.NamingException: Lookup failed for 'Bean30#ejb.Bean30Remote2' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfaceejb.Bean30Remote2 [Root exception is java.lang.ClassNotFoundException: ejb.Bean30Remote2]]
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at applicationclientfortest.Main.main(Main.java:27)
      ... 6 more
      Caused by: javax.naming.NamingException: ejb ref resolution error for remote business interfaceejb.Bean30Remote2 [Root exception is java.lang.ClassNotFoundException: ejb.Bean30Remote2]
      at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:433)
      at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:75)
      at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
      at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:556)
      at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514)
      ... 9 more
      Caused by: java.lang.ClassNotFoundException: ejb.Bean30Remote2
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at org.glassfish.appclient.client.acc.ACCClassLoader.findClass(ACCClassLoader.java:212)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
      at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:687)
      at com.sun.ejb.EJBUtils.loadGeneratedRemoteBusinessClasses(EJBUtils.java:462)
      at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:413)
      ... 13 more

      I've checked on the GlassFish. It has been deployed successfully with name "EJBModule30".

      Any comments will be greatly appreciated. Please let me know if i'm doing something wrong.