Too many JAXB Contexts are beeing created in Switchyard

Solution In Progress - Updated -


We are exposing business logic in our Switchyard applications via SOAP services. The data transfer objects used to call the internal web services is based on the internal data model, which is quite huge. In our Switchyard implementations we are using java to java transformations, transforming the incoming data to the JAXB data transfer objects and vice versa. The JABX objects are then transformed to and from XML using switchyard JAXB transformers. In some projects we’re having more than 10 of them registered.

The Problem:
For every transformation a new JAXB context is created. Instantiating a JAXB context takes ~10s on a developers machine and is consuming lots of memory. We’re also noticing the excessive memory consumption on our production machines compared to the actually small number of deployments we have. This happens already during startup of JBoss servers.

Our analysis shows the JAXB context creation take places here:

package org.switchyard.transform.jaxb.internal;

public class JAXBTransformerFactory implements TransformerFactory<JAXBTransformModel> {

    public Transformer<?, ?> newTransformer(JAXBTransformModel model) {

        QName fromType = model.getFrom();
        QName toType = model.getTo();

        if (toJavaTransformType(fromType, toType) == JavaTransformType.JAVA2XML) {
            return new JAXBMarshalTransformer(fromType, toType, model.getContextPath());
        } else {
            return new JAXBUnmarshalTransformer(fromType, toType, model.getContextPath());

It would definitely help to have one JAXBContext per context path per deployment. Sharing them across deployments would be even better.


  • Red Hat JBoss Fuse Service Works
    • 6.0.0
  • Red Hat JBoss Fuse (on EAP)
    • 6.2.1
    • 6.3.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content