[rules-users] Inserting Facts from Json Format

ekzl at yahoo.com ekzl at yahoo.com
Thu Jul 5 12:11:42 EDT 2012


Hi,

I'm facing the same problem.

The following code works fine if i know upfront wht the object should be:

		ObjectMapper mapper = new ObjectMapper();
		FactType type = kbase.getFactType("eu.mc2bis.events",
"DeviceEventDeclared");		
		System.out.println ("Actual type:" + type.getFactClass() );
		
		Object event;
		try
		{
			event = mapper.readValue(arg2, type.getFactClass());
			session.insert(event);
			session.fireAllRules();
		}
		catch (JsonParseException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		catch (JsonMappingException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		

So actually this means that the class is available from the classloader now
when i do the same using BatchExecutionHelper.newJSonMarshaller() i get a
.the following exception:

Exception in thread "main"
com.thoughtworks.xstream.converters.ConversionException:
eu.mc2bis.events.DeviceEventDeclared : eu.mc2bis.events.DeviceEventDeclared
---- Debugging information ----
message             : eu.mc2bis.events.DeviceEventDeclared
cause-exception     :
com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : eu.mc2bis.events.DeviceEventDeclared
class               : org.drools.command.runtime.rule.InsertObjectCommand
required-type       : org.drools.command.runtime.rule.InsertObjectCommand
converter-type      :
org.drools.runtime.help.impl.XStreamJSon$JSonInsertConverter
line number         : -1
class[1]            : org.drools.command.runtime.BatchExecutionCommandImpl
converter-type[1]   :
org.drools.runtime.help.impl.XStreamJSon$JSonBatchExecutionCommandConverter
version             : null

Any help would be  appreciated,

Regards,
e



--
View this message in context: http://drools.46999.n3.nabble.com/Inserting-Facts-from-Json-Format-tp3570810p4018491.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list