1 Reply Latest reply on Oct 26, 2004 5:23 PM by mcifuentes

    Class loaders problem

    mcifuentes

      Hi everyone:
      I was worked with javasssist a few days but I have a cuesstion about it, but the main cuestion is how integrate javassist with jboss, because really I don't know after 5 days of work on it.

      My problem is the next, i created a new class (without problems), but when a mdb try to execute it ways its catch the same error "ClassNotFound", I think that is because the class is not in the classloader. Please help me.



      public static void createScript(String nameScript, String inputTextScript)
       throws NotFoundException, CannotCompileException, IOException{
      
       try{
       ClassPool pool;
      
       pool = ClassPool.getDefault();
      
       pool.appendClassPath(classPath);
      
       CtClass newClass = pool.makeClass( nameScript );
       newClass.stopPruning(true);
      
       CtClass superClass = null;
       superClass = pool.get( packageName + suffixClass );
      
       newClass.setSuperclass(superClass);
      
       newClass.addConstructor(CtNewConstructor.defaultConstructor(newClass));
      
       executeBody = executeBody + inputTextScript ;
      
       newClass.addMethod(CtNewMethod.make(executeBody, newClass));
       newClass.writeFile(workingDir);
       newClass.defrost();
       newClass.detach();
       }
       catch (NotFoundException e ){
       throw e;
      
       }
       catch (CannotCompileException e ){
       throw e;
       }
       catch (IOException e ){
       throw e;
       }
      
      
       }
      
      
      
      
       public static ArrayList executeScript(String name, Mensaje msg){
      
       ArrayList msgs = null;
      
      
       Class c = null;
      
      
      
       try {
       c = Class.forName(name);
       } catch (ClassNotFoundException e) {
       e.printStackTrace();
       }
      
      
       Object testConstructed = null;
       try {
       testConstructed = c.newInstance();
       } catch (InstantiationException e1) {
       e1.printStackTrace();
       } catch (IllegalAccessException e1) {
       e1.printStackTrace();
       }
      
       Script valor = (Script) testConstructed;
      
       msgs = valor.execute();
       return msgs;
      
      
       }