I would say that either the bundle with that xml resource does not export
the org.codehaus.plexus package where the xml file is, and/or the bundle
containing your activator does not import that package.  If those are both
true, it should work as far as I can tell.

Chris

--
Chris Custine
FUSESource :: http://fusesource.com
My Blog :: http://blog.organicelement.com
Apache ServiceMix :: http://servicemix.apache.org
Apache Felix :: http://felix.apache.org
Apache Directory Server :: http://directory.apache.org


On Thu, Jan 28, 2010 at 5:45 AM, Alexander Blotny <
[email protected]> wrote:

> Hi,
>
> I am trying to use maven embedder inside the Felix OSGi framework.
> At first I created the MANIFEST files for all the dependencies of maven
> embedder and used jardir for starting the bundles.
>
> Following jars are started:
>
> aspectjrt-1.5.3.jar
> commons-cli-1.0.jar
> doxia-sink-api-1.0-alpha-9.jar
> jsch-0.1.27.jar
> jtidy-4aug2000r7-dev.jar
> maven-artifact-3.0-SNAPSHOT.jar
> maven-core-2.1-SNAPSHOT.jar
> maven-embedder-2.1-SNAPSHOT.jar
> maven-lifecycle-2.1-SNAPSHOT.jar
> maven-model-2.1-SNAPSHOT.jar
> maven-plugin-api-2.1-SNAPSHOT.jar
> maven-profile-2.1-SNAPSHOT.jar
> maven-project-2.1-SNAPSHOT.jar
> maven-reporting-api-2.1-SNAPSHOT.jar
> maven-toolchain-2.1-SNAPSHOT.jar
> maven-workspace-2.1-SNAPSHOT.jar
> plexus-classworlds-1.2-alpha-12.jar
> plexus-container-default-1.0-alpha-44.jar
> plexus-interactivity-api-1.0-alpha-6.jar
> plexus-interpolation-1.0-SNAPSHOT.jar
> plexus-utils-1.5.1.jar
> wagon-file-1.0-beta-2.jar
> wagon-http-lightweight-1.0-beta-2.jar
> wagon-http-shared-1.0-beta-2.jar
> wagon-provider-api-1.0-beta-2.jar
> wagon-ssh-1.0-beta-2.jar
> wagon-ssh-common-1.0-beta-2.jar
> wagon-ssh-external-1.0-beta-2.jar
>
> Using maven embedder from within eclipse was no problem but starting it in
> the OSGi framework throws exceptions.
> The code for using maven embedder I got from the apache maven homepage
> (excerpt) and started it in the Activator of a bundle:
>
> File projectDirectory = new File(folder);
> File user = new File(projectDirectory, "settings.xml");
> Configuration configuration = new
> DefaultConfiguration().setUserSettingsFile( user ).setClassLoader(
> context.getBundle().getClass().getClassLoader() );
> ConfigurationValidationResult validationResult =
> MavenEmbedder.validateConfiguration(configuration);
> if ( validationResult.isValid() )
>        {
>            MavenEmbedder embedder = null;
>            try {
>                embedder = new MavenEmbedder( configuration );
>            } catch (MavenEmbedderException e) {
>                e.printStackTrace();
>             }
>         }
>
> As you can see, as Classloader I am using the one from the bundle.
> The problem is now that inside the jar plexus-container is a resource as
> xml
> which is accessed via getResourceStream of the Classloader. But the
> resource
> cannot be found:
>
> java.lang.IllegalStateException: The internal default plexus-bootstrap.xml
> is missing. This is highly irregular, your plexus JAR is most likely
> corrupt. Realms:
>  plexus.core parent=sun.misc.launcher$appclassloa...@6a765291 (null)
>    at
>
> org.codehaus.plexus.DefaultPlexusContainer.initializeConfiguration(DefaultPl
> exusContainer.java:1017) [na:na]
>    at
>
> org.codehaus.plexus.DefaultPlexusContainer.initialize(DefaultPlexusContainer
> .java:812) [na:na]
>    at
>
> org.codehaus.plexus.DefaultPlexusContainer.construct(DefaultPlexusContainer.
> java:406) [na:na]
>    at
>
> org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.jav
> a:199) [na:na]
>    at org.apache.maven.embedder.MavenEmbedder.start(MavenEmbedder.java:652)
> [na:na]
>    at
> org.apache.maven.embedder.MavenEmbedder.<init>(MavenEmbedder.java:198)
> [na:na]
>
> The source code of accessing the xml file in plexus-container.jar looks
> like
> this:
>
>        InputStream is = containerRealm.getResourceAsStream(
> "org/codehaus/plexus/plexus-bootstrap.xml" );         if ( is == null )
> {            ClassRealm cr = containerRealm;            String realmStack =
> "";            while ( cr != null )            {                realmStack
> += "\n  " + cr.getId() + " parent=" + cr.getParent() + " ("
> + cr.getResource( "org/codehaus/plexus/plexus-bootstrap.xml" ) + ")";
> cr = cr.getParentRealm();            }
> containerRealm.display();
> throw new IllegalStateException( "The internal default plexus-bootstrap.xml
> is missing. "                + "This is highly irregular, your plexus JAR
> is
> most likely corrupt. Realms:" + realmStack );        }
>
> Is there a possibility to assure access to that resource without changing
> the source code?
> Has anyone an idea?
>
> Thanks,
> Alex
>
>
>

Reply via email to