I'm trying to convert a bean to an XML file using Jaxb and Camel. All of the examples I see in books and online follow a similar format but it just doesnt work for me. It could be my bean, but I'm not sure.
I get the following error:
[ERROR] Failed to execute goal org.apache.camel:camel-maven-plugin:2.12.0.redhat-610379:run (default-cli) on project simple-route: null: MojoExecutionException: InvocationTargetException: org.apache.camel.util.ObjectHelper.notNull(Ljava/lang/Object;Ljava/lang/String;)V -> [Help 1] [ERROR]
I have a hashmap but I'm also populating fields. The reason for that is that I was just trying to see what worked. I'm not really attached to either, though I think Jaxb uses the fields.
heres my route, then my bean
<bean id="mockSql" class="tutorial.simple.route.MockSql"/>
<camelContext id="camel" xmlns="http://ift.tt/TZ5qsO">
<route>
<from uri="bean:mockSql?method=populate"/>
<marshal ref="mockSql" id="jb1" customId="true">
<jaxb contextPath="tutorial.simple.route"/>
</marshal>
<to uri="file:target/messages/other"/>
</route>
</camelContext>
</beans>
now my bean
package tutorial.simple.route;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.camel.CamelContext;
import org.apache.camel.Handler;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
public class MockSql {
private String name="name";
private String job="job";
private static final Logger log = Logger.getLogger("mockSql");
ArrayList <HashMap> ary = new ArrayList<HashMap>();
public MockSql() throws Exception{
// CamelContext context = new DefaultCamelContext();
log.setLevel(Level.DEBUG);
log.debug("constructed mock sql \n \n");
}
@Handler
public ArrayList<HashMap> populate(){
HashMap<String, String> hm = new HashMap();
HashMap<String, String> hm2 = new HashMap();
hm.put("n1", "j1");
hm2.put("n2", "j2");
ary.add(hm);
ary.add(hm2);
log.debug("populated mock sql");
return ary;
}
}
No comments:
Post a Comment