こんにちは、jboss にデプロイされた seassion Bean から Maven リポジトリを検索しようとしています
このコードは javaSE で動作します
PlexusContainer 神経叢 = 新しい DefaultPlexusContainer();
NexusIndexer n = (NexusIndexer) plexus.lookup(NexusIndexer.class);
IndexUpdater iu = (IndexUpdater) plexus.lookup(IndexUpdater.class);
// DefaultNexusIndexer n = 新しい 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 = 新しい RAMDirectory();
// IndexCreator min = 新しい 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(分);
indexCreators.add(mavenPlugin);
indexCreators.add(mavenArchetype);
indexCreators.add(jar);
IndexingContext c = n.addIndexingContext(
"温度"、
"テスト"、
new File("/home/tomas/Desktop/mavenTest"),
tempIndex ディレクトリ、
"http://repository.jboss.org/maven2/",
ヌル、
indexCreators );
IndexUpdateRequest ur=新しい IndexUpdateRequest(c);
ur.setForceFullUpdate(真);
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 リクエスト = new FlatSearchRequest(q);
FlatSearchResponse レスポンス = n.searchFlat(リクエスト);
for (ArtifactInfo a : response.getResults()) {
文字列 bUrl=url+a.groupId+"/"+a.artifactId+"/"+a.version+"/";
文字列 fileName=a.artifactId+"-"+a.version;
System.out.println(bUrl+ファイル名+"."+a.packaging);
}
jboss では、次の例外が発生します。
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
役割: org.sonatype.nexus.index.NexusIndex
私の知る限り、DefaultNexusIndexer をインスタンス化できるため、これはビルド パスとは何の関係もありません (神経叢が注入を行わなければならないため、これは機能しません)。
助けてください