We have a project where we're creating a web-app deployed to JBoss. Maven, war packaging, etc. Now the client has a requirement that we include a command-line-interface for the app, saying a user should also be able to fire up a main method somewhere inside the war (no matter whether the app is currently deployed on JBoss or not).
I'm kind of at a loss. I've searched here and many different searches on Google, and I've found the Jetty / Jenkins examples, but those examples only seem to have one class file needed to run as a jar.
Currently the war structure for the project is this:
-resources
-META-INF
---MANIFEST.MF, et al
-WEB-INF
---web.xml, classes(com/*), lib, et al
I'm having Maven set up the MANIFEST.MF file with the Main-Class for the class I want to call using java -jar. But then the structure of the war seems to need to follow a "normal" jar structure, like this:
-resources
-com/*/main.class
-META-INF
---MANIFEST.MF, et al
-WEB-INF
---web.xml, classes(com/*), lib, et al
But then the main.class depends on other classes in the app, so I find myself putting more and more of the code in both places, for the jar functionality and the war as well.
Ok, so I've used Maven + antrun to copy the class files from WEB-INF/classes to the root of the war file. Now there are jars that the classes depend on (for instance, log4j). So NOW I find myself using antrun to unjar the necessary jars, placing THOSE class files in the root of the war...
This seems...crazy. Is there a (better) way?
edited with more information The CLI functionality needs to access a database, so there are unfortunately many classes needed (all the DAO/EBO/configuration classes)