views:

113

answers:

1

My web application uses a native dll for part of its functionality (the location of which is provided in PATH). Everything works until I make a change to the WAR and JBoss hot deploys this WAR. At this point, the dll is no longer found and I need to manually restart the server.

What is the best way to load the dll back into the app after a hot deploy?

A: 

It might not be so easy. Normally a DLL is tied to a specific classloader. When you redeploy, that means that the original classloader used for your application is destroyed. Unfortunately the Java Virtual Machine does not allow a second classloader to reload a DLL again.

You must have something static, that will never be unloaded by the Virtual Machine. Maybe having a second application that loads the DLL would be a solution, as redeploying the first application wouldn't then affect the DLL. I guess it could also be possible to create a Jar file that loads the DLL and add it to the classpath of JBoss itself, instead of adding it to your application. Normally such servers have a "shared" directory where such jar files can be added that will be shared by all applications.

The following bug from SUN sheds some light in this issue, which is way more general than just loading servlets:

http://bugs.sun.com/bugdatabase/view%5Fbug.do?bug%5Fid=4225434

Mario Ortegón