You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Sean Mitchell <se...@mitchwood.com> on 2006/07/25 21:04:36 UTC
exec-maven-plugin and classpath
Hi All...
I'm trying to make the exec-maven-plugin run a java Main using the project's
classpath, but I'm running into trouble.
As per TFM I have specified the arguments thusly:
<arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project
dependencies,
also adding the project build directory -->
<classpath/>
</arguments>
This gives me the nasty stacktrace at the bottom, using maven 2.0.2 and 2.0.4.
If I remove the classpath goop, it will attempt to run the specified class but
fails on the first dependency.
Anyone have any idea what is wrong?
Sean
---------- excerpt from pom.xml -------------
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.caribbeancricket.walcott.tools.ArticleImporter</mainClass>
<arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project
dependencies,
also adding the project build directory -->
<classpath/>
</arguments>
<systemProperties>
<systemProperty>
<key>myproperty</key>
<value>myvalue</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin
----------NASTY STACKTRACE-----------
[INFO] Trace
java.lang.ArrayStoreException
at java.lang.System.arraycopy(Native Method)
at java.util.ArrayList.toArray(ArrayList.java:304)
at
org.codehaus.plexus.component.configurator.converters.composite.ArrayConverter.fromConfiguration(ArrayConverter.java:141)
at
org.codehaus.plexus.component.configurator.converters.ComponentValueSetter.configure(ComponentValueSetter.java:247)
at
org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:137)
at
org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent(BasicComponentConfigurator.java:56)
at
org.apache.maven.plugin.DefaultPluginManager.populatePluginFields(DefaultPluginManager.java:1033)
at
org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(DefaultPluginManager.java:579)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:393)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:531)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:485)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:455)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:303)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:270)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:139)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: exec-maven-plugin and classpath
Posted by Kaare Nilsen <ka...@gmail.com>.
Glad to help, and to make the commandline a little shorter you could
keep the following configuration in the pom (this is my preferred way
of use)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.0.1</version>
<configuration>
<mainClass>com.caribbeancricket.walcott.tools.ArticleImporter</mainClass>
</configuration>
</plugin
then in the commandline simply : mvn exec:java
On 26/07/06, Sean Mitchell <se...@mitchwood.com> wrote:
> On Wednesday 26 July 2006 7:14 am, Kaare Nilsen wrote:
>
> > This is at least the setup that works for me. I see that a little more
> > documentation is needed on the mojo site.
> > But for any further question, please use the mojo user group .
>
> Thanks for your help... in fact, my problem was that the class I was trying to
> run had a runtime dependency (mysql driver) that was not listed in my pom.xml
> and I jumped to conclusions about the classpath. Your configuration worked
> fine once I sorted this out, as did a simple
>
> mvn
> exec:java -Dexec.mainClass=com.caribbeancricket.walcott.tools.ArticleImporter
>
> Cheers,
>
> Sean
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: exec-maven-plugin and classpath
Posted by Sean Mitchell <se...@mitchwood.com>.
On Wednesday 26 July 2006 7:14 am, Kaare Nilsen wrote:
> This is at least the setup that works for me. I see that a little more
> documentation is needed on the mojo site.
> But for any further question, please use the mojo user group .
Thanks for your help... in fact, my problem was that the class I was trying to
run had a runtime dependency (mysql driver) that was not listed in my pom.xml
and I jumped to conclusions about the classpath. Your configuration worked
fine once I sorted this out, as did a simple
mvn
exec:java -Dexec.mainClass=com.caribbeancricket.walcott.tools.ArticleImporter
Cheers,
Sean
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: exec-maven-plugin and classpath
Posted by Kaare Nilsen <ka...@gmail.com>.
Hi..
What you actually do here is to mix the configuration style og the
exec and the java goal. In the configuration of the java goal there is
no <classpath> element because it will automaticly be build based on
the project dependencies. Also I would remove the <systemProperties>
section (well that is if you do not actually need a system variable
with the key myproperty, and then i would reccomend renaming it :))
Please note that there was a bug in the java goal in the 1.0 version
of the plugin so please make shure you are using the 1.0.1 version.
Well. so the plugin config should then look something like this :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<phase>[your wanted phase here. for valid ones see
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html]</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.caribbeancricket.walcott.tools.ArticleImporter</mainClass>
</configuration>
</plugin
This is at least the setup that works for me. I see that a little more
documentation is needed on the mojo site.
But for any further question, please use the mojo user group .
Best regards
Kaare Nilsen
On 25/07/06, Sean Mitchell <se...@mitchwood.com> wrote:
> Hi All...
>
> I'm trying to make the exec-maven-plugin run a java Main using the project's
> classpath, but I'm running into trouble.
>
> As per TFM I have specified the arguments thusly:
>
> <arguments>
> <argument>-classpath</argument>
> <!-- automatically creates the classpath using all project
> dependencies,
> also adding the project build directory -->
> <classpath/>
> </arguments>
>
> This gives me the nasty stacktrace at the bottom, using maven 2.0.2 and 2.0.4.
>
> If I remove the classpath goop, it will attempt to run the specified class but
> fails on the first dependency.
>
> Anyone have any idea what is wrong?
>
> Sean
>
>
>
>
> ---------- excerpt from pom.xml -------------
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>exec-maven-plugin</artifactId>
> <executions>
> <execution>
> <goals>
> <goal>java</goal>
> </goals>
> </execution>
> </executions>
> <configuration>
> <mainClass>com.caribbeancricket.walcott.tools.ArticleImporter</mainClass>
> <arguments>
> <argument>-classpath</argument>
> <!-- automatically creates the classpath using all project
> dependencies,
> also adding the project build directory -->
> <classpath/>
> </arguments>
> <systemProperties>
> <systemProperty>
> <key>myproperty</key>
> <value>myvalue</value>
> </systemProperty>
> </systemProperties>
> </configuration>
> </plugin
>
>
>
>
> ----------NASTY STACKTRACE-----------
> [INFO] Trace
> java.lang.ArrayStoreException
> at java.lang.System.arraycopy(Native Method)
> at java.util.ArrayList.toArray(ArrayList.java:304)
> at
> org.codehaus.plexus.component.configurator.converters.composite.ArrayConverter.fromConfiguration(ArrayConverter.java:141)
> at
> org.codehaus.plexus.component.configurator.converters.ComponentValueSetter.configure(ComponentValueSetter.java:247)
> at
> org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:137)
> at
> org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent(BasicComponentConfigurator.java:56)
> at
> org.apache.maven.plugin.DefaultPluginManager.populatePluginFields(DefaultPluginManager.java:1033)
> at
> org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(DefaultPluginManager.java:579)
> at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:393)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:531)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:485)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:455)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:303)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:270)
> at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:139)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
> at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
> at
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
> at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org