Thanks Robert. In the end I found another way to do what I needed which did
not involve Maven exec, but will keep that in mind as I should in the first
place. :-)

After all, when to use debug flags if not when debugging... :D

pozdrawiam,
Tomasz Borek


2012/9/10 Robert Scholte <rfscho...@codehaus.org>

>  Try to run Maven with the logginglevel on debug, so: mvn -X  test
> This will show you the commandline being executed, which should give you a
> hint what's going wrong.
>
> Robert
>
> ------------------------------
> From: tomasz.bo...@gmail.com
> Date: Mon, 10 Sep 2012 14:31:25 +0200
> To: user@mojo.codehaus.org
> Subject: [mojo-user] Re: Classloader problem with main class
>
>
> Hi again,
>
> I found few promising links, with issues. There seems to be some
> classloader / config related problem resulting in that exception.
>
> http://jira.codehaus.org/browse/MNG-3888
> http://jira.codehaus.org/browse/MEXEC-32
>
> http://mail-archives.apache.org/mod_mbox/maven-users/200607.mbox/<
> 58ca838c0607260414w5c61ddcjea269f5c19944...@mail.gmail.com>
> Tried the config from the last one and got ClassNotFound again.
>
> So, it would seem that the classpath isn't set. Will try setting it
> manually.
>
> regards,
> Tomasz Borek
>
>
> 2012/9/10 Tomasz Borek <tomasz.bo...@gmail.com>
>
> Hi,
>
> Plug-in has a problem with finding a class and wanted to use mailing list
> members expertise on it. It may well be I'm using it wrong, if so, please
> point where. Also, if you know a better way of doing what I need to achieve
> - also please share.
> I tried searching archive but this ain't possible due to 404 page when
> accessing the link that should point there*.
>
> *What I'm trying to achieve:*
> I have a class that makes a naming check (adheres standards or not) and I
> wish to run it during build and fail the build with explanation if findings
> are not to my liking. I have the check, it works, reports findings as it
> should. Now, I wish to plug that in Maven build, so even folks who run mvn
> clean install -DskipTests would get the message if needed.
>
> Enter exec plugin.
>
> I wish to run my main class with it, and set a system property which then
> will be checked for by "enforce".
>
> *How I'm going
> *
>
> 1) In my <build> I've added this:
>
>                       <plugin>
>                                 <groupId>org.codehaus.mojo</groupId>
>                                 <artifactId>exec-maven-plugin</artifactId>
>                                 <version>1.2.1</version>
>                                 <executions>
>                                  <execution>
>                                         <id>REST-naming-standard</id>
> <phase>test</phase> <goals> <goal>exec</goal> </goals>
>                                 </execution>
>                                </executions>
>                                         <configuration>
>
> <executable>java</executable>
>                                                 <arguments>
>
> <argument>-classpath</argument>
>                                                  <classpath/>
>
> <argument>com.company.naming.RestPathNameITest.Main</argument>
>                                                 </arguments>
>                                         </configuration>
>                         </plugin>
>
> 2) You might want to say, I should try <goal>java</goal> with the required
> parameter: <mainClass>. Well, I did. Very similar section with <mainClass>
> and without argument with main class was my other try.* *
>
>                   <plugin>
>                                 <groupId>org.codehaus.mojo</groupId>
>                                 <artifactId>exec-maven-plugin</artifactId>
>                                 <version>1.2.1</version>
>                                 <executions>
>                                  <execution>
>                                         <id>REST-naming-standard</id>
>                                         <phase>test</phase>
>                                         <goals>
>                                          <goal>java</goal>
>                                         </goals>
>                                  </execution>
>                                 </executions>
>                                 <configuration>
>                                         <executable>java</executable>
>
> <mainClass>com.company.naming.RestPathNameITest.Main</mainClass>
>                                         <arguments>
>                                          <argument>-classpath</argument>
>                                          <classpath/>
>                                         </arguments>
>                                 </configuration>
>                         </plugin>
>
> *
> Errors I'm getting:
> *Both are classloader related and (most likely) are thrown by
> FindClassInClasspath.isClassInClasspath, either on normal path or exception
> path.
>
> 1) If I go as in 1, above, Maven can't find the class, though
> documentation suggests making argument -classpath with empty <classpath/>
> will result in full project classpath, and the class I'm trying to run is a
> test class.
>
> Documentation:
> http://mojo.codehaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html
>
> [INFO] [exec:exec {execution: REST-naming-standard}]
> Exception in thread "main" java.lang.NoClassDefFoundError:
> com/company/naming/RestPathNameITest/Main
> Caused by: java.lang.ClassNotFoundException:
> com.company.naming.RestPathNameITest.Main
>     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
>     at java.security.AccessController.doPrivileged(Native Method)
>     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> Could not find the main class: com.company.naming.RestPathNameITest.Main.
> Program will exit.
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Command execution failed.
>
>
> 2) The other error is more intriguing, it (I think) occurs when the
> isClassInClasspath function does the forName and catches exception. Arrays
> suggest that something attempted to load the class from one classloader
> into another.
>
> [INFO] Preparing exec:java
> [WARNING] Removing: java from forked lifecycle, to prevent recursive
> invocation.
> [INFO] No goals needed for project - skipping
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] FATAL ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] null
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Trace
> java.lang.ArrayStoreException
>     at java.util.ArrayList.toArray(ArrayList.java:305)
>     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:1357)
>     at
> org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(DefaultPluginManager.java:724)
>     at
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:468)
>     at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
>     at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
>     at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
>     at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
>     at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
>     at
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
>     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
>     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
>     at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
>     at
> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
>     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:597)
>     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)
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 49 seconds
> [INFO] Finished at: Mon Sep 10 13:19:35 CEST 2012
> [INFO] Final Memory: 124M/404M
> [INFO]
> ------------------------------------------------------------------------
>
>
> Any ideas?
>
> regards,
> Tomasz Borek
> * Page I found the link:
> http://mojo.codehaus.org/exec-maven-plugin/mail-lists.html
> Link itself: http://archive.codehaus.org/lists/org.codehaus.mojo.user
>
>
>

Reply via email to