jboss plexus中的maven索引搜索错误

发布于 2024-11-04 19:32:06 字数 3146 浏览 11 评论 0原文

您好,我试图从部署在 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();
              List 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);

             Directory 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(
                     "temp",
                    "test",
                    new File("/home/tomas/Desktop/mavenTest"),
                    tempIndexDirectory,
                    "http://repository.jboss.org/maven2/",
                    null,
                    indexCreators );



               IndexUpdateRequest ur=new IndexUpdateRequest(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 request = new FlatSearchRequest(q);
            FlatSearchResponse response = n.searchFlat(request);


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

                String bUrl=url+a.groupId+"/"+a.artifactId+"/"+a.version+"/";
                String fileName=a.artifactId+"-"+a.version;
                System.out.println(bUrl+fileName+"."+a.packaging);


            }

在 jboss 上出现此异常:

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

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

请帮忙

Hi Im trying to search a maven repository from a seassion bean deployed on jboss

this code works on javaSE

   PlexusContainer plexus =  new DefaultPlexusContainer();

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

//          DefaultNexusIndexer n = new DefaultNexusIndexer();
              List 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);

             Directory 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(
                     "temp",
                    "test",
                    new File("/home/tomas/Desktop/mavenTest"),
                    tempIndexDirectory,
                    "http://repository.jboss.org/maven2/",
                    null,
                    indexCreators );



               IndexUpdateRequest ur=new IndexUpdateRequest(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 request = new FlatSearchRequest(q);
            FlatSearchResponse response = n.searchFlat(request);


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

                String bUrl=url+a.groupId+"/"+a.artifactId+"/"+a.version+"/";
                String fileName=a.artifactId+"-"+a.version;
                System.out.println(bUrl+fileName+"."+a.packaging);


            }

On jboss a get this exception :

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

As far as I know this has nothing to do with the build path because i can instantiate the DefaultNexusIndexer (which does not work because plexus hast to make his injections)
It is probably something with plexus

Please help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

纵情客 2024-11-11 19:32:06

您是否检查过您的设备上是否有相同的 Plexus 配置文件类路径?

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

Have you checked that you have the same Plexus configuration files on your classpath?

I suppose that in your SE test you do have a plexus configuration file on the classpath which contains a component descriptor for role org.sonatype.nexus.index.NexusIndex which might be missing on your JBoss.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文