Uploaded image for project: 'Red Hat Decision Manager'
  1. Red Hat Decision Manager
  2. RHDM-814

KIE Server REST Command GetObjects with ObjectFilter not working

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • None
    • 7.1.0.GA
    • Kie-Server
    • None
    • RHEL 7.5, EAP 7.1.0, RHDM 7.1.0.GA

    • Hide

      1. Create a drools project with few rules in it.
      2. Model the rules in such a way that some Facts are inserted into the Working memory as a part of the RHS like this.

      rule "Rule 5"
          when
             eval(1 == 1)
          then
          	insert(new a.b.c.PotentialFraudFact("Fire"));
      end
      

      3. Package and deploy the KJAR into KIE server and create a container.
      4. Invoke the REST API /server/containers/instances/

      {id}

      or use RuleServicesClient to fire the rules.
      5. In the GetObjects command specify a filter (ClassObjectFilter) for the inserted fact. KIE server will throw a ClassNotFoundException
      6. In the GetObjects command specify a filter (ClassObjectSerializationFilter) for the inserted fact. KIE server will return back all facts without considering the specified filter.

      Show
      1. Create a drools project with few rules in it. 2. Model the rules in such a way that some Facts are inserted into the Working memory as a part of the RHS like this. rule "Rule 5" when eval(1 == 1) then insert( new a.b.c.PotentialFraudFact( "Fire" )); end 3. Package and deploy the KJAR into KIE server and create a container. 4. Invoke the REST API /server/containers/instances/ {id} or use RuleServicesClient to fire the rules. 5. In the GetObjects command specify a filter (ClassObjectFilter) for the inserted fact. KIE server will throw a ClassNotFoundException 6. In the GetObjects command specify a filter (ClassObjectSerializationFilter) for the inserted fact. KIE server will return back all facts without considering the specified filter.
    • 2020 Week 10-12 (from Mar 2)

    Description

      Filtering the facts in the GetObjectsCommand doesn't do any object filtering!.

      Here are the two code pieces that were used to set the ObjectFilter into GetObjectsCommand, but didn't produce the expected filtered results.

      Trial 1:

      ObjectFilter filter = new ObjectFilter() {
      			@Override
      			public boolean accept(Object object) {
      				return object.getClass().getName().equals("a.b.c.PotentialFraudFact");
      			}
      		};
       
      		Command<?> getObjects = commandsFactory.newGetObjects(filter, "out");
      
      

      Trial 2:

      ClassObjectSerializationFilter filter = new ClassObjectSerializationFilter(PotentialFraudFact.class);
      		Command<?> getObjects = commandsFactory.newGetObjects(filter, "out");
      
      

      In the response, the "out" identifier has all facts, not just the ones matching the given filter. It's as if it ignores the filter. Also, no error messages appear in the console.

      When a ClassObjectFilter is used instead of the aforementioned implementations, a ClassNotFoundException (shown below) for the a.b.c.PotentialFraudFact.class occurs. This is incorrect as the deployed container/KJAR has this class!.

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: java.lang.ClassNotFoundException: a.b.c.PotentialFraudFact from [Module "deployment.kie-server.war" from Service Module Loader]
      	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
      	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
      	at java.lang.Class.forName0(Native Method)
      	at java.lang.Class.forName(Class.java:264)
      	at org.drools.core.ClassObjectSerializationFilter.accept(ClassObjectSerializationFilter.java:50)
      	... 73 more
      
      

      The issue is with this line https://github.com/kiegroup/drools/blob/4c6856223b8be47b4fc52c35423be8b50e46b501/drools-core/src/main/java/org/drools/core/ClassObjectSerializationFilter.java#L50 where the class loader used to find the class couldn't find the class that corresponds to the given Fact.

      Attachments

        Issue Links

          Activity

            People

              mfusco@redhat.com Mario Fusco
              balki404 Balakrishnan Balasubramanian
              Karel Suta Karel Suta
              Karel Suta Karel Suta
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: