• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

AccessControlException with a custom ClassLoader

 
Author
Posts: 131
7
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created a very basic database brower application. To provide the most fexibility, I allow users to enter the connection string and choose the *.jar file that contains the JDBC drivers for their database. Each JDBC driver is loaded using a custom ClassLoader that I created. The allows the user to connect to an Oracle, PostgreSql, MySQL, databases all at the same time and, by specifying the *.jar files themselves, I do not have to distribute dozens of jars with my application.
When I start the application via WebStart, the the signed jar files successfully all <AllPermission>. However, when my custom ClassLoader tries to read the jar file that a user specifies, I get an AccessControlException. Specifically, the exception is being thrown when my code hits the File.isDirectory() method (The custom ClassLoader I created can be given a directory and it will pickup every *.jar file in that directory).
Does anyone have any idea why my custom ClassLoader would not be able to access the jar file a user specifies? Do I have to register my custom ClassLoader with the SecurityManager in some way?
Thanks,
Michael.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've come accross something similar when loading dynamically loading jboss classes from webstart
Apparently the allProperties tag only applies to the webstart classloader, not custom classloaders (these use the java.policy file)
The following code fixed it
Policy.setPolicy( new Policy() {
public PermissionCollection
getPermissions(CodeSource codesource) {
Permissions perms = new Permissions();
perms.add(new AllPermission());
return(perms);
}
public void refresh(){
}
});
 
Michael Remijan
Author
Posts: 131
7
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
!!!EXCELLENT!!!
That worked!
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having a similar problem.
I need to get a connection from the connection pool
from a Weblogic Server. I need weblogic.jar in my classpath.
The application runs fine from console.
When I deploy it as a WebStart Application i get the following error. Please help.



Originally posted by Stijn Luyten:
I've come accross something similar when loading dynamically loading jboss classes from webstart

Apparently the allProperties tag only applies to the webstart classloader, not custom classloaders (these use the java.policy file)

The following code fixed it

Policy.setPolicy( new Policy() {
public PermissionCollection
getPermissions(CodeSource codesource) {
Permissions perms = new Permissions();
perms.add(new AllPermission());
return(perms);
}
public void refresh(){
}
});




[ May 31, 2006: Message edited by: Sudeep Agrawal ]
 
Sudeep Agrawal
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Silly me , Stijn Luyten had given the solution. Use the piece of code Stijn Luyten suggested , put it in a static block in the Main class that has the main method.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic