Add resource files to classpath using daemon(jsvc)

793 views Asked by At

I am struggeling with this for a while. I am using Spring3.1 in a standalone env. I have resources files which I need to add into the classpath (applicationXML). In eclipse it's a known and easy way. Now I am trying to deploy my application to a standalone env on linux using Daemon (commons-daemon-1.0.3.jar).

How can I add resources files there to the classpath?

1

There are 1 answers

0
Jim Doyle On BEST ANSWER

One thing you can do is use the Maven Shade plugin. This is used to create a SuperJAR of everything in your build profile — dependent JARs from Apache and Spring, as well as your own code. The Shade Plugin can that add a Classpath entry of "." into the Manifest of the SuperJAR, this is precisely how you will be able to run the Main class of the SuperJAR, but have the classloader look in both a local directory as well as a JAR for all your components.

You'll have to adjust your build a bit so that things like log4j.properties and application-context.xml, and other files you wish to have sysadmins/customers modifer after build are kept out of the resources/path — otherwise they will get baked into the build.

You might look at my source code here http://sourceforge.net/projects/jee2pctest/. The client driver code provides an excellent example of how to use the Maven Shade plugin to create a directly executable JAR with external properties files.The magic is mainly in the pom.xml file. One Caveat, I am using the Maven build tooling, if you are still on ANT using using your IDE's built-in packager, then you might have some work cut out.