Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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).

share|improve this question
add comment

2 Answers

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.

share|improve this answer
    
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
add comment

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.

share|improve this answer
    
(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_n Mar 14 '13 at 5:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.