6 Replies Latest reply on Sep 22, 2008 8:09 AM by Morten Hauch

    JAXB in jBPM

    Morten Hauch Newbie

      I'm trying to use JAXB in jBPM, which produces the error mentioned in https://jira.jboss.org/jira/browse/JBPM-1404.
      I have downloaded the source code and tried to apply the patch described in the jira by replacing only the class and the inner classes.
      Unfortunately I am not able to get it to work.
      I am using the jBPM bundled with JBoss ESB 4.4, and I have downloaded and patched jpdl-3.2.2-SOA-4.2 from subversion.

      The findClass in ProcessClassLoader now looks like:

      public Class findClass(String name) throws ClassNotFoundException {
       Class clazz = null;
      
       FileDefinition fileDefinition = processDefinition.getFileDefinition();
       if (fileDefinition!=null) {
       String fileName = "classes/" + name.replace( '.', '/' ) + ".class";
       byte[] classBytes;
       try {
       classBytes = fileDefinition.getBytes(fileName);
       clazz = defineClass(name, classBytes, 0, classBytes.length);
       } catch (JbpmException e) {
       clazz = null;
       }
       // Add the package information
       final int packageIndex = name.lastIndexOf('.') ;
       if (packageIndex != -1) {
       final String packageName = name.substring(0, packageIndex) ;
       final Package classPackage = getPackage(packageName) ;
       if (classPackage == null) {
       definePackage(packageName, null, null, null, null, null, null, null) ;
       }
       System.out.println("package is: "+packageName);
       }
       }
      
       if (clazz==null) {
       throw new ClassNotFoundException("class '"+name+"' could not be found by the process classloader");
       }
      
       return clazz;
       }
      


      - and the output is:
      20:14:04,030 INFO [STDOUT] package is: dk.lenio.em.smile.jbpm.vo
      20:14:04,063 ERROR [GraphElement] action threw exception: "dk.lenio.em.smile.jbpm.vo" doesnt contain ObjectFactory.class or jaxb.index
      javax.xml.bind.JAXBException: "dk.lenio.em.smile.jbpm.vo" doesnt contain ObjectFactory.class or jaxb.index

      I have a class named ObjectFactory in the package dk.lenio.em.smile.jbpm.vo.

      Any suggestions?

        • 1. Re: JAXB in jBPM
          Ronald van Kuijk Master

          with all these kinds of new reflection using frameworks with custom classloader things, the processclassloader (used for versioning mainly) becomes less and less usefull (imo).

          So my suggestion would be to try it without loading any classes that are in the processarchive. Put all in jars on the classpath but jou might run into https://jira.jboss.org/jira/browse/JBPM-1148 then....

          • 2. Re: JAXB in jBPM
            Morten Hauch Newbie

            Thanks for your reply.
            I'm not to happy about the suggestion, however.
            That would require a restart with every change in objects (internal to jbpm) - and might cause problems if a class used in a long running workflow changes.

            • 3. Re: JAXB in jBPM
              Ronald van Kuijk Master

              Yep... correct... but my suggestion was just to check if it works then, so we have a more narrow path to search for the real problem... and maybe rethink (redesign?) the class versioning in relation to processdefinitions

              • 4. Re: JAXB in jBPM
                Morten Hauch Newbie

                Fair enough...

                So I did as suggested: copied my objects using jaxb to lib, which worked fine.
                This is however an unacceptable solution (as mentioned above), and the only purpose was to narrow down the problem.

                So back to start: any suggestions how to make jaxb work with classes loaded with the jbpm classloader?

                • 5. Re: JAXB in jBPM
                  Ronald van Kuijk Master

                  Hauch,

                  I think the first thing to do is to make a jira issue for this. This does not solve your problem, I know, but it puts it on the radar. A complete yet simple example would help a lot.

                  This is such a fundamental thing (the classloader in relation to other frameworks) that I suspect that you will not get any help from the community. Not that they do not want to, but for some that had kind of similar issues, it was not a big deal to do it differently. The core developers are the ones that can either help you with some suggestions, fix it or whatever.

                  Sorry

                  • 6. Re: JAXB in jBPM
                    Morten Hauch Newbie

                    Ronald

                    Thanks for your help.
                    There is already a jira on this issue - I just couldn't get the described fix to work (see the first post).
                    My hope was that somebody actually had tried the fix, and was able to help me.

                    I will find another way to solve the problem (probably using xStream, xmlBeans or equivalent).