0

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 ?!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Mohamad Hatem
  • 53
  • 1
  • 7

2 Answers2

0

There is no advantage using jar dependencies on the server classpath. This will force you to depend on the server itself which is not a good idea when dealing with continuous delivery.

BTW you shall know that every war file has it own classpath when deployed, so if you deploy some war, let's suppose on a Tomcat Server, it will use it's own classpath which contains the necessary jars. The container (Tomcat in this case) will know nothing about these jars but your application will.

R. Karlus
  • 2,094
  • 3
  • 24
  • 48
0

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!

Andrew S
  • 2,509
  • 1
  • 12
  • 14