Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4266706
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:47:51+00:00 2026-05-21T06:47:51+00:00

Hallo, I try to run a main method during my maven build process. Hence,

  • 0

Hallo,

I try to run a main method during my maven build process. Hence, I added the exec-maven-plugin and the following snippet to my pom.xml

<plugin>
     <!-- http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/ -->
     <groupId>org.codehaus.mojo</groupId>
     <artifactId>exec-maven-plugin</artifactId>
     <version>1.1.1</version>
     <executions>
      <execution>
       <id>compile-reports</id>
       <phase>compile</phase>
       <goals>
        <goal>java</goal>
       </goals>
       <configuration>
        <mainClass>at.xyz.dls.util.JasperReportCompiler</mainClass>
       </configuration>
      </execution>
     </executions>
    </plugin>

The main class exists and is also executed, when I call it out of the command line:

mvn exec:java -Dexec.mainClass="at.xyz.dls.util.JasperReportCompiler"

I also tried to create a empty new project to test, if an other depencency in the pom causes the problem, but had no success. In the maven settings.xml in the ~/.m2 folder, there is only the entry for an mirror, but no profiles, or anything else, which could cause a problem.

It just does not start it. When I deleted all my artifacts in my repo under org.codehouse, it did not download the exec-maven-plugin. Only when I did the command line call.

Any hints? Thanks in advance!

edit: I forgot to mention I have used “mvn clean install”. so it should have passed the compile phase…

edit:

up to now, I could not solve the problem. Thanks for your answers so far! I will try to give all information once again, and hope, one of you guys, find’s the fishy part. I have no idea anymore….

What I did:

  • Delete the folder org/codehouse/mojo in my maven proxy. just to show, when the dependencies are loaded.
  • show some java and maven version information
  • build the project with: mvn -clean install (which should pass the test phase to execute my main method)
  • execute the main method to show, the exec-maven-plugin is loaded only afterwards and works

As far as I understood, calling “mvn clean install” should pass the test phase (the tests are executed…), hence the exec-maven-plugin should be called, which should execute the main method. Am I right?

D:\Eclipse-3.6.1-JSF\ws\exec-test>java -version java version "1.6.0_21" Java(TM) SE Runtime Environment (build 1.6.0_21-b07) Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)

D:\Eclipse-3.6.1-JSF\ws\exec-test>mvn -version Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200) Java version: 1.6.0_21 Java home: C:\Programme\Java\jdk1.6.0_21\jre Default locale: de_AT, platform encoding: Cp1252 OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows" D:\Eclipse-3.6.1-JSF\ws\exec-test>mvn clean install 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building Unnamed - at.test:exec-test:jar:0.0.1-SNAPSHOT 
[INFO] task-segment: [clean, install] 
[INFO] ------------------------------------------------------------------------ 
[INFO] [clean:clean {execution: default-clean}] 
[INFO] Deleting directory D:\Eclipse-3.6.1-JSF\ws\exec-test\target 
[INFO] [resources:resources {execution: default-resources}] 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] Copying 0 resource 
[INFO] [compiler:compile {execution: default-compile}] 
[INFO] Compiling 1 source file to D:\Eclipse-3.6.1-JSF\ws\exec-test\target\classes 
[INFO] [resources:testResources {execution: default-testResources}] 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] Copying 0 resource 
[INFO] [compiler:testCompile {execution: default-testCompile}] 
[INFO] Compiling 1 source file to D:\Eclipse-3.6.1-JSF\ws\exec-test\target\test-classes 
[INFO] [surefire:test {execution: default-test}] 
[INFO] Surefire report directory: D:\Eclipse-3.6.1-JSF\ws\exec-test\target\surefire-reports

T E S T S

Running at.test.ExecTestTest JUnit Test call: end of junit test.


Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0


[INFO] [jar:jar {execution: default-jar}] 
[INFO] Building jar: D:\Eclipse-3.6.1-JSF\ws\exec-test\target\exec-test.jar 
[INFO] [install:install {execution: default-install}] 
[INFO] Installing D:\Eclipse-3.6.1-JSF\ws\exec-test\target\exec-test.jar to D:\maven.m2\repository\at\test\exec-test\0.0.1-SNAPSHOT\exec-test-0.0.1-SNAPSHOT.jar 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESSFUL 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 3 seconds 
[INFO] Finished at: Thu Mar 10 12:07:08 CET 2011 
[INFO] Final Memory: 15M/37M 
[INFO] ------------------------------------------------------------------------ D:\Eclipse-3.6.1-JSF\ws\exec-test>mvn exec:java -Dexec.mainClass="at.test.ExecTest" 
[INFO] Scanning for projects... 
[INFO] Searching repository for plugin with prefix: 'exec'. Downloading: http://pced06.vab.sozvers.at:8080/artifactory/repo/org/codehaus/mojo/exec-maven-plugin/1.2/exec-maven-plugin-1.2.pom 6K downloaded (exec-maven-plugin-1.2.pom) Downloading: http://pced06.vab.sozvers.at:8080/artifactory/repo/org/codehaus/mojo/exec-maven-plugin/1.2/exec-maven-plugin-1.2.jar 35K downloaded (exec-maven-plugin-1.2.jar) 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building Unnamed - at.test:exec-test:jar:0.0.1-SNAPSHOT 
[INFO] task-segment: [exec:java] 
[INFO] ------------------------------------------------------------------------ 
[INFO] Preparing exec:java [WARNING] Removing: java from forked lifecycle, to prevent recursive invocation. 
[INFO] No goals needed for project - skipping 
[INFO] [exec:java {execution: default-cli}]


[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESSFUL 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 7 seconds 
[INFO] Finished at: Thu Mar 10 12:07:20 CET 2011 
[INFO] Final Memory: 5M/15M 
[INFO] ------------------------------------------------------------------------        

D:\Eclipse-3.6.1-JSF\ws\exec-test>

now again the modified 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>at.test</groupId>
  <artifactId>exec-test</artifactId>
  <version>0.0.1-SNAPSHOT</version>

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

  <build>
    <finalName>exec-test</finalName>
    <defaultGoal>install</defaultGoal>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
            <source>1.6</source>
            <target>1.6</target>
            <encoding>UTF-8</encoding>
          </configuration>
        </plugin>
        <plugin>
<!-- http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/ -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
  <execution>
    <id>compile-reports</id>
    <phase>test</phase>
    <goals>
      <goal>java</goal>
    </goals>
    <configuration>
      <mainClass>at.test.ExecTest</mainClass>
    </configuration>
  </execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.8.2</version>
  </dependency>
</dependencies>

The main class:

package at.test;

public class ExecTest {
  /**
   * @param args
   */
  public static void main(String[] args) {
    System.out.println("##################################");
  }
}

And the JUnit Test Class:

package at.test;
import org.junit.Test;
import at.test.ExecTest;

public class ExecTestTest {

  @Test
    public void testTestTest() {
      System.err.println("JUnit Test call:");
      ExecTest.main(null);
      System.err.println("end of junit test.");
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:47:52+00:00Added an answer on May 21, 2026 at 6:47 am

    Finally I found the problem. Was quite a stupid mistake:

    In the pom.xml I used the <pluginManagement> around the <plugins> node.

    Maven did not complain, but ignored all plugin configurations.
    Maybe someone can use this information…

    Thanks for your help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hallo, i am using WSS 3.0 and i need to display certain entries of
Hallo i am currently playing around with castle projects ActiveRecord and the remoting facility.
Hallo, i need to write some javascript that gets the contents of a userfield
I.e.: echo H#97llo | MagicPerlCommand Stdout: Hallo were MagicPerlCommand is something like perl -pnle
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello again ladies and gents! OK, following on from my other question on ASP.NET
I'm trying to run an application from eclipse on a rooted acer iconia tab,
Hello I was writing a Regular Expression (first time in my life I might
Hello can anybody solve this please I'm creating the object in the action class
Hello I am compiling a program with make but I get the error of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.