1 Reply Latest reply on Mar 29, 2010 8:49 AM by Joost den Boer

    rules in jBPM 4.3

    Adaw Dasx Newbie

      According to jBPM Developers Guide i modyfy my existing jBPM project to add some drools rules. It looks very simple and it worked in my project when in drl files I was using typical Java types like String or Integer. But when I want to use insted of those types, my own Java class i got nasty exception.

       


      I have 2 questions:

       

      1. Where I can find working example with use of custom Java classes in drl files which was described jBPM Developers Guide (no it isn't in example directory)?

       

      2. What casues my exception while using rules. Generaly I made project with one package in which I keep all files (drl, java, jpdl ), my eclipse is also configured according to drools tutorial.

       


      in jpdl a have:

       

         <rules-decision g="90,620,48,48" name="simpleClaim">
            <transition g="-28,-26" name="Nie" to="drools_end"/>
            <transition g="-21,-4" name="Tak" to="Kalkulacja odszkodowania"/>
         </rules-decision>

       

      ------------

      simpleClaim.drl:

      global org.jbpm.jpdl.internal.rules.Outcome outcome;
      global test.Claim claim;

       

      rule "Rule 01"  
          when
              eval( claim.accident_damage_elements_no  >= 10 )
          then
              outcome.set("Tak");
      end

       

      rule "Rule 02"  
          when
              eval( claim.getAccident_damage_elements_no() < 10 )
          then
              outcome.set("Nie");
      end

       

      ------------

      Claim.java:
      import java.io.Serializable;
      import java.util.Date;

       

      public class Claim implements Serializable
      {
          private Integer accident_damage_elements_no;

       

      ...
      setters and getters here
      ....
          public Claim( )
          {
          }   
         
         
          public Claim( int accident_damage_elements_no )
          {
              this.accident_damage_elements_no = accident_damage_elements_no;
          }
      ....
      }
      ----------

      This exception I get after deployment of my generated bar file:

      org.jboss.resteasy.spi.UnhandledException: org.jbpm.api.JbpmException:
        xml validation error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'condition'. One of '{"http://jbpm.org/4.0/jpdl":event-listener, "http://jbpm.org/4.0/jpdl":hql, "http://jbpm.org/4.0/jpdl":sql, "http://jbpm.org/4.0/jpdl":java, "http://jbpm.org/4.0/jpdl":script, "http://jbpm.org/4.0/jpdl":mail}' is expected. [line=10 column=55 ]: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'condition'. One of '{"http://jbpm.org/4.0/jpdl":event-listener, "http://jbpm.org/4.0/jpdl":hql, "http://jbpm.org/4.0/jpdl":sql, "http://jbpm.org/4.0/jpdl":java, "http://jbpm.org/4.0/jpdl":script, "http://jbpm.org/4.0/jpdl":mail}' is expected.
        error: drl problem: claim
          org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:319)
          org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:230)
          org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:206)
          org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:360)
          org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:173)
          org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:93)
          org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:68)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          org.jboss.bpm.console.server.util.GWTJsonFilter.doFilter(GWTJsonFilter.java:59)

      root cause

      org.jbpm.api.JbpmException:
        xml validation error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'condition'. One of '{"http://jbpm.org/4.0/jpdl":event-listener, "http://jbpm.org/4.0/jpdl":hql, "http://jbpm.org/4.0/jpdl":sql, "http://jbpm.org/4.0/jpdl":java, "http://jbpm.org/4.0/jpdl":script, "http://jbpm.org/4.0/jpdl":mail}' is expected. [line=10 column=55 ]: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'condition'. One of '{"http://jbpm.org/4.0/jpdl":event-listener, "http://jbpm.org/4.0/jpdl":hql, "http://jbpm.org/4.0/jpdl":sql, "http://jbpm.org/4.0/jpdl":java, "http://jbpm.org/4.0/jpdl":script, "http://jbpm.org/4.0/jpdl":mail}' is expected.
        error: drl problem: claim
          org.jbpm.pvm.internal.xml.ProblemList.getJbpmException(ProblemList.java:175)
          org.jbpm.pvm.internal.xml.ProblemList.getJbpmException(ProblemList.java:141)
          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          java.lang.reflect.Method.invoke(Method.java:597)
          org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
          org.jbpm.pvm.internal.repository.DeploymentImpl_$$_javassist_27.getJbpmException(DeploymentImpl_$$_javassist_27.java)
          org.jbpm.pvm.internal.repository.DeployerManager.deploy(DeployerManager.java:50)
          org.jbpm.pvm.internal.repository.RepositorySessionImpl.getObject(RepositorySessionImpl.java:129)
          org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl.execute(ProcessDefinitionQueryImpl.java:72)
          org.jbpm.pvm.internal.query.AbstractQuery.execute(AbstractQuery.java:87)
          org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
          org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
          org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
          org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
          org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
          org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
          org.jbpm.pvm.internal.query.AbstractQuery.untypedList(AbstractQuery.java:68)
          org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl.list(ProcessDefinitionQueryImpl.java:141)
          org.jbpm.integration.console.ProcessEnginePluginImpl.getDeployments(ProcessEnginePluginImpl.java:59)
          org.jboss.bpm.console.server.EngineFacade.getDeployments(EngineFacade.java:75)
          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          java.lang.reflect.Method.invoke(Method.java:597)
          org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:117)
          org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:260)
          org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:232)
          org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:166)
          org.jboss.resteasy.core.DispatcherUtilities.getJaxrsResponse(DispatcherUtilities.java:142)
          org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)
          org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:173)
          org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:93)
          org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:68)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          org.jboss.bpm.console.server.util.GWTJsonFilter.doFilter(GWTJsonFilter.java:59)

      root cause

      org.jbpm.api.JbpmException
          org.jbpm.pvm.internal.xml.ProblemList.getJbpmException(ProblemList.java:171)
          org.jbpm.pvm.internal.xml.ProblemList.getJbpmException(ProblemList.java:141)
          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          java.lang.reflect.Method.invoke(Method.java:597)
          org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:197)
          org.jbpm.pvm.internal.repository.DeploymentImpl_$$_javassist_27.getJbpmException(DeploymentImpl_$$_javassist_27.java)
          org.jbpm.pvm.internal.repository.DeployerManager.deploy(DeployerManager.java:50)
          org.jbpm.pvm.internal.repository.RepositorySessionImpl.getObject(RepositorySessionImpl.java:129)
          org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl.execute(ProcessDefinitionQueryImpl.java:72)
          org.jbpm.pvm.internal.query.AbstractQuery.execute(AbstractQuery.java:87)
          org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
          org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
          org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
          org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
          org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
          org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
          org.jbpm.pvm.internal.query.AbstractQuery.untypedList(AbstractQuery.java:68)
          org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl.list(ProcessDefinitionQueryImpl.java:141)
          org.jbpm.integration.console.ProcessEnginePluginImpl.getDeployments(ProcessEnginePluginImpl.java:59)
          org.jboss.bpm.console.server.EngineFacade.getDeployments(EngineFacade.java:75)
          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          java.lang.reflect.Method.invoke(Method.java:597)
          org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:117)
          org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:260)
          org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:232)
          org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:166)
          org.jboss.resteasy.core.DispatcherUtilities.getJaxrsResponse(DispatcherUtilities.java:142)
          org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)
          org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:173)
          org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:93)
          org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:68)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          org.jboss.bpm.console.server.util.GWTJsonFilter.doFilter(GWTJsonFilter.java:59)

      root cause

      org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'condition'. One of '{"http://jbpm.org/4.0/jpdl":event-listener, "http://jbpm.org/4.0/jpdl":hql, "http://jbpm.org/4.0/jpdl":sql, "http://jbpm.org/4.0/jpdl":java, "http://jbpm.org/4.0/jpdl":script, "http://jbpm.org/4.0/jpdl":mail}' is expected.
          com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
          com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
          com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
          com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
          com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:410)
          com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3165)
          com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1777)
          com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:705)
          com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)
          com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2747)
          com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
          com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
          com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
          com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
          com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
          com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
          com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
          com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
          org.jbpm.pvm.internal.xml.Parser.buildDom(Parser.java:452)
          org.jbpm.pvm.internal.xml.Parser.execute(Parser.java:389)
          org.jbpm.pvm.internal.xml.Parse.execute(Parse.java:158)
          org.jbpm.pvm.internal.repository.ProcessDeployer.deploy(ProcessDeployer.java:68)
          org.jbpm.pvm.internal.repository.DeployerManager.deploy(DeployerManager.java:46)
          org.jbpm.pvm.internal.repository.RepositorySessionImpl.getObject(RepositorySessionImpl.java:129)
          org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl.execute(ProcessDefinitionQueryImpl.java:72)
          org.jbpm.pvm.internal.query.AbstractQuery.execute(AbstractQuery.java:87)
          org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
          org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
          org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
          org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
          org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
          org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
          org.jbpm.pvm.internal.query.AbstractQuery.untypedList(AbstractQuery.java:68)
          org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl.list(ProcessDefinitionQueryImpl.java:141)
          org.jbpm.integration.console.ProcessEnginePluginImpl.getDeployments(ProcessEnginePluginImpl.java:59)
          org.jboss.bpm.console.server.EngineFacade.getDeployments(EngineFacade.java:75)
          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          java.lang.reflect.Method.invoke(Method.java:597)
          org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:117)
          org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:260)
          org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:232)
          org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:166)
          org.jboss.resteasy.core.DispatcherUtilities.getJaxrsResponse(DispatcherUtilities.java:142)
          org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)
          org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:173)
          org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:93)
          org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:68)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          org.jboss.bpm.console.server.util.GWTJsonFilter.doFilter(GWTJsonFilter.java:59)