Skip to main content

AccessControlException when loading XML in Applet, using JAXB 2.1.2

2 replies [Last post]
Joined: 2006-12-21

I have an applet that loads XML files via JAXB. I wrote XML schema, generated Java code using XJC. Everything just worked fine with JAXB 1.0. Recently, I decided to upgrade to JAXB 2.1.2 (the latest stable version available). I regenerated Java code from schema using 2.1.2's XJC, modified my code to fit the newly generated code. Then I got the following exception while loading the applet: access denied (java.lang.RuntimePermission accessDeclaredMembers)
at Source)
at Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkMemberAccess(Unknown Source)
at java.lang.Class.checkMemberAccess(Unknown Source)
at java.lang.Class.getDeclaredMethods(Unknown Source)
at sun.reflect.annotation.AnnotationType.(Unknown Source)
at sun.reflect.annotation.AnnotationType.getInstance(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(Unknown Source)
at java.lang.Class.initAnnotationsIfNecessary(Unknown Source)
at java.lang.Class.getAnnotation(Unknown Source)
at com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getClassAnnotation(
at com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getClassAnnotation(
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(
at com.sun.xml.bind.v2.ContextFactory.createContext(
at com.sun.xml.bind.v2.ContextFactory.createContext(
at com.sun.xml.bind.v2.ContextFactory.createContext(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(
at javax.xml.bind.ContextFinder.find(
at javax.xml.bind.JAXBContext.newInstance(
at javax.xml.bind.JAXBContext.newInstance(
at ...

It seems that the AccessControlException happened when JAXB tried to get annotation from certain class(es). I also noticed that the JAXB 2.1.2 code and the code generated by JAXB 2.1.2's XJC use annotations a lot.

My question: is annotation retrieval generally prohibited by Java applet's security restriction or this is caused by a bug in JAXB 2.1.2 so that it doesn't work with Java applet?

BTW, signed applet does solve the issue, however, signed applet is not an option for us.


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-04-30

Did you find a resolution to this?

This would be a limiting factor in using this technology
if this won't work. Have you tried Apache's XMLBeans?

Joined: 2003-06-09

> My question: is annotation retrieval generally prohibited by Java applet's security restriction

I think you need to ask that question to the right folks.

> this is caused by a bug in JAXB 2.1.2 so that it doesn't work with Java applet?

I don't think this is a problem in JAXB. We are just calling getAnnotation method.