Hi
On Fri, Aug 6, 2010 at 11:02 AM, Oliver Schmitz-Hennemann <
[email protected]> wrote:
> Hi Everybody,
>
> we have implemented a REST webservice using CXF 2.2.6 and jaxb 2.1.5
> running
> in a tomcat 6.0.10.
> We are experiencing some serious problems concerning perm gen memory usage
> induced by continuously loading classes.
> Having traced around through the code we now know that the problem is
> induced by the fact, that the JaxbContext and within that some Injector
> implementations are only stored in WeakReferences. This each GC removes
> both. So, each Request after a GC will create a lot of classes.
>
I think there may've been some issue fixed in CXF 2.2.6/7 related to a
possible leak.
Dan pointed out the other day that WeakRefs don't make a difference in this
case given that JAXBContexts link to the Classes, so that should not cause
perm gen issues;
> Looking at the AbstractJAXBProvider in org.apache.cxf.jaxrs.provider, it
> seams possible to supply an JAXB Context somehow, but I could not figure
> out, how to do that.
>
>
> protected JAXBContext getJAXBContext(Class<?> type, Type genericType)
> throws JAXBException {
> if (mc != null) {
> ContextResolver<JAXBContext> resolver =
> mc.getResolver(ContextResolver.class, JAXBContext.class);
> if (resolver != null) {
> JAXBContext customContext = resolver.getContext(type);
> if (customContext != null) {
> return customContext;
> }
> }
> }
>
>
> Anybody any idea if this is the rigth solution, and how to make use of it?
>
> Sure, you can register a custom ContextResolver as a regular provider.
Alternatively, you can try to register a custom provider extending
JAXBElementProvider and override one of its createJAXBContext methods. Also
please try 2.2.7 or later and see if the issue has been resolved there
cheers, Sergey
> Oli
>