【问题标题】:maven index search in jboss plexus errorjboss plexus错误中的maven索引搜索
【发布时间】:2011-08-17 06:08:06
【问题描述】:

您好,我正在尝试从部署在 jboss 上的 seassion bean 中搜索 maven 存储库

此代码适用于 javaSE

 PlexusContainer plexus = new DefaultPlexusContainer();

            NexusIndexer n = (NexusIndexer) plexus.lookup(NexusIndexer.class);
            IndexUpdater iu = (IndexUpdater) plexus.lookup(IndexUpdater.class);

// DefaultNexusIndexer n = new DefaultNexusIndexer();
              列出 indexCreators=new ArrayList();

// IndexingContext c = n.addIndexingContext("test", "test",new File("/home/tomas/Desktop/test"),new File("/home/tomas/Desktop/index"), "http: //repository.jboss.org/", null);

             目录 tempIndexDirectory = new RAMDirectory();



// IndexCreator min = new MinimalArtifactInfoIndexCreator();
// MavenPluginArtifactInfoIndexCreator mavenPlugin = new MavenPluginArtifactInfoIndexCreator();
// MavenArchetypeArtifactInfoIndexCreator mavenArchetype = new MavenArchetypeArtifactInfoIndexCreator();
// JarFileContentsIndexCreator jar = new JarFileContentsIndexCreator();
//

             IndexCreator min = plexus.lookup(IndexCreator.class, MinimalArtifactInfoIndexCreator.ID);
                IndexCreator mavenPlugin = plexus.lookup(IndexCreator.class, MavenPluginArtifactInfoIndexCreator.ID);
                IndexCreator mavenArchetype = plexus.lookup(IndexCreator.class, MavenArchetypeArtifactInfoIndexCreator.ID);
                IndexCreator jar = plexus.lookup(IndexCreator.class, JarFileContentsIndexCreator.ID);
                indexCreators.add(min);
                indexCreators.add(mavenPlugin);
                indexCreators.add(mavenArchetype);
                indexCreators.add(jar);

                IndexingContext c = n.addIndexingContext(
                     “温度”,
                    “测试”,
                    新文件(“/home/tomas/Desktop/mavenTest”),
                    临时索引目录,
                    "http://repository.jboss.org/maven2/",
                    空值,
                    索引创建者);



               索引更新请求 ur=新索引更新请求(c);
               ur.setForceFullUpdate(true);
            iu.fetchAndUpdateIndex(ur);

// for (String s : c.getAllGroups()) {
// System.out.println(s);
// }
            BooleanQuery q = new BooleanQuery();
            q.add(n.constructQuery(ArtifactInfo.GROUP_ID, "*"), Occur.SHOULD);

            FlatSearchRequest 请求 = 新的 FlatSearchRequest(q);
            FlatSearchResponse 响应 = n.searchFlat(request);


            for (ArtifactInfo a : response.getResults()) {

                字符串 bUrl=url+a.groupId+"/"+a.artifactId+"/"+a.version+"/";
                字符串文件名=a.artifactId+"-"+a.version;
                System.out.println(bUrl+fileName+"."+a.packaging);


            }

在 jboss 上得到这个异常:

org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
      角色:org.sonatype.nexus.index.NexusIndex 

据我所知,这与构建路径无关,因为我可以实例化 DefaultNexusIndexer(这不起作用,因为 plexus 必须进行注射) 可能是神经丛的东西

请帮忙

【问题讨论】:

    标签: maven jboss nexus plexus maven-indexer


    【解决方案1】:

    您是否检查过您的类路径中是否有相同的Plexus configuration files

    我想在您的 SE 测试中,您的类路径中确实有一个 plexus 配置文件,其中包含角色 org.sonatype.nexus.index.NexusIndex 的组件描述符,您的 JBoss 上可能缺少该描述符。

    【讨论】:

    • 我在 SE 和 jboss 中都没有使用相同的包。
    • 编辑:org.sonatype.nexus.index.NexusIndex 的描述符与类在同一个包中会不会是丛无法找到它,因为它被打包在一个耳文件中?
    • 应该可以从一个ear文件加载它,因为它只使用[ClassLoader.getResources()](download.oracle.com/javase/6/docs/api/java/lang/…。也许你可以在你的JBoss上调试(或添加日志)到看看能不能加载?
    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 2013-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-17
      • 1970-01-01
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多