users@jersey.java.net

[Jersey] cglib and MessageBodyWriters

From: redwine <jack.redwine_at_gmail.com>
Date: Wed, 4 Apr 2012 11:17:17 -0700 (PDT)

I have a scenario where we are returning a cglib enhanced object from a REST
request. And it seems to fail because the @XmlRootElement annotation class
does not have the @inherited annotation. Thus, a writer cannot be found
because

AbstractJAXBElementProvider.java
@Override
public boolean isWriteable(Class<?> type, Type genericType, Annotation
annotations[], MediaType mediaType) {
        return JAXBElement.class.isAssignableFrom(type) &&
isSupported(mediaType);
}

returns false, Because JAXBElement.class.isAssignableFrom(type) returns
false.

I believe this can easily be fixed if I can determine a way to override the
messageBodyFactory so that I can intercept the class and convert the cglib
enhanced class to it's original form. Any Suggestions?

--- more information if you are interested ---

just a little background to help explain the scenario. We are using the
com.sun.jersey.spi.spring.container.servlet.SpringServlet servlet class.
leveraging JSR250 for permission base security. We recently introduced SOAP
and in order to secure those services with JSR250 we added
spring security's global-method-security which creates a cglib enhanced
version of the spring bean to secure the bean based on the JSR250
annotation.

<security:global-method-security jsr250-annotations="enabled"
proxy-target-class="true" />

Because the REST resources are scanned components and contain the JSR250
annotations they are enhanced with cglib as well. In addition we are
returning the resources themselves on many of the rest requests. As a
result the entity being returned is a cglib enhanced entity.

The application works perfectly until I add the
security:global-method-security spring bean.






--
View this message in context: http://jersey.576304.n2.nabble.com/cglib-and-MessageBodyWriters-tp7437555p7437555.html
Sent from the Jersey mailing list archive at Nabble.com.