This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Trying to build with maven => package my.external.package does not exist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Trying to build with maven => package my.external.package does not exist" Watch "Trying to build with maven => package my.external.package does not exist" New topic
Author

Trying to build with maven => package my.external.package does not exist

jean-gobert de coster
Ranch Hand

Joined: Dec 04, 2008
Posts: 49
Hi, I created a maven project and did some coding (yay) which required me to use some libraries that are in any maven repository (:sad

so I imported the .jar files of those libraries and did happily code without Eclipse complaining about anything (except for staying up too late).

then now I'm proudly trying to build my very first .war with maven, I run -> maven build... clean package and then I get a whole bunch of errors saying that

[ERROR]
Mojo:
org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile
FAILED for project:
myproject:search:war:0.0.1-SNAPSHOT
Reason:
/Users/me/Documents/myproject/src/main/java/com/mydomain/myclass/myController.java:[17,36] package org.someother.project.package does not exist

what is wrong? How can this be? I'm in despair, save my friday the 13th
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Somewhere in your pom you are referencing org.someother.project.package, where is that?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

What are the contents of the myController.java file? Do you have this line:



JBoss In Action
jean-gobert de coster
Ranch Hand

Joined: Dec 04, 2008
Posts: 49
Peter Johnson wrote:What are the contents of the myController.java file? Do you have this line:




more like



Somewhere in your pom you are referencing org.someother.project.package, where is that?


I'm not sure I can reference org.someother.project.package in my pom.xml, since that package is not a maven project, it's not in any repository.

my pom.xml looks like this:



What I did do, in the build path of the project, was to link the .jar in which org.someother.project.package is. So I have a symbolic link "lib" source folder in my project.

As I said, Eclipse doesn't seem to mind, however I noticed that I don't have any .class files generated (even though auto build is on).
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Does your pom.xml for the war project have the built jar as a dependency?
jean-gobert de coster
Ranch Hand

Joined: Dec 04, 2008
Posts: 49
Martijn Verburg wrote:Does your pom.xml for the war project have the built jar as a dependency?


the pom.xml in my previous post is that of my war project
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Sorry, didn't have my coffee yet In that case you need to add in that 3rd party jar as a dependency in your pom.xml file.
jean-gobert de coster
Ranch Hand

Joined: Dec 04, 2008
Posts: 49
Martijn Verburg wrote:Sorry, didn't have my coffee yet In that case you need to add in that 3rd party jar as a dependency in your pom.xml file.


Is it possible to add that as a directory or do I have to add all the .jar manually one by one?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

You need to add the jar manually, see for assistance, you'll need to install that jar into your local repository however.
jean-gobert de coster
Ranch Hand

Joined: Dec 04, 2008
Posts: 49
OK will do

I didn't think of adding them to my local, that's brilliant (and simple) thanks
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

You'll want to probably be able to do this as a long term solution (your local repo is temporary after all). Nexus and Artifactory are two highly recommended dependency managers to try.
jean-gobert de coster
Ranch Hand

Joined: Dec 04, 2008
Posts: 49
Martijn Verburg wrote:You'll want to probably be able to do this as a long term solution (your local repo is temporary after all). Nexus and Artifactory are two highly recommended dependency managers to try.


Thanks for the input, I've hear of Nexus before and will definitely take it into consideration. My intent is to convince my boss and co-workers that maven is good for us, but I need to tame the beast if I want to present it
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Sounds good! In that case I'd recommend reading the Free PDF - "Maven - Definitive Guide", it'll quickly get you up to speed (just google for it).
 
 
subject: Trying to build with maven => package my.external.package does not exist
 
Similar Threads
Maven-built WAR file not containing .hbm.xml files
Error Compiling Maven Project
Should I master a build tool?
Maven 1.0.2 & eclipse: "build-all does not exist"
Help with a Build Error