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 9019037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:40:48+00:00 2026-06-16T04:40:48+00:00

Context : I have a Maven goal that calls an executable (it happens to

  • 0

Context: I have a Maven goal that calls an executable (it happens to be a Groovy script, but it doesn’t matter) which needs as an argument the path to a runtime ibrary (it happens to be a JDBC driver, but it doesn’t matter either).

Instead of hardcoding the path to the driver, I’m constructing it as a classpath dependency, so that it’s picked from whererever the Maven repository will happen to be (we have different environments with different OSes).

<classpath>
    <dependency>postgresql:postgresql</dependency> <!-- groupId:artifactId -->
</classpath>

Problem: the classpath is not resolved as expected, instead of the path to the library, it is empty (and therefore the invocation fails).

The relevant parts of the pom.xml are below:

<dependency>
  <groupId>postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>9.1-901.jdbc4</version>
  <scope>provided</scope>
</dependency>


<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.2.1</version>
  <executions>
    <execution>
      <id>initialize-rule-plugin</id>
      <phase>compile</phase>
        <goals><goal>exec</goal></goals>
        <configuration>
          <executable>full\path\to\groovy</executable>
          <arguments>
            <argument>-cp</argument>
              <classpath>
                <dependency>postgresql:postgresql</dependency>
              </classpath>
            <argument>myscript.groovy</argument>
          </arguments>
        </configuration>
      </execution>
  </executions>
</plugin>

The debug output is:

[DEBUG] Configuring mojo 'org.codehaus.mojo:exec-maven-plugin:1.2.1:exec' with basic configurator -->
[DEBUG]   (s) dependency = postgresql:postgresql
[DEBUG]   (f) arguments = [-cp, Classpath { postgresql:postgresql}, ]
[...]
[DEBUG] Collected project artifacts [org.springframework:spring-context:jar:3.1.2.RELEASE:compile, org.springframework:spring-aop:jar:3.1.2.RELEASE:compile, org.springframework:spring-beans:jar:3.1.2.RELEASE:compile, org.springframework:spring-core:jar:3.1.2.RELEASE:compile, org.springframework:spring-expression:jar:3.1.2.RELEASE:compile, org.springframework:spring-asm:jar:3.1.2.RELEASE:compile, org.springframework:spring-webmvc:jar:3.1.2.RELEASE:compile, org.springframework:spring-context-support:jar:3.1.2.RELEASE:compile, org.springframework:spring-web:jar:3.1.2.RELEASE:compile, org.springframework:spring-tx:jar:3.1.2.RELEASE:compile, aopalliance:aopalliance:jar:1.0:compile, org.springframework:spring-orm:jar:3.1.2.RELEASE:compile, org.springframework:spring-jdbc:jar:3.1.2.RELEASE:compile, org.slf4j:slf4j-api:jar:1.7.1:compile, org.slf4j:jcl-over-slf4j:jar:1.7.1:runtime, org.slf4j:slf4j-log4j12:jar:1.7.1:runtime, log4j:log4j:jar:1.2.17:compile, javax.validation:validation-api:jar:1.0.0.GA:compile, org.hibernate:hibernate-validator:jar:4.3.0.Final:compile, org.jboss.logging:jboss-logging:jar:3.1.0.CR2:compile, org.hibernate:hibernate-entitymanager:jar:4.1.7.Final:compile, org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile, dom4j:dom4j:jar:1.6.1:compile, org.javassist:javassist:jar:3.15.0-GA:compile, org.hibernate:hibernate-core:jar:4.1.7.Final:compile, antlr:antlr:jar:2.7.7:compile, org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile, org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile, org.codehaus.jackson:jackson-mapper-asl:jar:1.9.10:compile, org.codehaus.jackson:jackson-core-asl:jar:1.9.10:compile, javax.servlet:jstl:jar:1.2:compile, commons-dbcp:commons-dbcp:jar:1.4:compile, commons-pool:commons-pool:jar:1.5.4:compile, org.codehaus.groovy:groovy-all:jar:2.0.5:compile]
[DEBUG] Collected project classpath [C:\projects\myproject\target\classes]
[DEBUG] Toolchains are ignored, 'executable' parameter is set to c:\full\path\to\groovy
[DEBUG] Executing command line: cmd /c c:\full\path\to\groovy.bat -cp C:\projects\myproject\target\classes myscript.groovy 

As it can be seen, it does not pick up the classpath to the driver (which exists).

I have tried with and without also including the dependency’s version number in the reference.

Thank you in advance.

  • 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-06-16T04:40:50+00:00Added an answer on June 16, 2026 at 4:40 am

    As per my comment, I found a different way to do the same thing. Since there was no other solution posted, I’ll post it as an answer if anyone runs into the same problem.

    The key is to use a different plugin, which creates, on-the-fly, properties populated with the path to a jar.

    <plugin>
      <groupId>org.bitstrings.maven.plugins</groupId>
      <artifactId>dependencypath-maven-plugin</artifactId>
      <version>1.1.1</version>
      <executions>
        <execution>
          <id>set-all</id>
          <goals>
            <goal>set</goal>
          </goals>
        <configuration>
          <propertySets>
            <propertySet>
              <includes>
                <include>postgresql:postgresql:jar</include>
              </includes>
            </propertySet>
          </propertySets>
        </configuration>
        </execution>
      </executions>
    </plugin>
    
    [...]
    
    <execution>
      <id>my-script</id>
      <phase>compile</phase>
      <goals>
        <goal>exec</goal>
      </goals>
      <configuration>
        <executable>path/to/groovy</executable>
        <arguments>
          <argument>-cp</argument>
          <argument>${postgresql:postgresql:jar}</argument>
          <argument>my-script.groovy</argument>
        </arguments>
      </configuration>
    </execution>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a LINQ TO SQL Context that I have created that calls a
I have imported project with Maven. But Subclipse didn't recognize that project already in
Context: I have a class that implements a Session, maintaining a TCP connection to
I have a context loader class which loads an XML file with info on
I have a multi module maven web application, which uses hibernate. I use the
I have a small command line utility project that I'm using Maven to manage.
I have a Maven project that so far used to compile without problems. Today,
I have a maven project which consist of two maven modules: web module and
I have a number of dependencies on my project that Maven resolves correctly. The
I have an app., coded with ejb3, jsf and maven, which runs on jboss

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.