I think that you are facing the same question as me.
private static JAXBContext createJAXBContext() throws Exception { return isJDKInternal()?(JAXBContext)AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() { public JAXBContext run() throws Exception { return JAXBContext.newInstance(MetroConfig.class.getPackage().getName()); } }, createSecurityContext()):JAXBContext.newInstance(MetroConfig.class.getPackage().getName()); } private static AccessControlContext createSecurityContext() { PermissionCollection perms = new Permissions(); perms.add(new RuntimePermission("accessClassInPackage.com.sun.xml.internal.ws.runtime.config")); perms.add(new ReflectPermission("suppressAccessChecks")); return new AccessControlContext(new ProtectionDomain[]{new ProtectionDomain((CodeSource)null, perms)}); }
this code is in the MetroConfigLoader JDK, it will load the resource with a certain privilege, and this is the main reason, so you can use jaxws-rt , which is the third part of lib to implement it,
Or you can load your resource in your classloader using AccessController.doPrivileged so that you can access your resource.
source share