views:

107

answers:

1

Hello all,

I'm trying to learn maven ASAP as its required for my current work place. I found this great book which pretty much explains everything about maven.

I'm using eclipse for java development and I installed maven eclipse plugin, in the book I mentioned above there is example(which may or may not be relevant) 4.2.1. Yahoo! Weather RSS.

Purpose of this example is to ilustrate how maven works in a slightly more complex way, by connecting to the yahoo weather rss server and getting the appropriate data from it.

With what I struggle is this line below,I manage to execute it from cmd(I'm using win-7)

mvn exec:java -Dexec.mainClass=org.sonatype.mavenbook.weather.Main

When I use text editor and cmd, first to edit files and second to perform commands with maven I do everything as in the book everything runs perfectly, but we work with eclipse so I'd like to learn how to do the same with eclipse.

How do I do this from eclipse?

Here is the image of what I try to run :

alt text

So I get to the next screen :

alt text

I run it and I get this error :

Version: 1.1.1
Mojo: exec
brought in via: Direct invocation

While building project:
Group-Id: org.sonatype.mavenbook.custom
Artifact-Id: weather
Version: 0.0.1-SNAPSHOT
From file: C:\OPR-CS\weather\pom.xml


Missing parameters include:
executable



[INFO] ------------------------------------------------------------------------
[INFO] For more information, run with the -e flag
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILED
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Tue Feb 02 14:47:04 CET 2010
[INFO] Final Memory: 1M/7M
[INFO] ------------------------------------------------------------------------

I assume I didn't pass the appropriate parameteres as it says in error above.

-Dexec.mainClass=org.sonatype.mavenbook.weather.Main 

This line above. Because I don't know how. Here is the pom.xml file, same as in book slightly adjusted here it is:

<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"&gt;
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.sonatype.mavenbook.custom</groupId>
    <artifactId>weather</artifactId>
    <packaging>jar</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>weather</name>
    <url>http://maven.apache.org&lt;/url&gt;

    <licenses>
        <license>
            <name>Apache 2</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt&lt;/url&gt;
            <distribution>repo</distribution>
            <comments>A business-friendly OSS license</comments>
        </license>
    </licenses>

    <organization>
        <name>ORIGIGI</name>
        <url>http://www.devs.com&lt;/url&gt;
    </organization>

    <developers>
        <developer>
            <id>emco</id>
            <name>Myself and I</name>
            <email>[email protected]</email>
            <url>http://www.devs.com&lt;/url&gt;
            <organization>ORIGIGI</organization>
            <organizationUrl>http://www.devs.com&lt;/organizationUrl&gt;
            <roles>
                <role>developer</role>
            </roles>
            <timezone>-6</timezone>
        </developer>

    </developers>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>jaxen</groupId>
            <artifactId>jaxen</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>velocity</groupId>
            <artifactId>velocity</artifactId>
            <version>1.5</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Can anyone help me? Thank you

+2  A: 

You're invoking exec:exec instead of exec:java.

The goals section should be exec:java, and in the JRE tab and the -DmainClass=... argument.

Robert Munteanu
@Robert MunteanuI get this error now `Invalid mojo or lifecycle phase: org.codehaus.mojo:exec-maven-plugin:1.1.1:exec:java Original error message was: Invalid task 'org.codehaus.mojo:exec-maven-plugin:1.1.1:exec:java': you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal`
Gandalf StormCrow
Now build fails again but this time I get this error `Reason: An exception occured while executing the Java class. null`
Gandalf StormCrow
@Robert Munteanu, does this mean I have an error somewhere in my/books code?
Gandalf StormCrow
yes it was mistake .. book author made mistake .. confused int with string .. thank you ..
Gandalf StormCrow