Error calling container "xxxxxx": Error unmarshalling input.... HELP!!

1,426 views
Skip to first unread message

Daniel Paredes

unread,
Dec 19, 2017, 9:44:21 AM12/19/17
to Drools Usage
Hello everyone!.... I'm working with kie server and kie workbench 7.3 and when I have a problem when I send a POST to the server
{
  "type" : "FAILURE",
  "msg" : "Error calling container xxxxxxxxxx: Error unmarshalling input",
  "result" : null
}

i have this to object:

package prueba;

import java.util.ArrayList;
import java.util.List;

public class GroupsOfFlights {

    private String internalGDSKey;

    private List<Flights> flights;

    public String getInternalGDSKey() {
        return internalGDSKey;
    }

    public void setInternalGDSKey(String internalGDSKey) {
        this.internalGDSKey = internalGDSKey;
    }

    public List<Flights> getFlights() {
        return flights;
    }

    public void setFlights(List<Flights> flights) {
        this.flights = flights;
    }

   
}

*****************************
and

package prueba;

public class Flights {

    private String marketingCarrier;

    private int flightNumber;


    public Flights(String marketingCarrier, int flightNumber) {
        super();
        this.marketingCarrier = marketingCarrier;
        this.flightNumber = flightNumber;
    }


    public String getMarketingCarrier() {
        return marketingCarrier;
    }


    public void setMarketingCarrier(String marketingCarrier) {
        this.marketingCarrier = marketingCarrier;
    }


    public int getFlightNumber() {
        return flightNumber;
    }


    public void setFlightNumber(int flightNumber) {
        this.flightNumber = flightNumber;
    }

   

}
*******************************
and the rule is:

package prueba;

 
import prueba.*;
import java.util.ArrayList;
import java.util.List;


rule "Platinum Customer"
salience 100
lock-on-active true

when
  gf : GroupsOfFlights( internalGDSKey == "asd1")
  items : List( size == gf.flights.size() ) from collect ( Flights( marketingCarrier == "AV" ) from gf.flights )
then
  gf.setInternalGDSKey("sdk");
  System.out.println("Flight Key: " + gf.getInternalGDSKey());
  update(gf);
end
***********************************

but when i send d json through Postman I have an error mention.

this is my json:
{
  "commands": [
    {
      "insert": {
        "out-identifier": "flights",
        "return-object": "true",
        "object": {
          "prueba.GroupsOfFlights": {
            "internalGDSKey": "sdk",
            "flights": [
              {
                "marketingCarrier": "XX"
              }
            ]
          }
        }
      }
    },
    {
      "fire-all-rules": ""
    }
  ]
}


Please Help! Thanks!

Maciej Swiderski

unread,
Dec 20, 2017, 2:30:37 AM12/20/17
to drools...@googlegroups.com
This might be because of type erasure and your List<Fligts> becomes List<Object> and thus it might not know how to put the data in. So I’d try to include type information in the array as well:

this is my json:
{
  "commands": [
    {
      "insert": {
        "out-identifier": "flights",
        "return-object": "true",
        "object": {
          "prueba.GroupsOfFlights": {
            "internalGDSKey": "sdk",
            "flights": [
              {               
          "prueba.GroupsOfFlights”:  {"marketingCarrier": “XX”
}
              }
            ]
          }
        }
      }
    },
    {
      "fire-all-rules": ""
    }
  ]
}

Anyway, best way to find the payload is to use KieServer’s Marshaller.JSON to serialize the data and thus have complete and expected format.

Maciej
--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/58b68d9b-b95e-498c-8c8f-cc3952e8f097%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Paredes

unread,
Dec 20, 2017, 9:23:34 AM12/20/17
to Drools Usage
Hello Maciej, I really appreciate your answer!

I would like to know more about this: "best way to find the payload is to use KieServer’s Marshaller.JSON to serialize the data and this have complete and expected format."

You know where I can find an example? I would appreciate your help
.
W
hat I'm trying to do is that a rule can compare all the values of a list object, so for example, if all values are "true",it change the value of another attribute.

I was trying as you told me but the error
the error continues. This is the server log:

[31m10:05:29,130 ERROR [org.kie.server.services.drools.DroolsKieContainerCommandServiceImpl] (default task-32) Error calling container 'listObjectProject_1.0.5': org.kie.server.api.marshalling.MarshallingException: Error unmarshalling input
    at org.kie.server.api.marshalling.json.JSONMarshaller.unmarshall(JSONMarshaller.java:282)
    at org.kie.server.services.drools.DroolsKieContainerCommandServiceImpl.callContainer(DroolsKieContainerCommandServiceImpl.java:60)
    at org.kie.server.remote.rest.drools.CommandResource.manageContainer(CommandResource.java:73)
    at sun.reflect.GeneratedMethodAccessor305.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:402)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:209)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    at io.undertow.server.handlers.DisableCacheHandler.handleRequest(DisableCacheHandler.java:33)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:53)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:59)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
    at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
    at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
    at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of prueba.Flights out of START_ARRAY token
 at [Source:  {

     "commands":[
       {
          "insert":{
             "out-identifier":"flights",
             "return-object":"true",
             "object": {
               "prueba.GroupsOfFlights":{
                 "internalGDSKey":"sdk",
                 "flights":[
                     {
                     "prueba.Flights":{"marketingCarrier":"sasa"}
                     }
                     ]
               }
             }
           }
       },
       {
          "fire-all-rules":""
       }
     ]
  }; line: 10, column: 28] (through reference chain: org.drools.core.command.runtime.BatchExecutionCommandImpl["commands"]->java.util.ArrayList[0]->org.drools.core.command.runtime.rule.InsertObjectCommand["object"]->prueba.GroupsOfFlights["flights"])
    at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:255)
    at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:971)
    at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:967)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromArray(BeanDeserializerBase.java:1293)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:159)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:135)
    at org.kie.server.api.marshalling.json.JSONMarshaller$CustomAsWrapperTypeDeserializer.deserializeTypedFromObject(JSONMarshaller.java:789)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeWithType(BeanDeserializerBase.java:1017)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:488)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:95)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:260)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
    at org.kie.server.api.marshalling.json.JSONMarshaller$CustomAsWrapperTypeDeserializer.deserializeTypedFromObject(JSONMarshaller.java:795)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeWithType(BeanDeserializerBase.java:1017)
    at com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:42)
    at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3779)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2050)
    at org.kie.server.api.marshalling.json.JSONMarshaller$CustomObjectDeserializer.mapObject(JSONMarshaller.java:663)
    at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer.deserialize(UntypedObjectDeserializer.java:225)
    at com.fasterxml.jackson.databind.deser.std.StdDelegatingDeserializer.deserialize(StdDelegatingDeserializer.java:160)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:490)
    at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:260)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
    at com.fasterxml.jackson.databind.jsontype.impl.AsWrapperTypeDeserializer._deserialize(AsWrapperTypeDeserializer.java:115)
    at com.fasterxml.jackson.databind.jsontype.impl.AsWrapperTypeDeserializer.deserializeTypedFromObject(AsWrapperTypeDeserializer.java:49)
    at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:142)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:279)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:249)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
    at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:490)
    at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:260)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3807)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2797)
    at org.kie.server.api.marshalling.json.JSONMarshaller.unmarshall(JSONMarshaller.java:280)
    ... 55 more

Thanks!!


Maciej Swiderski

unread,
Dec 21, 2017, 2:38:54 AM12/21/17
to drools...@googlegroups.com
Daniel,
On 20 Dec 2017, at 15:23, Daniel Paredes <daniel.pa...@gmail.com> wrote:

Hello Maciej, I really appreciate your answer!

I would like to know more about this: "best way to find the payload is to use KieServer’s Marshaller.JSON to serialize the data and this have complete and expected format."

You know where I can find an example? I would appreciate your help
.

What I'm trying to do is that a rule can compare all the values of a list object, so for example, if all values are "true",it change the value of another attribute.
try with the marshalles to see what content they produce and if that is still an issue, if so then share your kjar so we can take a look

Maciej

Daniel Paredes

unread,
Dec 21, 2017, 2:37:51 PM12/21/17
to Drools Usage

Maciej Swiderski

unread,
Dec 22, 2017, 7:45:53 AM12/22/17
to drools...@googlegroups.com
these two lines are only for using your objects to print out how the JSON format of it should look like. Keep in mind to add your domain classes to the extraClasses when configuring marshaller so it will use their types

Maciej
Reply all
Reply to author
Forward
0 new messages