IBM Support

Methods to create a JAXBContext for WAS client applications

Troubleshooting


Problem

There are two methods to create a JAXBContext when the client uses JAXB: 1. Provide the list of packages that contain JAXB classes. 2. Provide a list of potential JAXB classes. The client application may be logging errors similar to the ones listed below: - JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils checkPackage looking for xyz/package/framework/webservice/exception/jaxb.index - JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils checkPackage jaxb.index file Not Found: xyz/package/framework/webservice/exception/jaxb.index - JAXBUtils 1 org.apache.axis2.jaxws.message.databinding.JAXBUtils createJAXBContextValue Package xx.bpm.framework.webservice.exception does not contain an ObjectFactory or package-info class. Searching for JAXB classes - javax.xml.bind.JAXBException: xyz.package.finxxx.xxp.webservices.xxyyzz is not known to this context" Creating a JAXBContext to make sure the package can be seen should resolve this problem.

Symptom


Cause

The problem occurs because the client provided a list of potential JAXB classes and the search for those classes failed to include a JAXB class in cases where automatic detection of classes does not work or is too slow.

Diagnosing The Problem

Here are the steps to locating which packages need the jaxb.index file to bypass the slower class search:

1) Enable the following trace string "*=info:com.ibm.ws.webservices.*=all:org.apache.axis2*=all:com.ibm.ws.websvcs.*=all"

2) In the trace log, search for "does not contain an ObjectFactory"
3) For each package with this comment, add the jaxb.index file to the package listing the JAXB classes in that package.
4) If a package is listed as "does not contain an ObjectFactory" and does not contain any JAXB classes, include an empty jaxb.index file in that package.

Resolving The Problem

There are two methods to create a JAXBContext.

1) Provide the list of packages that contain JAXB classes. This is the most preferred approach because we do not have to search for potential JAXB classes.

To use this option, each package in the list of packages must contain an ObjectFactory class or a jaxb.index file (jaxb.index files are used with bottom up development where the tooling does not create ObjectFactory classes). An Ifix implemented jaxb.index file support in 7.0.0.25.

The jaxb.index files are manually added to the application by the developer and they list the JAXB classes within a packages that are used by the application.

2) Provide a list of potential JAXB classes. This approach is used if ANY package in the package list does not contain an ObjectFactory class or a jaxb.index file. This approach takes longer because we have to examine all class files in the classpath and try to identify which are potential JAXB classes.

In cases where automatic detection of classes does not work or is too slow, a jaxb.index file can be used to resolve the problem

To find out which packages require the jaxb.index file, search the trace file for the following string: "does not contain an ObjectFactory"

The recommendation is to create a jaxb.index file that lists the JAXB classes for each of the packages. Then place the file within the class path (perhaps in the jar at the package location).

The next time you test this operation, there should be no trace with "does not contain an ObjectFactory" and the JAXBContext creation should be successful using the package name and not have to search for classes. If the "not known to context" message persists, ensure the missing JAXB class is in the jaxb.index file for that package.

In order for the jaxb.index to be of value, ALL packages used during the JAXBContext creation must contain either an ObjectFactory class or a jaxb.index file which lists the JAXB classes.

Following APAR also provide additional information and requirement

http://www-01.ibm.com/support/docview.wss?uid=swg1PM56170

http://www-01.ibm.com/support/docview.wss?uid=swg1PM59472

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Web Services (for example: SOAP or UDDI or WSGW or WSIF)","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.0;8.5;8.0;7.0.0.27;7.0.0.25","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21634869