Search code examples
javamavenjersey

Why am I running into org.codehaus.mojo:exec-maven-plugin:1.2.1:exec error?


I have the following simple pom.xml. When I run the application it runs into following error, I read many answers for this problem but they did not work out.

    ClientConfig config = new DefaultClientConfig();
    Client client = Client.create(config);
    WebResource resource = client.resource("Query Request Goes Here");
    List<Output> allOutputs = resource.get(new GenericType<List<Output>>(){});
    System.out.println(allOutputs.size());



Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project eBaytest: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany</groupId>
    <artifactId>Test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>eBaytest</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>1.18</version>
            <type>jar</type>
        </dependency>
    </dependencies>
</project>

Solution

  • It looks like you're trying to set up a new Jersey project using Jersey 1.x. My first recommendation would be to use the latest 2.5.1. Also, you'll definitely want to be able to run Maven from the command line, so install that first. When you have that, follow these instructions to set up a new Jersey project, basically:

    mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-grizzly2 \
    -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false \
    -DgroupId=com.example -DartifactId=simple-service -Dpackage=com.example \
    -DarchetypeVersion=2.5.1
    

    After that, make your changes and run:

    mvn -e compile exec:java
    

    If you get any errors then, you can come back here and share them with us.