users@jersey.java.net

[Jersey] Re: Class com.sun.jersey.server.linking.impl.FieldDescriptor can not access a member of class java.util.zip.ZipConstants with modifiers "public static final"

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Tue, 4 Jan 2011 10:18:43 +0100

Hi Paul,

Agreed, Can you log an issue?

Thanks,
Paul.

On Jan 4, 2011, at 1:26 AM, Paul Apostolescu wrote:

> I'm running into the following exception when using the link support:
>
> Jan 3, 2011 6:51:21 PM
> com.sun.jersey.server.linking.impl.FieldDescriptor getFieldValue
> SEVERE: null
> java.lang.IllegalAccessException: Class
> com.sun.jersey.server.linking.impl.FieldDescriptor can not access a
> member of class java.util.zip.ZipConstants with modifiers "public
> static final"
> at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:
> 65)
> at java.lang.reflect.Field.doSecurityCheck(Field.java:960)
> at java.lang.reflect.Field.getFieldAccessor(Field.java:896)
> at java.lang.reflect.Field.get(Field.java:358)
> at
> com
> .sun
> .jersey
> .server
> .linking.impl.FieldDescriptor.getFieldValue(FieldDescriptor.java:66)
> at
> com
> .sun
> .jersey
> .server.linking.impl.RefProcessor.processLinks(RefProcessor.java:113)
> at
> com
> .sun
> .jersey
> .server.linking.impl.RefProcessor.processMember(RefProcessor.java:120)
> <a lot more of the same>
> at
> com
> .sun
> .jersey
> .server.linking.impl.RefProcessor.processLinks(RefProcessor.java:72)
> at
> com.sun.jersey.server.linking.LinkFilter.filter(LinkFilter.java:78)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl._handleRequest(WebApplicationImpl.java:1310)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:1239)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .application
> .WebApplicationImpl.handleRequest(WebApplicationImpl.java:1229)
> at
> com
> .sun
> .jersey.spi.container.servlet.WebComponent.service(WebComponent.java:
> 420)
> at
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:497)
> at
> com
> .sun
> .jersey
> .spi
> .container.servlet.ServletContainer.service(ServletContainer.java:684)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:
> 820)
> at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
> at org.mortbay.jetty.servlet.ServletHandler
> $CachedChain.doFilter(ServletHandler.java:1221)
> <etc>
>
> The exception is caused by RefProcessor not stopping when it gets to
> fields of primitive types, for example the following document:
> <Links><Link>One</Link></Links>
>
> will be processed as follows:
> - RefProcessor calls processLinks / processMember until it we get to
> "One" (the string)
> - from here the string "One" is processed via processLinks, "count"
> field is found
> - the int "count" is processed via processLinks, MAX_INTEGER is found
> - MAX_INTEGER is processed via processLinks, "serialVersionUUID" is
> found
> .... etc ...
> - until the execution finally gets to a JarFile instance where the
> "CENFLG" field throws the IllegalAccessException.
>
> IMO the types that are outside of user's control (like primitive
> types, java.lang, etc) should not be processed, it will not only
> prevent errors like the one above but also speed up response
> processing.
>
>
> Thanks
> - Paul
>
>