aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Error Compiling Maven Project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Error Compiling Maven Project" Watch "Error Compiling Maven Project" New topic
Author

Error Compiling Maven Project

Praneet Mirchandani
Ranch Hand

Joined: Dec 16, 2009
Posts: 46
Hi,

I am trying to build my project using maven. Encountered some problems when i ran the command
mvn compile.

I made some changes to pom.xml, tried a few things. It is still showing me errors while compiling.


I have added the repositories in pom.xml, cant figure out how to work around this.

Here is the error log:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building PricingCore
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 4 resources
[WARNING] POM for 'javax.mail:mail:pom:1.4:compile' is invalid.

Its dependencies (if any) will NOT be available to the current build.
[WARNING] POM for 'javax.jms:jms:pom:1.1:compile' is invalid.

Its dependencies (if any) will NOT be available to the current build.
[WARNING] POM for 'com.sun.jdmk:jmxtools:pom:1.2.1:compile' is invalid.

Its dependencies (if any) will NOT be available to the current build.
[WARNING] POM for 'com.sun.jmx:jmxri:pom:1.2.1:compile' is invalid.

Its dependencies (if any) will NOT be available to the current build.
Downloading: http://repo2.maven.org/maven2/ojdbc/ojdbc/14/ojdbc-14.jar
[INFO] Unable to find resource 'ojdbc:ojdbc:jar:14' in repository repo2 (http://
repo2.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/ojdbc/ojdbc/14/ojdbc-14.jar
[INFO] Unable to find resource 'ojdbc:ojdbc:jar:14' in repository central (http:
//repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) ojdbc:ojdbc:jar:14

Try downloading the file manually from:
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html

Then, install it using the command:
mvn install:install-file -DgroupId=ojdbc -DartifactId=ojdbc -Dversion=14 -
Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:

mvn deploy:deploy-file -DgroupId=ojdbc -DartifactId=ojdbc -Dversion=14 -Dp
ackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) com.wellmanage.pricing:PricingCore:jar:1.0-SNAPSHOT
2) ojdbc:ojdbc:jar:14

----------
1 required artifact is missing.

for artifact:
com.wellmanage.pricing:PricingCore:jar:1.0-SNAPSHOT

from the specified remote repositories:
central (http://repo1.maven.org/maven2),
repo2 (http://repo2.maven.org/maven2)



[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Fri Feb 26 13:58:04 GMT+05:30 2010
[INFO] Final Memory: 5M/10M
[INFO] ------------------------------------------------------------------------

Here is the pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wellmanage.pricing</groupId>
<artifactId>PricingCore</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>PricingCore</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>
<dependency>
<groupId>ojdbc</groupId>
<artifactId>ojdbc</artifactId>
<version>14</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>repo2</id>
<url>http://repo2.maven.org/maven2</url>
</repository>
</repositories>

</project>


Thanks,
Praneet
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

Praneet, do you think you can think up some more descriptive message titles? When several threads show up with the same title, it makes it look like you're simply reposting the same message. Also, it's more likely that someone who knows the answer won't look at the question, since the real question probably isn't in the title.

Just to be really annoying this morning, I'm also going to suggest that you learn about the "Code" button on the JavaRanch editor. If you use it to mark up sample code and XML files in your post, they'll display more readably and won't get reformatted like general text does.

It looks like you're failing because you want Maven to include a local dependency. In other words, a module that's specific to your installation, but not to the world at large. In order to do that, you have to first place it in your repository using the "mvn install" goal. If multiple users need this dependencty, you should have a shared repository that it gets installed into that all users can reference.


Customer surveys are for companies who didn't pay proper attention to begin with.
Praneet Mirchandani
Ranch Hand

Joined: Dec 16, 2009
Posts: 46

Hi Tim,

Taken note of your suggestions for the future.

As for the project, I have tried using mvn install to install the jars, but it throws up some invalid error.

I have two maven repositories on the desktop. Theres one in the D drive, and one at D:\Documents and Settings\users\.....

I think I tried installing it in the wrong one. Is one of them the default repository?

I am not at my desktop right now, will be able to try it only tomorrow. Will keep posting updates.

Thanks,
Praneet
Joonas Reynders
Greenhorn

Joined: Mar 01, 2010
Posts: 2
Hi!

As you have probably noted by googling you are not the only one suffering with this problem. No one seems to have posted a solution though.

I would try resolving the issue by:
- Making sure you have the latest maven (2.2.1 as of writing).
- Delete your local repository and run mvn clean install again. I have it and I have the javax.mail 1.4 in my local repository and it's pom seems to be valid so maybe you have downloaded a corrupt one from somewhere
- If you have an explicit dependancy to the javax.mail 1.4 try updating the version to 1.4.1

Posting -X output might help debugging further

Cheers,
Joonas
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

I run Linux, and on that platform the local Maven repository is in the ".m2" subdirectory of my home directory. Since Windows is now moving towards a more Unix-like directory convention (those embedded spaces in directory names look nice, but they drive parsers insane!), it's possible that you're being hit by transition issues. Originally, in XP, the Maven repo would be in "C:\Documents and Settings\userid\.m2".

I think there's an option you can put in your per-user ".m2" directories to use a shared repository (per-machine, instead of per-user), but I haven't ever tried it. These days almost nobody runs with multiple developers logged into one computer in the old time-sharing style common back when hardware was a lot more expensive.
Praneet Mirchandani
Ranch Hand

Joined: Dec 16, 2009
Posts: 46

Hi,

Seems to be working now. I ran mvn clean install, it still threw me some errors.

Then downloaded jms-1.1.jar, jmxri-1.2.1.jar and jmxtools-1.2.1.jar, and installed them in the repository.

Also, I noticed that while giving the path to a jar, the entire path upto the jar file itself needs to be specified. Did not know about this.

The project Build was successful. Thanks everyone for the help.

Praneet
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

Praneet Mirchandani wrote:
Also, I noticed that while giving the path to a jar, the entire path upto the jar file itself needs to be specified. Did not know about this.
Praneet


:confused:

If the jar is a Maven dependency, you don't give a path at all. However you do need to fully specify the group, artifact and version IDs in your dependencies.

Actually, you can fudge the version ID, but it's not a recommended practice.
Praneet Mirchandani
Ranch Hand

Joined: Dec 16, 2009
Posts: 46

When I ran mvn compile, it said ojdbc.jar version 14 missing. So I downloaded the jar.

Here is the command I used to try and install it:

mvn install:install-file -DgroupId=ojdbc -DartifactId=ojdbc -Dversion=14 -Dpackaging=jar -Dfile=D:\

This did not work. (Jar not found or something, which seemed pretty strange.) So I tried this:

mvn install:install-file -DgroupId=ojdbc -DartifactId=ojdbc -Dversion=14 -Dpackaging=jar -Dfile=D:\ojdbc14.jar
which was the entire path up to the jar file itself.

Praneet
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

Actually, what you did was import a jar into Maven. Since, as far as I know, Oracle doesn't provide its drivers in any public Maven repositories, what you did was correct, and yes, Maven wants to know exactly where to find the file it's supposed to copy and catalog into the Maven repository.

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

I just had a thought - why do you have a dependency on the ojdbc artifact? Are you making calls specify to the Oracle JDBC driver, or are you making standard JDBC calls? Unless you have a good reason to use the Oracle JDBC-specific classes you really should be using standard JDBC, in which case the the JDBC API comes with the JDK and you can remove the dependency on ojdbc.


JBoss In Action
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

Peter Johnson wrote:I just had a thought - why do you have a dependency on the ojdbc artifact? Are you making calls specify to the Oracle JDBC driver, or are you making standard JDBC calls? Unless you have a good reason to use the Oracle JDBC-specific classes you really should be using standard JDBC, in which case the the JDBC API comes with the JDK and you can remove the dependency on ojdbc.


Actually, I started to say something similar, but for a different reason. ojdbc.jar has the actual Oracle JDBC drivers in it, and while it is fully conformant with (and extends) JDBC 3, the code is specific to communicating with an Oracle server, just as the respective driver jars for MySQL, DB/2, PostgreSQL, and so forth are all server-specific. Of course, being open-source, the MySQL and PostgreSQL driver jars are part of the standard global Maven repositories, which isn't true of the DB/2 and Oracle closed-source drivers.

What I was going to comment on wasn't the use of the jarfile itself, but specifying it as a Maven dependency, since in a webapp, the JDBC drivers are better off simply copied into the appserver's common library directory. Then I remembered I have several stand-alone JPA applications and unit test processes, and since they have no separate container, they do, in fact include vendor driver jars as Maven dependencies.
Praneet Mirchandani
Ranch Hand

Joined: Dec 16, 2009
Posts: 46
Hi,

Actually if I didnt include the ojdbc jar file, it threw me an error saying that this jar is missing.

So I included it. The project does use a lot of Sql queries etc.

Thanks,
Praneet
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

Praneet Mirchandani wrote:Hi,

Actually if I didnt include the ojdbc jar file, it threw me an error saying that this jar is missing.

So I included it. The project does use a lot of Sql queries etc.

Thanks,
Praneet


Unless you call Oracle-specific classes, you shouldn't have that problem. The accepted process uses the Class.forName() method to dynamically load the driver class without the need for a static (build-time) linkage.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error Compiling Maven Project