I have a maven project that uses the maven-native-plugin for supporting JNI.
It works fine on the command line, but fails with an internal error when
running under m2eclipse. This is on Windows by the way, but that probably
doesn't matter.

I've distilled the example project from maven-native-plugin to a simple
example that shows the problem. Simply create a Java project in Eclipse and
add this pom.xml which just tries to run javah:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.codehaus.mojo.natives.it.jni.win32</groupId>
  <artifactId>hello</artifactId>
  <version>0.0</version>
  <name>JNI - DLL </name>
  <packaging>dll</packaging>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>native-maven-plugin</artifactId>
        <version>1.0-alpha-2</version>
        <extensions>true</extensions>
        <configuration>
          <javahOS>win32</javahOS>
        </configuration>

        <executions>
          <execution>
            <id>javah</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>javah</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

If you run mvn native:javah from the comand line it runs (ending with a
build error because we did not actually provide any java classes to run
javah on).

When running it from Eclipse it fails trying to configure the javah mojo
which uses plexus. It is failing trying to lookup a component as can be seen
from the exception:

Caused by:
org.codehaus.plexus.component.repository.exception.ComponentLookupException:
Component descriptor cannot be found in the component repository:
org.codehaus.mojo.natives.manager.JavahManager [default] (lookup realm:
ClassRealm[org.codehaus.mojo:native-maven-plugin, parent: ClassRealm[
plexus.core, parent: null]]).

But it should be found. It is defined in
org.codehaus.mojo.natives:maven-native-manager:jar which is part of
org.codehaus.mojo:native-maven-plugin classpath as shown by this text just
above the exception.

[DEBUG] In verifyVersionedPlugin for: org.codehaus.mojo:native-maven-plugin
[DEBUG]
org.codehaus.mojo:native-maven-plugin:maven-plugin:1.0-alpha-2:runtime(selected
for runtime)
[DEBUG]   org.apache.maven:maven-plugin-api:jar:2.0.4:runtime (selected for
runtime)
[DEBUG]   org.apache.maven:maven-project:jar:2.0.4:runtime (selected for
runtime)
[DEBUG]     org.apache.maven:maven-settings:jar:2.0.4:runtime (selected for
runtime)
[DEBUG]       org.apache.maven:maven-model:jar:2.0.4:runtime (selected for
runtime)
[DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.1:runtime (selected
for runtime)
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.1:runtime (selected for
runtime)
[DEBUG]
org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9:runtime(selected
for runtime)
[DEBUG]         junit:junit:jar:3.8.1:runtime (selected for runtime)
[DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed
- nearer found: 1.1)
[DEBUG]         classworlds:classworlds:jar:1.1-alpha-2:runtime (selected
for runtime)
[DEBUG]     org.apache.maven:maven-profile:jar:2.0.4:runtime (selected for
runtime)
[DEBUG]     org.apache.maven:maven-model:jar:2.0.4:runtime (selected for
runtime)
[DEBUG]     org.apache.maven:maven-artifact-manager:jar:2.0.4:runtime(selected
for runtime)
[DEBUG]       
org.apache.maven:maven-repository-metadata:jar:2.0.4:runtime(selected
for runtime)
[DEBUG]       org.apache.maven:maven-artifact:jar:2.0.4:runtime (selected
for runtime)
[DEBUG]
org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-6:runtime (selected
for runtime)
[DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed
- nearer found: 1.1)
[DEBUG]     org.codehaus.plexus:plexus-utils:jar:1.1:runtime (selected for
runtime)
[DEBUG]     org.apache.maven:maven-artifact:jar:2.0.4:runtime (selected for
runtime)
[DEBUG]
org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9:runtime(selected
for runtime)
[DEBUG]       junit:junit:jar:3.8.1:runtime (selected for runtime)
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4:runtime (removed -
nearer found: 1.1)
[DEBUG]       classworlds:classworlds:jar:1.1-alpha-2:runtime (selected for
runtime)
[DEBUG]   
org.codehaus.mojo.natives:maven-native-api:jar:1.0-alpha-2:runtime(selected
for runtime)
[DEBUG]     org.apache.maven:maven-plugin-api:jar:2.0:runtime (removed -
nearer found: 2.0.4)
[DEBUG]     bcel:bcel:jar:5.1:runtime (selected for runtime)
[DEBUG]
org.codehaus.mojo.natives:maven-native-javah:jar:1.0-alpha-2:runtime(selected
for runtime)
[DEBUG]     org.apache.maven:maven-plugin-api:jar:2.0:runtime (removed -
nearer found: 2.0.4)
[DEBUG]
org.codehaus.mojo.natives:maven-native-generic-c:jar:1.0-alpha-2:runtime(selected
for runtime)
[DEBUG]     org.apache.maven:maven-plugin-api:jar:2.0:runtime (removed -
nearer found: 2.0.4)
[DEBUG]
org.codehaus.mojo.natives:maven-native-msvc:jar:1.0-alpha-2:runtime(selected
for runtime)
[DEBUG]     org.apache.maven:maven-plugin-api:jar:2.0:runtime (removed -
nearer found: 2.0.4)
[DEBUG]   
org.codehaus.mojo.natives:maven-native-bcc:jar:1.0-alpha-2:runtime(selected
for runtime)
[DEBUG]     org.apache.maven:maven-plugin-api:jar:2.0:runtime (removed -
nearer found: 2.0.4)
[DEBUG]
org.codehaus.mojo.natives:maven-native-manager:jar:1.0-alpha-2:runtime(selected
for runtime)
[DEBUG]     org.apache.maven:maven-plugin-api:jar:2.0:runtime (removed -
nearer found: 2.0.4)
[DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.1:runtime (selected for
runtime)
[DEBUG] Using the following artifacts for classpath of:
org.codehaus.mojo:native-maven-plugin:maven-plugin:1.0-alpha-2:

[org.codehaus.mojo.natives:maven-native-api:jar:1.0-alpha-2:runtime
 org.codehaus.mojo.natives:maven-native-manager:jar:1.0-alpha-2:runtime
 org.codehaus.mojo.natives:maven-native-javah:jar:1.0-alpha-2:runtime
 org.codehaus.mojo.natives:maven-native-bcc:jar:1.0-alpha-2:runtime
 bcel:bcel:jar:5.1:runtime
 org.codehaus.plexus:plexus-utils:jar:1.1:runtime
 org.codehaus.mojo.natives:maven-native-msvc:jar:1.0-alpha-2:runtime
 org.codehaus.mojo.natives:maven-native-generic-c:jar:1.0-alpha-2:runtime ]

I didn't paste the whole debug output since you can run it yourself easily
enough.

Help! I don't know how to debug this sort of thing and know very little
about maven plugins.

-- 
Dale King

Reply via email to