Hi, I am currently trying to tune the performance of my CXF Client, and I noticed that during Service creation, the JAXBContext keeps getting created even if I'm hitting the same endpoint just with different clients. I looked into the CXF source, and I see that there is a caching mechanism that's supposed to keep the context (org.apache.cxf.common.jaxb.JAXBContextCache), but for one reason or another, the cache lookup almost always fails. It seems like since the cache uses WeakReferences to hold the context, the context gets garbage collected almost immediately and has to be recreated each time. My calls to the same endpoint happen only a few seconds apart so I'm a little surprised that it gets collected that quickly.
When I modified the JAXBContextCache (actually it's inner class CachedContextAndSchemas) to use direct references instead of WeakReference, this problem went away. The caching worked as expected and service creation went much faster. But I would really prefer not to modify the cxf source, so I'm wondering if there's something that I'm missing or something that I can do so I can avoid rolling my own cxf build? I've looked into just keeping a reference of the JAXBContext in my code to prevent it from being garbage collected, but it's pretty deep into the cxf code and it doesn't seem like there was a clean way of doing it. -- View this message in context: http://cxf.547215.n5.nabble.com/JAXBContext-caching-and-WeakReferences-tp5711383.html Sent from the cxf-user mailing list archive at Nabble.com.
