[
https://issues.redhat.com/browse/DROOLS-5534?page=com.atlassian.jira.plug...
]
Enrique González Martínez commented on DROOLS-5534:
---------------------------------------------------
This is kinda strange:
{code}
@Override
public ServiceResponse<ExecutionResults> callContainer(String containerId,
String payload, MarshallingFormat marshallingFormat, String classType) {
if( payload == null ) {
return new
ServiceResponse<ExecutionResults>(ServiceResponse.ResponseType.FAILURE, "Error
calling container " + containerId + ". Empty payload. ");
}
try {
KieContainerInstanceImpl kci = (KieContainerInstanceImpl)
context.getContainer( containerId, ContainerLocatorProvider.get().getLocator());
if (kci != null && kci.getKieContainer() != null) {
Class<? extends Command> type = BatchExecutionCommandImpl.class;
if (classType != null && !classType.isEmpty()) {
type = (Class<? extends Command>)
kci.getKieContainer().getClassLoader().loadClass(classType);
}
Command<?> cmd = kci.getMarshaller( marshallingFormat
).unmarshall(payload, type);
if (!(cmd instanceof BatchExecutionCommandImpl)) {
cmd = new BatchExecutionCommandImpl(Arrays.asList(new
ExecutableCommand<?>[]{(ExecutableCommand<?>) cmd} ));
}
if (cmd == null || ((BatchExecutionCommandImpl)cmd).getCommands() == null
|| ((BatchExecutionCommandImpl)cmd).getCommands().isEmpty()) {
return new
ServiceResponse<ExecutionResults>(ServiceResponse.ResponseType.FAILURE, "Bad
request, no commands to be executed - either wrong format or no data");
}
ExecutionResults results = rulesExecutionService.call(kci,
(BatchExecutionCommandImpl) cmd);
return new
ServiceResponse<ExecutionResults>(ServiceResponse.ResponseType.SUCCESS,
"Container " + containerId + " successfully called.", results);
} else {
return new
ServiceResponse<ExecutionResults>(ServiceResponse.ResponseType.FAILURE,
"Container " + containerId + " is not instantiated.");
}
} catch (Exception e) {
logger.error("Error calling container '" + containerId +
"'", e);
return new
ServiceResponse<ExecutionResults>(ServiceResponse.ResponseType.FAILURE, "Error
calling container " + containerId + ": " + e.getMessage());
}
}
{code}
this use the next line to deserialize
{code}
Command<?> cmd = kci.getMarshaller( marshallingFormat ).unmarshall(payload, type);
{code}
which uses the kie container instance class loader which is presumed to hold all the
classes for the project. I don't see why this is failing.
MarshallingException occurs during REST request (JSON) unmarshalling
in KIE server.
-----------------------------------------------------------------------------------
Key: DROOLS-5534
URL:
https://issues.redhat.com/browse/DROOLS-5534
Project: Drools
Issue Type: Bug
Components: kie server
Affects Versions: 7.40.0.Final
Reporter: Toshiya Kobayashi
Assignee: Toshiya Kobayashi
Priority: Major
Attachments: full_error_messages.txt, reproducer_02699633_1.zip
A user's decision service deployed on KIE server receives REST commands from client,
MarshallingException due to class loading failure occurs during JSON unmarshalling before
the commands are processed. I attached a simplified reproducer reproducer_02699633_1.zip
expressing the issue, and the error message is like below:
{noformat}
Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve
type id 'com.example.reproducer.common.params.ContactParam' as a subtype of
[simple type, class com.example.reproducer.common.base.IRuleParam]: no such class found
at [Source: (String)"{ "lookup" : "ksession-rules",
"commands" : [ { "insert" : { "object" : {
"com.example.reproducer.common.base.Fact1": { "parameter" : {
"@class" :
"com.example.reproducer.common.params.ContactParam",
"contactInfo" : 123456789 } } } } }, {
"fire-all-rules" : "" } ]}"; line: 1, column: 185] (through
reference chain:
org.drools.core.command.runtime.BatchExecutionCommandImpl["commands"]->java.util.ArrayList[0]->org.drools.core.command.runtime.rule.InsertObjectCommand["object"]->com.example.reproducer.common.base.Fact1["parameter"])
{noformat}
For full error messages, see full_error_messages.txt in Attachment.
The user's decision service (kjar) uses classes in another module jar as a library.
ContactParam class which is a sub type of IRuleParam interface is in the kjar and
IRuleParam interface is in the module jar.
Also, @JsonTypeInfo(use = Id.CLASS) annotation is given to IRuleParam like below in
order for JSON implementation to recognize a given class to Fact1.parameter as a sub type
of IRuleParam.
{code:java}
@JsonTypeInfo(use = Id.CLASS)
public interface IRuleParam {
}
{code}
Both classes contained in the module jar and classes in the kjar should be loaded.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)