Friday, February 26, 2016

JAXB UnmarshalException when converting Payload in Camel

Camel provides camel-jaxb jar  for converting XML to POJO data and vice versa using JAXB data format.
The samples provided in the documentation states that the contextPath should be set to the Java Package of the POJO class for the marshaling and unmarshaling purposes.
But when trying to set the contextPath to a required class package  it throws the exception “javax.xml.bind.UnmarshalException: unexpected element Expected elements are (none)
This is raised because meta-data information is missing and the registryFormat element is not found in the context. This can be fixed by creating the Context with the Object Factory class and using this reference to unmarshal the data. 
JAXBContext jaxbContext = JAXBContext
                           .newInstance(new Class[] { com.test.ObjectFactory.class });
              DataFormat registryFormat = new JaxbDataFormat(jaxbContext);
              from("file:in?noop=true").convertBodyTo(org.w3c.dom.Document.class)
                           .unmarshal(registryFormat)
                           .log("The message after conversion" + "${body}");      

Saturday, January 23, 2016

Unresolved constraint error when installing bundles in Fuse

When installing a bundle in Fuse, it quite common  to encounter the Unresolved constraint error: missing requirement: osgi.wiring.package error.
This error is thrown when the packages imported using Felix plugin are in conflict or if the dependent bundles are not installed. 
The article in this link provides a detailed explanation on the cause and fixes for this error 
But for those looking for quick fix ,the following steps would be handy.
  • Use osgi:headers <> to list the manifest details of the bundle.
  • In the manifest details,check for packages are marked in Red in Import-Package Listing. These are the  candidates which potentially cause this error.
  • Verify if the bundle corresponding to the erroneous package is installed and started 
These  steps should help to resolve most of the unresolved constraint exception when installing a bundle.