XFire

JAXBContext not reused if web service clients use the same schema

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.2.1
  • Fix Version/s: 1.2.2
  • Component/s: JAXB 2.0
  • Labels:
    None
  • Environment:
    Java 5, Tomcat 5.5, and JAXB 2.0 (or JAXB 2.1)
  • Number of attachments :
    1

Description

XFire creates an instance of JAXBContext for each web service (I think it might actually be one per "type" sent to or returned from a service). If all the web services use the same schema, this results in duplicate instances of the JAXBContext, which wastes memory. Quite a lot of memory if you have a large object model in JAXB.

You could possibly work around this by splitting the schema up, but this isn't possible in our case as we don't control the schema.

A possible solution would be to move the JAXB context creation to JaxbTypeCreator and have it shared amongst all the instances of JaxbType it creates. Basically the idea is to pull the creation of JAXBContext high enough that it's only done once per schema rather than once per type.

Activity

Hide
Dan Everton added a comment -

This patch does mostly what I need. It lets you pass an existing JAXBContext to a JaxbServiceFactory. The context is then used by all layers from there. Now I can use the same schema across multiple services and not run out of heap.

The JAXBContext should be thread-safe so I don't think there are any threading issues.

Show
Dan Everton added a comment - This patch does mostly what I need. It lets you pass an existing JAXBContext to a JaxbServiceFactory. The context is then used by all layers from there. Now I can use the same schema across multiple services and not run out of heap. The JAXBContext should be thread-safe so I don't think there are any threading issues.
Hide
Dan Everton added a comment -

Note the above patch is against the XFire 1.2.1 source as I can't get the SVN repository through the proxy at work.

Show
Dan Everton added a comment - Note the above patch is against the XFire 1.2.1 source as I can't get the SVN repository through the proxy at work.
Hide
Dan Diephouse added a comment -

Thanks, applied.

Show
Dan Diephouse added a comment - Thanks, applied.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: