Поиск индекса maven в ошибке сплетения jboss

Привет, я пытаюсь найти репозиторий maven из сеансового компонента, развернутого на jboss.

этот код работает на 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 (который не работает, потому что plexus должен делать свои инъекции). Вероятно, это что-то с plexus

Пожалуйста помоги


person sherif    schedule 02.05.2011    source источник


Ответы (2)


этот работает

https://github.com/cstamas/maven-indexer-examples/tree/master/indexer-example-01 кстати это самая новая версия

person sherif    schedule 25.05.2011

Убедились ли вы, что на вашем путь к классам?

Я предполагаю, что в вашем тесте SE у вас есть файл конфигурации сплетения в пути к классам, который содержит дескриптор компонента для роли org.sonatype.nexus.index.NexusIndex, который может отсутствовать в вашем JBoss.

person wjans    schedule 04.05.2011
comment
У меня нет этих файлов конфигурации ни в том, ни в другом, я использую один и тот же пакет в SE и в jboss. - person sherif; 04.05.2011
comment
РЕДАКТИРОВАТЬ: дескриптор для org.sonatype.nexus.index.NexusIndex находится в том же пакете, что и класс. Может быть, сплетение не может его найти, потому что оно упаковано в файл уха? - person sherif; 04.05.2011
comment
Также должна быть возможность загрузить его из файла уха, поскольку он просто использует [ClassLoader.getResources()](download.oracle.com/javase/6/docs/api/java/lang/. Возможно, вы можете отладить ( или добавить ведение журнала) на вашем JBoss, чтобы узнать, можно ли его загрузить? - person wjans; 04.05.2011