javaserverwardeploying

Deploying war on server mechanism


When I developed any web application I added many jars which my code depended on them. I want to know when I deployed the war on the server how server or containers using these jars, And if I but them on server's modules directly is it will be an advantage for publishing or deploying ?!


Solution

  • When your code is executed the container will look within your war to see if the dependent jar is available. If it cannot find the dependent jar within your war then the container will traverse it's tree to see if it can find the dependency somewhere within the container itself. Through configuration, it is possible to reverse so the war is checked last.

    The war should be self-contained, with the dependent jars in the war's WEB-INF/lib folder. Configure the container (likely default) to check the war first. This maintains isolation which helps keep the app stable over time. For example, the container might be updated but your app should not need to be updated.

    Deploying those dependent jars outside the war, to somewhere within the container to a shared folder, will likely make those dependent jars visible to all deployed apps and/or the container itself. This eventually leads to jar version conflicts and class loader issues. Don't do it!