0 Replies Latest reply on Nov 10, 2009 7:39 AM by marcosroriz

    ClassLoader and java.lang.ClassNotFoundException

    marcosroriz

      Hi I'm using Javassist as a library for our library (InterCommunication on Ginga) that with PhoneME + Personal Basis Profile will be the platform for embedded devices (digital tv). The question is that we're using Javassist to create Stubs on the fly for Xlets, which is like Applets but for Digital TV. However since Javassist will be a core component of our library it will be in the XbootClassPath. Even through we add (appending or inserting) the AppClassCL, that views the ClassPath, we can sucesfully find the targeting class that we want however when we try to load we get this error described below.

      One reason is that the CL of the makeClass method is using the CL that loaded javassist, how can we do a workaround on that situation?

      Thanks in advance,

      Marcos

      Error Message:

      CAN WE FIND?? file:/home/marcosroriz/workspace/UFG-InterAPPJava-SimpleApplication/dist/Server.class
      java.lang.ClassNotFoundException: Server
       at java.lang.ClassLoader.loadBootstrapClass(Unknown Source)
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Unknown Source)
       at br.ufg.inf.core.interapp.ClassCreator.makeClass(Unknown Source)
       at br.ufg.inf.core.interapp.Registry.lookup(Native Method)
       at br.ufg.inf.core.interapp.IxcRegistry.lookup(Unknown Source)
       at Client.startXlet(Unknown Source)
       at com.sun.xlet.XletManager.handleRequest(Unknown Source)
       at com.sun.xlet.XletStateQueue.dispatchRequests(Unknown Source)
       at com.sun.xlet.XletStateQueue$1.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)
       at java.lang.Thread.startup(Unknown Source)
      java.lang.ClassCastException: Server_Stub
       at Client.startXlet(Unknown Source)
       at com.sun.xlet.XletManager.handleRequest(Unknown Source)
       at com.sun.xlet.XletStateQueue.dispatchRequests(Unknown Source)
       at com.sun.xlet.XletStateQueue$1.run(Unknown Source)
       at java.lang.Thread.run(Unknown Source)
       at java.lang.Thread.startup(Unknown Source)
      


      Code:
      private static CtClass cc;
      
       public static void makeClass(String iName) {
       try {
       ClassPool pool = ClassPool.getDefault();
      
       System.out.println("SYS CL: " + ClassLoader.getSystemClassLoader());
      
       pool.insertClassPath(new LoaderClassPath(pool.getClass().getClassLoader()));
       pool.insertClassPath(new LoaderClassPath(pool.getClassLoader()));
       pool.insertClassPath(new LoaderClassPath(ClassLoader.getSystemClassLoader()));
      
       System.out.println("CAN WE FIND?? " + pool.find("Server"));
       cc = pool.makeClass(iName + "_Stub");
      ....