I have a maven WAR file that has a main class in it. I want to run this main class using command line similar to Hudson, which uses Jetty from behind
I have looked through Hudson's POM file and kind of understand how the file structure looks like (once WAR is exploded). I followed Hudson POM to set up my own project and when I export the WAR, this same structure looks fine.
Now the problem I'm having is that the main class need some dependencies (namely Log4J for logging and Jackson for JSON). These dependencies are in the WEB-INF/lib folder which the web app uses. How can I set up the main class to point to the WEB-INF/lib folder to get these dependencies.
The POM <build> section configures what the main class is and its dependencies (shown below).
Given what I have done or configured, when I run it, it gives NoClassDefFoundError, clearly it can't find the lib
After playing with it a bit, I have abandon the main class thing in WAR file. Actually I got to the point I got everything in order but when I run it, the DB connection is null because the console (main class) can't get the JNDI stuff from the app server. And I thought making it to work (meaning using JDBC) is too much effort IMO.
So the new approach? Have a web page or controller to call the necessary web services. Since I still need to trigger it automatically using cron job or similar, I found there is a "start" command in Windows to open the browser and load the page.
K. Tsang CEng MBCS PMP PMI-ACP OCPJEA OCPJP
Stephan van Hulst
posted 3 years ago
Can you maybe explain more about the purpose of your application? What does the web application do? What do you want the main class to do?
The whole idea was that I need a) to export/import files to/from other systems for their processing and b) generate PDF report to end users every day. The functions are all done in web services.
So I was originally planning to have a main class (in the WAR file) to do that. But I figured if I was able to call main class, it won't get the DB connection from JNDI. Then fallback to just a regular (manual) service call (controller).
In fact, a colleague of mine actually simplify the whole thing: write of the controller thing, separate the service call into another project, use parameters to determine what web service.
Then I thought, better than my approach at first. No JDBC or DB thing to set up. Just a matter of plugging in the parms correctly. I can live with that.