the second approach seems to work when using the --bootdir=dir option of run.sh instead of --patchdir.
Here is what I did for testing purposes:
1) Added extra log-Statements to org.jboss.system.server.ServerImpl
2) Compiled that file with the Jar-Files of the jbossInstallDir/lib directory on the classpath
3) Put the compiled ServerImpl.class in a jar-File, say a.jar
4) Run the server with --bootdir=myDir where myDir contained a.jar
5) Received the log statements on the console
But I'm not yet sure exactly when to use --bootdir and when to use --patchdir. Can someone please shed some light on this?
so far as I can see, one has to use bootdir if any class must be patched that is loaded via the ServerLoader according to section 184.108.40.206.3. The Complete Class Loading Model im Adminguide of the JBoss Admin-Guide (concerning JBoss AS 4.0.3SP1).
Anything else should be patched via patchdir. The reason not to use bootdir as well is that some required classes might not be available via ServerLoader.
All in all, nearly anything can be patched, except:
1) org.jboss.Main / org.jboss.system.server.ServerLoader
2) Application classes (in .ears, .wars, ...) if a loader-repository is configured or some other configuration prevents the respective deployer from using the JBoss-Classloader
Is that correct so far?
By the way, what about the possibility to provide patches that are loaded by the Classloader of a particular loader-repository (which then would have to be configured)? Deployed applications could then be patched the way the JBoss server itself gets patched.