In my EAR application, I have one class which is a actually a Groovy class loader. In that class I am writting the following code:
////////////////////////////////////////////////////////////////////////////////////////////////////////
System.setProperty("java.security.policy", "=security/groovy.policy");
protected GroovyClassLoader loader = (GroovyClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return new GroovyClassLoader(SecurityTestSupport.class.getClassLoader());
}
});
currentClassLoader = Thread.currentThread().getContextClassLoader();
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
Thread.currentThread().setContextClassLoader(loader);
return null;
}
});
protected Class parseClass(final GroovyCodeSource gcs) {
Class clazz = null;
try {
clazz = loader.parseClass(gcs);
} catch (Exception e) {
fail(e.toString());
}
return clazz;
}
protected void executeScript(Class scriptClass, Permission missingPermission) {
try {
Script script = InvokerHelper.createScript(scriptClass, new Binding());
script.run();
//InvokerHelper.runScript(scriptClass, null);
} catch (AccessControlException ace) {
if (missingPermission != null && missingPermission.implies(ace.getPermission())) {
return;
} else {
fail(ace.toString());
}
}
if (missingPermission != null) {
fail("Should catch an AccessControlException");
}
}
public static void main(String[] arg){
parseAndExecute(new GroovyCodeSource(scriptStr, generateClassName(), codeBase));
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
It is working fine as normal java project but when I am trying to deploy the code as EAR application, the glassfish policy file is not allowing to setup a new java policy file and is giving error.
Please provide your inputs on it.
[Message sent by forum member 'bhat_anshul' (bhat_anshul)]
http://forums.java.net/jive/thread.jspa?messageID=331928