1

I have a maven based application, and it references certain libraries that are marked as provided by my application server, such as:

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>servlet-api</artifactId>
  <version>2.5</verision>
  <scope>provided</scope>
</dependency>

Now obviously my application server needs to provide version 2.5 of the servlet api. Are there any strategies for ensuring the correct version of the library is being provided the app server (hopefully deployment tests would discover this as well, but I'm hoping to prevent the mismatch in the first place).

Jeff Storey
  • 448
  • 1
  • 7
  • 19

2 Answers2

0

If you are deploying on Linux, you could package your installation as PRM or DEB packages and give them dependencies. Then rpm/dpkg will refuse to install your application if the server is too old. There are good maven modules for creating such packages.

Bittrance
  • 3,070
  • 3
  • 24
  • 27
  • My issue here though is more how to ensure that the maven pom specifies the same dependencies that the server will actually be using (and to test it in an automated way). – Jeff Storey Apr 30 '12 at 12:47
0

The answer is in the question: the pom explicitly says that version 2.5 of the servlet api is "provided", which means pre-installed by someone/something. Maven has been removed from providing/ensuring these dependencies are met (more specifically, the check has been deferred to either runtime or the installer). In this case, the dependencies would be managed & provided by rpm/dpkg (...or macports "port", cygwin's "install.exe"...) or just a conscientious manual download/install. For example, assuming dpkg/rpm/port/etc, your app would be declared to depend on "tomcat-6.x" or "glassfish-3.x" (etc).

You actually could have maven download and package a servlet implementation with your app as a proper maven dependency, but (typically) that's not wanted, unless it is to create a small stand-alone server (e.g., bundled w/ winstone, like jenkins). In some cases, you may actually choose to provide both options: so, the end-user's package manager (yumex, synaptic) would show both your-app-standalone (bundled w/ a server) and your-app-war (just the web app) which would require some app server to also be installed.

michael
  • 384
  • 1
  • 5
  • (originally posted as a comment to the other answer (which I agree with), but my response became too long to fit as a comment.) – michael Mar 14 '13 at 05:11