jboss plexus中的maven索引搜索错误

jboss plexus中的maven索引搜索错误,maven,jboss,nexus,plexus,maven-indexer,Maven,Jboss,Nexus,Plexus,Maven Indexer,嗨,我正试图从部署在jboss上的seassion bean中搜索maven存储库 这段代码在javaSE上工作 PlexusContainer plexus = new DefaultPlexusContainer(); NexusIndexer n = (NexusIndexer) plexus.lookup(NexusIndexer.class); IndexUpdater iu = (IndexUpdater) plexus.looku

嗨,我正试图从部署在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); } PlexusContainer-plexus=新的DefaultPlexusContainer(); NexusIndexer n=(NexusIndexer)plexus.lookup(NexusIndexer.class); IndexUpdater iu=(IndexUpdater)plexus.lookup(IndexUpdater.class); //DefaultNexusIndexer n=新的DefaultNexusIndexer(); List indexCreators=new ArrayList(); //IndexingContext c=n.addIndexingContext(“测试”、“测试”、新文件(“/home/tomas/Desktop/test”)、新文件(“/home/tomas/Desktop/index”)、”http://repository.jboss.org/“,空); 目录tempIndexDirectory=new-RAMDirectory(); //IndexCreator min=新的MinimalArtificationFoIndexCreator(); //MavenPluginArtifactInfoIndexCreator mavenPlugin=新的MavenPluginArtifactInfoIndexCreator(); //MavenArchetypeArtifactInfoIndexCreator mavenArchetype=新的MavenArchetypeArtifactInfoIndexCreator(); //JarFileContentsIndexCreator jar=新的JarFileContentsIndexCreator(); // IndexCreator min=plexus.lookup(IndexCreator.class,minimarArtificationFoIndexCreator.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); 添加(最小值); 添加(mavenPlugin); add(mavenArchetype); 添加(jar); IndexingContext c=n.addIndexingContext( “临时工”, “测试”, 新文件(“/home/tomas/Desktop/mavenTest”), 临时索引目录, "http://repository.jboss.org/maven2/", 无效的 非激励器); IndexUpdateRequest ur=新的IndexUpdateRequest(c); ur.SETLUPDATE(真); iu.fetchAndUpdateIndex(ur); //for(字符串s:c.getAllGroups()){ //系统输出打印项次; // } BooleanQuery q=新的BooleanQuery(); q、 添加(n.constructQuery(ArtifactInfo.GROUP_ID,“*”),出现。应); FlatSearchRequest请求=新的FlatSearchRequest(q); FlatSearchResponse响应=n.searchFlat(请求); for(ArtifactInfo a:response.getResults()){ String bUrl=url+a.groupId+“/”+a.artifactId+“/”+a.version+“/”; 字符串文件名=a.artifactId+“-”+a.version; System.out.println(bUrl+fileName+“+a.packaging); } 在JBossA上,获取此异常:

org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException role: org.sonatype.nexus.index.NexusIndex org.codehaus.plexus.component.repository.exception.ComponentLookupException:java.util.NoSuchElementException 角色:org.sonatype.nexus.index.NexusIndex 据我所知,这与构建路径无关,因为我可以实例化DefaultNexusIndexer(这不起作用,因为plexus必须进行注入) 可能是神经丛的问题


请帮助

您是否检查了类路径上是否有相同的路径

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

这一个有效


顺便说一句,它是最新版本

我在Im中也没有此配置文件,在SE和jboss.EDIT中使用相同的包:org.sonatype.nexus.index.NexusIndex的描述符与类在同一个包中,可能是plexus找不到它,因为它打包在ear文件中?应该可以从ear文件中加载它因为它只使用[ClassLoader.getResources()](。也许您可以在JBoss上调试(或添加日志记录)以查看是否可以加载它?