The error message suggests to me that there is no class ObjectFactory, or
not where it ought to be, for JAXB to be happy. If you JAXB-annotate your
Java classes by hand, you'll also have to write an ObjectFactory.java.
A little info can be found in my JAXB
tutorial<http://jaxb.java.net/tutorial/section_6_2_4-The-Object-Factor...;.
Also, you could apply xjc to an XML Schema to learn how it's done ;-)
-W
On 2 August 2011 19:11, kkelleyjr <karl.kelley.jr(a)gmail.com> wrote:
Update:
So I have the following as code that I found in a blog by salaboy...
List<String> myDomainClasses = new ArrayList<String>();
myDomainClasses.add("com.test.TestFact");
// I need to create a JAXB context including my domain classes
// to be able to create a JAXB representation to send to the server
JAXBContext jaxbContext =
DroolsJaxbContextHelper.createDroolsJaxbContext(myDomainClasses, null);
TestFact test = new TestFact();
// Once I get my object I need to create
// some commands to execute on the server
// Here I include a reference to the session that
// I define in my Knowledge Context Profile
List<Command> listOCommand = new ArrayList<Command>();
listOCommand.add(new InsertObjectCommand(test, "testFact"));
BatchExecutionCommand cmd = CommandFactory.newBatchExecution(listOCommand,
"ksession1");
// Once I get all I need to send to the server,
// I need to use the JAXB context
// to obtain the JAXB representation.
StringWriter xmlReq = new StringWriter();
javax.xml.bind.Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty("jaxb.formatted.output", true);
marshaller.marshal(cmd, xmlReq);
// I create a HTTPClient to interact with the
// server via REST (HTTP POST)
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpParams params = new BasicHttpParams();
params.setParameter(ClientPNames.DEFAULT_HOST, "localhost");
//Print the JAXB xml that we will send to the server
System.out.println(xmlReq.toString());
// Send the Commands JAXB representation to the server for execution
HttpPost postMethod = new
HttpPost("http://localhost:8080/MyService/kservice/rest/execute");
HttpParams p = new BasicHttpParams();
p.setParameter("command", xmlReq.toString());
postMethod.setParams(p);
HttpResponse response = httpClient.execute(postMethod);
System.out.println(response);
Now I had to change a few things from the blog but it should be basically
the same as the post... I get the following exception...
1872701 [http-8080-1] ERROR processor.DefaultErrorHandler - Failed
delivery
for exchangeId: 839c6b11-3c2a-4106-9118-56417edfbab1. Exhausted after
delivery attempt: 1 caught: java.io.IOException: "null" doesnt contain
ObjectFactory.class or jaxb.index
java.io.IOException: "null" doesnt contain ObjectFactory.class or
jaxb.index
at
org.apache.camel.util.IOHelper.createIOException(IOHelper.java:80)
at
org.apache.camel.util.IOHelper.createIOException(IOHelper.java:72)
at
org.apache.camel.converter.jaxb.JaxbDataFormat.unmarshal(JaxbDataFormat.java:151)
at
org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:51)
Thanks for any advice on this matter...
--
View this message in context:
http://drools.46999.n3.nabble.com/Insert-a-fact-into-drools-server-from-a...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users