0

I have a servlet/jsp web project which runs fine on eclipse and is exported as war fine (once I clean it that is). I mavenized the project deleting all of the dependencies from the WEB-INF\lib folder except a homebrew jar (the output of another project in the workspace). When I run the package maven goal I get messages for missing classes from this jar:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
#..... NOTICE THIS COMES FROM A CUSTOM JAR
[ERROR] /C:/path/DataServlet.java:[3,30] package xxx.java.helpers does not exist

Now this has been asked before and the most rigorous solution appears to be to create a local repo: Can I add jars to maven 2 build classpath without installing them? (NB: I am at maven 3).

I would like to avoid this - so is there any way maven will just stuff this jar to WEB-INF\lib in the war ?

Solutions that use some maven plugin to cp the contents of the WEB-INF\lib in the war are welcome - although I just have this feeling that there should be a solution that takes into account the "special" nature of this folder.

Observations:

  • Alt+F5 removes this line:

    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
    

    which corresponds to the "Web App libraries" in the Java Build Path. So not only maven refuses to take into account the WEB-INF\lib - it also breaks the build path of eclipse completely.

Related:

Community
  • 1
  • 1
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361

1 Answers1

1

Did you add this jar from WEB-INF\lib as a dependency like this:

<dependency>
  <groupId>someGroupId</groupId>
  <artifactId>someArtifactId</artifactId>
  <version>1.0.0</version>
  <scope>system</scope>
  <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/homebrew jar</systemPath>
</dependency>
bary
  • 1,699
  • 2
  • 15
  • 24
  • I want to avoid the local repo solution - more so the `system` scope that is deprecated - read the links in my answer: "...the most rigorous solution appears to be to create a local repo: http://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them/7623805#7623805" – Mr_and_Mrs_D Jun 18 '14 at 13:51
  • 2
    They say in that spec that "system" "is considered an advanced kind of feature and should only be used when you truly understand all the ramifications of its use...". If you dont want to have this jar in your WEB-INF/lib folder then probably you need to (as you said) create some own maven repo. Look at Sonatype Nexus (this is some kind of proxy to other repositories which allows you to add own artifacts). – bary Jun 18 '14 at 14:09