获取原型目录失败(无法加载Ahcwagon)-m2e-0.12.1

时间:2011-09-27 09:06:48

标签: m2eclipse archetypes

我正在尝试使用m2eclipse api按原型导入项目。 我的代码在这里:

    RemoteCatalogFactory remoteCatalogFactory = new RemoteCatalogFactory("http:/server1/archetype-catalog.xml", null, true);
    ArchetypeCatalog catalog = remoteCatalogFactory.getArchetypeCatalog();
    List<Archetype> archetypes = catalog.getArchetypes();
    for (Archetype archetype : archetypes){
        System.out.println(archetype.getArtifactId());
    }

m2eclipse版本是:0.12.1。 得到以下例外:

1) Error injecting: org.sonatype.maven.wagon.AhcWagon
  at ClassRealm[plexus.core, parent: null]
  while locating org.apache.maven.wagon.Wagon annotated with @com.google.inject.name.Named(value=http)

1 error
    at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:958)
    at com.google.inject.Scopes$1$1.get(Scopes.java:59)
    at org.sonatype.guice.bean.locators.LazyQualifiedBean.getValue(LazyQualifiedBean.java:66)
    at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:54)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:247)
    ... 38 more
Caused by: java.lang.TypeNotPresentException: Type org.sonatype.maven.wagon.AhcWagon not present
    at org.sonatype.guice.bean.reflect.URLClassSpace.loadClass(URLClassSpace.java:94)
    at org.sonatype.guice.bean.reflect.NamedClass.load(NamedClass.java:46)
    at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
    at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:949)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:995)
    at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:945)
    ... 42 more
Caused by: java.lang.ClassNotFoundException: org.sonatype.maven.wagon.AhcWagon
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
    at org.sonatype.guice.bean.reflect.URLClassSpace.loadClass(URLClassSpace.java:90)

在调试期间,我发现bundleloader正在使用org.maven.ide.eclipse的bundle classloader来加载AhcWagon类。 因为maven embedder bundle没有导出AhcWagon的包,所以无法加载它。

但我的问题是:调用者(plexus-classworlds.jar)在maven嵌入器包中,而AhcWagon(在wagon-ahc.jar中)是在同一个包中。为什么不使用maven embedder的bundle loader来加载AhcWagon?

使用此API有什么问题吗?

太棒了!如果有任何示例代码。

此致 西蒙

1 个答案:

答案 0 :(得分:0)

m2eclipse0.12.1的错误,需要在清单中导出org.sonatype.maven.wagon。