Is there a simple way to load resource from my own executing JAR as InputStream without accessing ClassLoader? The problem is that my java.policy restricts accessing ClassLoader (this cannot be changed). I want to load some xml config which I can put anywhere in my JAR, but cannot have it outside the JAR.
Thank you for answers. Actually my problem is not with my own ClassLoader. I'm using XStream, which wants to create some classloader and app crashes with:
java.security.AccessControlException: access denied (java.lang.RuntimePermission createClassLoader) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323) at java.security.AccessController.checkPermiss开发者_Go百科ion(AccessController.java:546) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.SecurityManager.checkCreateClassLoader(SecurityManager.java:594) at java.lang.ClassLoader.(ClassLoader.java:226) at com.thoughtworks.xstream.core.util.CompositeClassLoader.(CompositeClassLoader.java:50)
Class.getResource/getResourceAsStream
.
In fact a class should always be able to get hold of its own class loader, no matter what the security policy.
精彩评论