Menu

Using one-jar to make WAR file executable

Mark Sinke
2011-02-09
2013-05-23
  • Mark Sinke

    Mark Sinke - 2011-02-09

    Hi,

    The company I work with uses one-jar to package tools in a single jar format (after an attempt to do one-jar like things ourselves we found this excellent utility). As a spin-off it would be nice to make WAR files "self-executable" with one-jar, for example to display version information or to start a basic installer.

    Now one-jar has all the necessary functionality to make this happen, but in the WAR case the libraries live in WEB-INF/lib, not just lib at the top level. From what I gather from the 0.98 source code it is not possible to make one-jar search that WEB-INF/lib path in addition to the lib folder.

    However, it looks like it should be doable - although I lost track in some of the classloading magic that happens.

    Has anyone attempted this before, or can you comment on a solution direction?

    I'd be happy to spend a few hours coding and testing an extension, but I'd need to have some direction to start properly.

    Thanks,

    Mark Sinke

     
  • P. Simon Tuffs

    P. Simon Tuffs - 2011-02-10

    I think this has been discussed here before. 

    CORE-DUMP:

    It should be possible to have a single WAR file run as a  one-jar, look for the code that matches "lib" for jars to pre-load into memory.  Extend it to also match "WEB-INF/lib" and you should be done.  OneJarClassLoader is the culprit responsible for the trickery.  It also treats "main" and "binlib" specially, so treating WEB-INF/lib special should not be a problem.  An embedded servlet engine such as Jetty should then respect the loaded classes (it won't be able to find the WEB-INF/lib.  You will also need to handle WEB-INF/classes.

    I don' have any free time right now, but will try to answer questions if you have them.

     

Log in to post a comment.