BlackBerry Administration API (BAA) application throws an "Unmarshalling Error"

by Retired on ‎10-21-2010 01:43 PM (5,877 Views)

Symptoms

This article applies to BlackBerry® Administration API (BAA) applications written in Java® using Apache CXF™ as the web service framework.

 

When using a proxy that was compiled against a different version of BlackBerry® Enterprise Server (BES) than the one currently targeted there is the potential to receive and "Unmarshalling Error" when making certain calls. The full error will resemble this:

 

org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"", local:"<element_name>"). Expected elements are <list_of_expected_elements>

Diagnosis

Between iterations of the BAA it can be expected that there will be elements added to classes that add more functionality. These additional elements are exposed in the respective versions of BAA and will normally be ignored if using a proxy generated from an earlier BES version where these elements were not yet available.

 

In earlier versions of Apache CXF the above scenario would function fine, any undefined elements received would not negatively effect the application. Beginning with Apache CXF 2.2.5, a JAXB ValidationEventHandler has been turned on that will error whenever an unexpected element is received. The result of this change is that when one of these unexpected elements is returned to the client BAA application an exception will be thrown causing the call to fail.

 

Note: This is not a bug with Apache CXF, it is just another layer of validation on the returned data.

Solution

It is possible to disable this additional validation from within your application. One way that will disable this for all calls throughout your application is to set the "set-jaxb-validation-event-handler" property to 'false' on the default Bus object using the following static call:

 

 

BusFactory.getDefaultBus().setProperty("set-jaxb-validation-event-handler", false);

 

 

This could be placed in the same section of the application that sets up the Web Service stubs and credentials.