1 Reply Latest reply on Sep 29, 2005 5:34 AM by Sven Schulz

    Bug in process class loader

    Sven Schulz Newbie

      Hi,

      the user guide says:

      Delegation classes are loaded with the process class loader of their respective process definition. The process class loader is a class loader that has the jBPM classloader as a parent. The process class loader adds all the classes of one perticular process definition. You can add classes to a process definition by putting them in the /classes folder in the process archive. Note that this is only useful when you want to version the classes that you add to the process definition. If versioning is not necessary, it is much more efficient to make the classes available to the jBPM class loader.


      However the ProcessClassLoader does not delegate to the parent (JBpm) class loader, throwing an exception if the class is not found. A possible fix would be

      
       public Class findClass(String name) throws ClassNotFoundException {
      
       try {
       return super.findClass(name);
       } catch (ClassNotFoundException cnfe) {
       /* Parent class loader failed to load the class. */
       }
      
       Class clazz = null;
      
       FileDefinition fileDefinition = processDefinition.getFileDefinition();
       if (fileDefinition!=null) {
       String fileName = "classes/" + name.replace( '.', '/' ) + ".class";
       byte[] classBytes = fileDefinition.getBytes(fileName);
       clazz = defineClass(name, classBytes, 0, classBytes.length);
       }
      
       if (clazz==null) {
       throw new ClassNotFoundException("class '"+name+"' could not be found by the process classloader");
       }
      
       return clazz;
       }
      


      Regards,
      Sven Schulz