|
|
Dynamically loading classes from servlets |
Many users complained about the fact that after placing a certaing set of files in a repository, these files were not accessed via Class.forName() or equivalent methods. Others also noticed that, moving the same entry from the "repository=" property in file zone.properties to the "wrapper.classpath=" in jserv.properties file, resulted in successfully restoring this capability.In other words: [jserv.properties] wrapper.classpath=/usr/java/lib/jsdk20.jar [zone.properties] repository=/usr/java/servlets,/usr/java/lib/foo.jar Class.forName("org.foo.Bar") doesn't work (where class "org.foo.Bar" is contained in "/usr/java/lib/foo.jar")
while [jserv.properties] wrapper.classpath=/usr/java/lib/jsdk20.jar:/usr/java/lib/foo.jar [zone.properties] repository=/usr/java/servlets Class.forName("org.foo.Bar") works.This happens because repositories are NOT merged with the JVM class path, and, so, unaccessible from the system ClassLoader. But why that? Because, to be able to give to JServ the ability of autoreloading servlet classes when these were changed, we had to create a different ClassLoader, and to use a different ClassLoader for each servlet zone. This also gives other benefits, expecially about security, in fact a certain zone cannot access classes and servlets specified in a different zone, and so a servlet in zone " Foo" cannot access to the servlet "MyServlet" specified in zone "Bar" when these two zones have different "repository= | |
| [Append to This Answer] |
| Previous: |
|
| Next: |
|
| ||||||||||