Search code examples
javaclassservletsclassloader

How do I reload servlet classes without restarting my web application?


I want to reload just my web layer classes without reloading my service layer classes (which take longer to initialize and change less frequently). There are no references from my service layer into the web layer and I can create a whole new instance of the web layer without problems.

I can conceive of a solution involving complicated class-loader tricks to isolate the web layer in its own class-loader and I think this is probably the only way to do this so what I'm asking is, is there a library out there which does this?

I know about JavaRebel - I don't need that much power and I'm really looking for a more lightweight free solution.


Solution

  • If your web layer is separated from the service layer would it be possible for you to deploy them as to separate applications? Then the web app could be reloaded as often as necessary.

    In case the reason for reloading of the webapp is changes in configuration, then move properties etc away from WEB-INF-folder (as they normally are not reloaded/reloadable). Ideas for handling reloadable configs etc can be found in Spring and FreeMarker