You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mirko Friedenhagen <mf...@gmail.com> on 2015/11/21 22:20:12 UTC

Running tests using failsafe from a shaded jar?

Hello,

I want to use to run tests on machine, where Maven is not installed
and access to a repository is not allowed.
However I want to (ab-)use the failsafe plugin so I may use the fine
machinery which allows to specify tests and get XML reports.

Using maven-embedded I created an App class which just runs
failsafe:integration tests, all dependencies are found in a shaded
jar.
I already used org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer
so a complete looking META-INF/plexus/components.xml is created.

When I start the jar with java -jar MY_SHADED_JAR.jar I always get the
following error:

22:09:57.365 [main] WARN  Sisu - Error injecting:
org.apache.maven.project.DefaultProjectBuildingHelper

com.google.inject.ProvisionException: Unable to provision, see the
following errors:


1) No implementation for org.apache.maven.classrealm.ClassRealmManager
was bound.

  while locating org.apache.maven.project.DefaultProjectBuildingHelper


Looking into components.xml DefaultClassRealmManager is not there but
is referenced twice.

Grepping through the components.xml files in a Maven installation, I
do not see where the DefaultClassRealmManager is instantiated.

Regards Mirko
--
http://illegalstateexception.blogspot.com/
https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
https://bitbucket.org/mfriedenhagen/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Running tests using failsafe from a shaded jar?

Posted by Mirko Friedenhagen <mf...@gmail.com>.
Hello Karl-Heinz,

I found the class but in none of the components.xml  files from plexus is a
hint that DCRM is the default for CRM :-)
Regards
Mirko
-- 
Sent from my mobile
Am 21.11.2015 22:33 schrieb "Karl Heinz Marbaise" <kh...@gmx.de>:

> Hi Mirko,
>
> The class DefaultClassRealmManager is contained in maven-core module..
>
> @Named
> @Singleton
> public class DefaultClassRealmManager
>     implements ClassRealmManager
> {
>     public static final String API_REALMID = "maven.api";
>
>     /**
>      * During normal command line build, ClassWorld is loaded by jvm
> system classloader, which only includes
>      * plexus-classworlds jar and possibly javaagent classes, see
> https://issues.apache.org/jira/browse/MNG-4747.
>      * <p>
>      * Using ClassWorld to determine plugin/extensions realm parent
> classloaders gives m2e and integration test harness
>      * flexibility to load multiple version of maven into dedicated
> classloaders without assuming state of jvm system
>      * classloader.
>      */
>     private static final ClassLoade
>
>
> ...
>
> http://maven.apache.org/ref/3.0.5/maven-core/apidocs/org/apache/maven/classrealm/DefaultClassRealmManager.html
>
>
> Kind regards
> Karl Heinz Marbaise
>
>
> On 11/21/15 10:20 PM, Mirko Friedenhagen wrote:
>
>> Hello,
>>
>> I want to use to run tests on machine, where Maven is not installed
>> and access to a repository is not allowed.
>> However I want to (ab-)use the failsafe plugin so I may use the fine
>> machinery which allows to specify tests and get XML reports.
>>
>> Using maven-embedded I created an App class which just runs
>> failsafe:integration tests, all dependencies are found in a shaded
>> jar.
>> I already used
>> org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer
>> so a complete looking META-INF/plexus/components.xml is created.
>>
>> When I start the jar with java -jar MY_SHADED_JAR.jar I always get the
>> following error:
>>
>> 22:09:57.365 [main] WARN  Sisu - Error injecting:
>> org.apache.maven.project.DefaultProjectBuildingHelper
>>
>> com.google.inject.ProvisionException: Unable to provision, see the
>> following errors:
>>
>>
>> 1) No implementation for org.apache.maven.classrealm.ClassRealmManager
>> was bound.
>>
>>    while locating org.apache.maven.project.DefaultProjectBuildingHelper
>>
>>
>> Looking into components.xml DefaultClassRealmManager is not there but
>> is referenced twice.
>>
>> Grepping through the components.xml files in a Maven installation, I
>> do not see where the DefaultClassRealmManager is instantiated.
>>
>> Regards Mirko
>> --
>> http://illegalstateexception.blogspot.com/
>> https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
>> https://bitbucket.org/mfriedenhagen/
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Running tests using failsafe from a shaded jar?

Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi Mirko,

The class DefaultClassRealmManager is contained in maven-core module..

@Named
@Singleton
public class DefaultClassRealmManager
     implements ClassRealmManager
{
     public static final String API_REALMID = "maven.api";

     /**
      * During normal command line build, ClassWorld is loaded by jvm 
system classloader, which only includes
      * plexus-classworlds jar and possibly javaagent classes, see 
https://issues.apache.org/jira/browse/MNG-4747.
      * <p>
      * Using ClassWorld to determine plugin/extensions realm parent 
classloaders gives m2e and integration test harness
      * flexibility to load multiple version of maven into dedicated 
classloaders without assuming state of jvm system
      * classloader.
      */
     private static final ClassLoade


...
http://maven.apache.org/ref/3.0.5/maven-core/apidocs/org/apache/maven/classrealm/DefaultClassRealmManager.html


Kind regards
Karl Heinz Marbaise


On 11/21/15 10:20 PM, Mirko Friedenhagen wrote:
> Hello,
>
> I want to use to run tests on machine, where Maven is not installed
> and access to a repository is not allowed.
> However I want to (ab-)use the failsafe plugin so I may use the fine
> machinery which allows to specify tests and get XML reports.
>
> Using maven-embedded I created an App class which just runs
> failsafe:integration tests, all dependencies are found in a shaded
> jar.
> I already used org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer
> so a complete looking META-INF/plexus/components.xml is created.
>
> When I start the jar with java -jar MY_SHADED_JAR.jar I always get the
> following error:
>
> 22:09:57.365 [main] WARN  Sisu - Error injecting:
> org.apache.maven.project.DefaultProjectBuildingHelper
>
> com.google.inject.ProvisionException: Unable to provision, see the
> following errors:
>
>
> 1) No implementation for org.apache.maven.classrealm.ClassRealmManager
> was bound.
>
>    while locating org.apache.maven.project.DefaultProjectBuildingHelper
>
>
> Looking into components.xml DefaultClassRealmManager is not there but
> is referenced twice.
>
> Grepping through the components.xml files in a Maven installation, I
> do not see where the DefaultClassRealmManager is instantiated.
>
> Regards Mirko
> --
> http://illegalstateexception.blogspot.com/
> https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
> https://bitbucket.org/mfriedenhagen/
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Running tests using failsafe from a shaded jar?

Posted by Mirko Friedenhagen <mf...@gmail.com>.
sisu-maven-plugin helped a lot:
https://github.com/mfriedenhagen/mavenembeddedtest
Regards Mirko
--
http://illegalstateexception.blogspot.com/
https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
https://bitbucket.org/mfriedenhagen/


On Tue, Nov 24, 2015 at 4:53 PM, Mirko Friedenhagen
<mf...@gmail.com> wrote:
> Hello Tamás, hello Jason,
>
> thanks for your tips, I will try to understand and digest your input :-).
>
> Regards
> Mirko
> Regards Mirko
> --
> http://illegalstateexception.blogspot.com/
> https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
> https://bitbucket.org/mfriedenhagen/
>
>
> On Tue, Nov 24, 2015 at 10:17 AM, Tamás Cservenák <ta...@cservenak.net> wrote:
>> Mirko,
>>
>> or just run the index goal of sisu-maven-plugin in pre-package phase, like
>> it is done here (to create the META-INF/sisu/javax.inject.Named index for
>> WAR that contains many things).
>>
>> https://github.com/sonatype/nexus-oss/blob/nexus-2.11.x/components/nexus-webapp/pom.xml#L336
>>
>> See
>> https://www.eclipse.org/sisu/docs/api/org.eclipse.sisu.mojos/index-mojo.html
>>
>> On Mon, Nov 23, 2015 at 2:23 PM Jason van Zyl <ja...@takari.io> wrote:
>>
>>> Mirko,
>>>
>>> You’ll notice if you look at the source that it’s a JSR330 component. So
>>> there is a the sisu-maven-plugin which generates a
>>> META-INF/sisu/javax.inject.Named as part of the build. You will want to
>>> look in your shaded JAR and make sure you have one of those files, I’m not
>>> certain if there is a resource transformer that deals with this file so you
>>> might have to make one of those. I say might because it depends on how you
>>> start up the container for Maven. If you don’t particularly care about
>>> startup speed you can make the container scan the classpath and it will
>>> create all the bindings from the classes in the scan. By default in Maven
>>> we get the container to use the index file cited above because it’s much
>>> faster at creating all the bindings. Your error results from there being no
>>> binding for the DefaultClassRealmManager so it’s likely not finding the
>>> javax.inject.Named file.
>>>
>>> If you look at some of the test cases[1] in maven-core you’ll see where
>>> the container is created and see how the scanning behaviour is changed. To
>>> try something quickly you can just turn the classpath scanning on and see
>>> if it’s fast enough. You might also have to lift a few bits from the
>>> PlexusTestCase class itself but it’s very similar to how the container if
>>> created in the MavenCli class which also serves as an example.
>>>
>>> [1]:
>>> https://github.com/apache/maven/blob/master/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
>>>
>>> > On Nov 22, 2015, at 2:03 AM, Mirko Friedenhagen <mf...@gmail.com>
>>> wrote:
>>> >
>>> > Hello Stephen, I will share how to do this in general. As it it not as
>>> easy
>>> > as I hoped I will firstly extract a POC project and share that on GitHub
>>> > immediately with the risk of never succeeding :-)
>>> >
>>> > Regards
>>> > Mirko
>>> > --
>>> > Sent from my mobile
>>> > Am 21.11.2015 23:34 schrieb "Stephen Connolly" <
>>> > stephen.alan.connolly@gmail.com>:
>>> >
>>> >> If you get this working, any chance you could share your work?
>>> >>
>>> >> On 21 November 2015 at 21:20, Mirko Friedenhagen <
>>> mfriedenhagen@gmail.com>
>>> >> wrote:
>>> >>
>>> >>> Hello,
>>> >>>
>>> >>> I want to use to run tests on machine, where Maven is not installed
>>> >>> and access to a repository is not allowed.
>>> >>> However I want to (ab-)use the failsafe plugin so I may use the fine
>>> >>> machinery which allows to specify tests and get XML reports.
>>> >>>
>>> >>> Using maven-embedded I created an App class which just runs
>>> >>> failsafe:integration tests, all dependencies are found in a shaded
>>> >>> jar.
>>> >>> I already used
>>> >>>
>>> org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer
>>> >>> so a complete looking META-INF/plexus/components.xml is created.
>>> >>>
>>> >>> When I start the jar with java -jar MY_SHADED_JAR.jar I always get the
>>> >>> following error:
>>> >>>
>>> >>> 22:09:57.365 [main] WARN  Sisu - Error injecting:
>>> >>> org.apache.maven.project.DefaultProjectBuildingHelper
>>> >>>
>>> >>> com.google.inject.ProvisionException: Unable to provision, see the
>>> >>> following errors:
>>> >>>
>>> >>>
>>> >>> 1) No implementation for org.apache.maven.classrealm.ClassRealmManager
>>> >>> was bound.
>>> >>>
>>> >>>  while locating org.apache.maven.project.DefaultProjectBuildingHelper
>>> >>>
>>> >>>
>>> >>> Looking into components.xml DefaultClassRealmManager is not there but
>>> >>> is referenced twice.
>>> >>>
>>> >>> Grepping through the components.xml files in a Maven installation, I
>>> >>> do not see where the DefaultClassRealmManager is instantiated.
>>> >>>
>>> >>> Regards Mirko
>>> >>> --
>>> >>> http://illegalstateexception.blogspot.com/
>>> >>> https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
>>> >>> https://bitbucket.org/mfriedenhagen/
>>> >>>
>>> >>> ---------------------------------------------------------------------
>>> >>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> >>> For additional commands, e-mail: users-help@maven.apache.org
>>> >>>
>>> >>>
>>> >>
>>>
>>> Thanks,
>>>
>>> Jason
>>>
>>> ----------------------------------------------------------
>>> Jason van Zyl
>>> Founder, Takari and Apache Maven
>>> http://twitter.com/jvanzyl
>>> http://twitter.com/takari_io
>>> ---------------------------------------------------------
>>>
>>> Simplex sigillum veri. (Simplicity is the seal of truth.)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Running tests using failsafe from a shaded jar?

Posted by Mirko Friedenhagen <mf...@gmail.com>.
Hello Tamás, hello Jason,

thanks for your tips, I will try to understand and digest your input :-).

Regards
Mirko
Regards Mirko
--
http://illegalstateexception.blogspot.com/
https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
https://bitbucket.org/mfriedenhagen/


On Tue, Nov 24, 2015 at 10:17 AM, Tamás Cservenák <ta...@cservenak.net> wrote:
> Mirko,
>
> or just run the index goal of sisu-maven-plugin in pre-package phase, like
> it is done here (to create the META-INF/sisu/javax.inject.Named index for
> WAR that contains many things).
>
> https://github.com/sonatype/nexus-oss/blob/nexus-2.11.x/components/nexus-webapp/pom.xml#L336
>
> See
> https://www.eclipse.org/sisu/docs/api/org.eclipse.sisu.mojos/index-mojo.html
>
> On Mon, Nov 23, 2015 at 2:23 PM Jason van Zyl <ja...@takari.io> wrote:
>
>> Mirko,
>>
>> You’ll notice if you look at the source that it’s a JSR330 component. So
>> there is a the sisu-maven-plugin which generates a
>> META-INF/sisu/javax.inject.Named as part of the build. You will want to
>> look in your shaded JAR and make sure you have one of those files, I’m not
>> certain if there is a resource transformer that deals with this file so you
>> might have to make one of those. I say might because it depends on how you
>> start up the container for Maven. If you don’t particularly care about
>> startup speed you can make the container scan the classpath and it will
>> create all the bindings from the classes in the scan. By default in Maven
>> we get the container to use the index file cited above because it’s much
>> faster at creating all the bindings. Your error results from there being no
>> binding for the DefaultClassRealmManager so it’s likely not finding the
>> javax.inject.Named file.
>>
>> If you look at some of the test cases[1] in maven-core you’ll see where
>> the container is created and see how the scanning behaviour is changed. To
>> try something quickly you can just turn the classpath scanning on and see
>> if it’s fast enough. You might also have to lift a few bits from the
>> PlexusTestCase class itself but it’s very similar to how the container if
>> created in the MavenCli class which also serves as an example.
>>
>> [1]:
>> https://github.com/apache/maven/blob/master/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
>>
>> > On Nov 22, 2015, at 2:03 AM, Mirko Friedenhagen <mf...@gmail.com>
>> wrote:
>> >
>> > Hello Stephen, I will share how to do this in general. As it it not as
>> easy
>> > as I hoped I will firstly extract a POC project and share that on GitHub
>> > immediately with the risk of never succeeding :-)
>> >
>> > Regards
>> > Mirko
>> > --
>> > Sent from my mobile
>> > Am 21.11.2015 23:34 schrieb "Stephen Connolly" <
>> > stephen.alan.connolly@gmail.com>:
>> >
>> >> If you get this working, any chance you could share your work?
>> >>
>> >> On 21 November 2015 at 21:20, Mirko Friedenhagen <
>> mfriedenhagen@gmail.com>
>> >> wrote:
>> >>
>> >>> Hello,
>> >>>
>> >>> I want to use to run tests on machine, where Maven is not installed
>> >>> and access to a repository is not allowed.
>> >>> However I want to (ab-)use the failsafe plugin so I may use the fine
>> >>> machinery which allows to specify tests and get XML reports.
>> >>>
>> >>> Using maven-embedded I created an App class which just runs
>> >>> failsafe:integration tests, all dependencies are found in a shaded
>> >>> jar.
>> >>> I already used
>> >>>
>> org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer
>> >>> so a complete looking META-INF/plexus/components.xml is created.
>> >>>
>> >>> When I start the jar with java -jar MY_SHADED_JAR.jar I always get the
>> >>> following error:
>> >>>
>> >>> 22:09:57.365 [main] WARN  Sisu - Error injecting:
>> >>> org.apache.maven.project.DefaultProjectBuildingHelper
>> >>>
>> >>> com.google.inject.ProvisionException: Unable to provision, see the
>> >>> following errors:
>> >>>
>> >>>
>> >>> 1) No implementation for org.apache.maven.classrealm.ClassRealmManager
>> >>> was bound.
>> >>>
>> >>>  while locating org.apache.maven.project.DefaultProjectBuildingHelper
>> >>>
>> >>>
>> >>> Looking into components.xml DefaultClassRealmManager is not there but
>> >>> is referenced twice.
>> >>>
>> >>> Grepping through the components.xml files in a Maven installation, I
>> >>> do not see where the DefaultClassRealmManager is instantiated.
>> >>>
>> >>> Regards Mirko
>> >>> --
>> >>> http://illegalstateexception.blogspot.com/
>> >>> https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
>> >>> https://bitbucket.org/mfriedenhagen/
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> >>> For additional commands, e-mail: users-help@maven.apache.org
>> >>>
>> >>>
>> >>
>>
>> Thanks,
>>
>> Jason
>>
>> ----------------------------------------------------------
>> Jason van Zyl
>> Founder, Takari and Apache Maven
>> http://twitter.com/jvanzyl
>> http://twitter.com/takari_io
>> ---------------------------------------------------------
>>
>> Simplex sigillum veri. (Simplicity is the seal of truth.)
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Running tests using failsafe from a shaded jar?

Posted by Tamás Cservenák <ta...@cservenak.net>.
Mirko,

or just run the index goal of sisu-maven-plugin in pre-package phase, like
it is done here (to create the META-INF/sisu/javax.inject.Named index for
WAR that contains many things).

https://github.com/sonatype/nexus-oss/blob/nexus-2.11.x/components/nexus-webapp/pom.xml#L336

See
https://www.eclipse.org/sisu/docs/api/org.eclipse.sisu.mojos/index-mojo.html

On Mon, Nov 23, 2015 at 2:23 PM Jason van Zyl <ja...@takari.io> wrote:

> Mirko,
>
> You’ll notice if you look at the source that it’s a JSR330 component. So
> there is a the sisu-maven-plugin which generates a
> META-INF/sisu/javax.inject.Named as part of the build. You will want to
> look in your shaded JAR and make sure you have one of those files, I’m not
> certain if there is a resource transformer that deals with this file so you
> might have to make one of those. I say might because it depends on how you
> start up the container for Maven. If you don’t particularly care about
> startup speed you can make the container scan the classpath and it will
> create all the bindings from the classes in the scan. By default in Maven
> we get the container to use the index file cited above because it’s much
> faster at creating all the bindings. Your error results from there being no
> binding for the DefaultClassRealmManager so it’s likely not finding the
> javax.inject.Named file.
>
> If you look at some of the test cases[1] in maven-core you’ll see where
> the container is created and see how the scanning behaviour is changed. To
> try something quickly you can just turn the classpath scanning on and see
> if it’s fast enough. You might also have to lift a few bits from the
> PlexusTestCase class itself but it’s very similar to how the container if
> created in the MavenCli class which also serves as an example.
>
> [1]:
> https://github.com/apache/maven/blob/master/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java
>
> > On Nov 22, 2015, at 2:03 AM, Mirko Friedenhagen <mf...@gmail.com>
> wrote:
> >
> > Hello Stephen, I will share how to do this in general. As it it not as
> easy
> > as I hoped I will firstly extract a POC project and share that on GitHub
> > immediately with the risk of never succeeding :-)
> >
> > Regards
> > Mirko
> > --
> > Sent from my mobile
> > Am 21.11.2015 23:34 schrieb "Stephen Connolly" <
> > stephen.alan.connolly@gmail.com>:
> >
> >> If you get this working, any chance you could share your work?
> >>
> >> On 21 November 2015 at 21:20, Mirko Friedenhagen <
> mfriedenhagen@gmail.com>
> >> wrote:
> >>
> >>> Hello,
> >>>
> >>> I want to use to run tests on machine, where Maven is not installed
> >>> and access to a repository is not allowed.
> >>> However I want to (ab-)use the failsafe plugin so I may use the fine
> >>> machinery which allows to specify tests and get XML reports.
> >>>
> >>> Using maven-embedded I created an App class which just runs
> >>> failsafe:integration tests, all dependencies are found in a shaded
> >>> jar.
> >>> I already used
> >>>
> org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer
> >>> so a complete looking META-INF/plexus/components.xml is created.
> >>>
> >>> When I start the jar with java -jar MY_SHADED_JAR.jar I always get the
> >>> following error:
> >>>
> >>> 22:09:57.365 [main] WARN  Sisu - Error injecting:
> >>> org.apache.maven.project.DefaultProjectBuildingHelper
> >>>
> >>> com.google.inject.ProvisionException: Unable to provision, see the
> >>> following errors:
> >>>
> >>>
> >>> 1) No implementation for org.apache.maven.classrealm.ClassRealmManager
> >>> was bound.
> >>>
> >>>  while locating org.apache.maven.project.DefaultProjectBuildingHelper
> >>>
> >>>
> >>> Looking into components.xml DefaultClassRealmManager is not there but
> >>> is referenced twice.
> >>>
> >>> Grepping through the components.xml files in a Maven installation, I
> >>> do not see where the DefaultClassRealmManager is instantiated.
> >>>
> >>> Regards Mirko
> >>> --
> >>> http://illegalstateexception.blogspot.com/
> >>> https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
> >>> https://bitbucket.org/mfriedenhagen/
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >>> For additional commands, e-mail: users-help@maven.apache.org
> >>>
> >>>
> >>
>
> Thanks,
>
> Jason
>
> ----------------------------------------------------------
> Jason van Zyl
> Founder, Takari and Apache Maven
> http://twitter.com/jvanzyl
> http://twitter.com/takari_io
> ---------------------------------------------------------
>
> Simplex sigillum veri. (Simplicity is the seal of truth.)
>
>
>
>
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Running tests using failsafe from a shaded jar?

Posted by Jason van Zyl <ja...@takari.io>.
Mirko,

You’ll notice if you look at the source that it’s a JSR330 component. So there is a the sisu-maven-plugin which generates a META-INF/sisu/javax.inject.Named as part of the build. You will want to look in your shaded JAR and make sure you have one of those files, I’m not certain if there is a resource transformer that deals with this file so you might have to make one of those. I say might because it depends on how you start up the container for Maven. If you don’t particularly care about startup speed you can make the container scan the classpath and it will create all the bindings from the classes in the scan. By default in Maven we get the container to use the index file cited above because it’s much faster at creating all the bindings. Your error results from there being no binding for the DefaultClassRealmManager so it’s likely not finding the javax.inject.Named file.

If you look at some of the test cases[1] in maven-core you’ll see where the container is created and see how the scanning behaviour is changed. To try something quickly you can just turn the classpath scanning on and see if it’s fast enough. You might also have to lift a few bits from the PlexusTestCase class itself but it’s very similar to how the container if created in the MavenCli class which also serves as an example.

[1]: https://github.com/apache/maven/blob/master/maven-core/src/test/java/org/apache/maven/AbstractCoreMavenComponentTestCase.java

> On Nov 22, 2015, at 2:03 AM, Mirko Friedenhagen <mf...@gmail.com> wrote:
> 
> Hello Stephen, I will share how to do this in general. As it it not as easy
> as I hoped I will firstly extract a POC project and share that on GitHub
> immediately with the risk of never succeeding :-)
> 
> Regards
> Mirko
> -- 
> Sent from my mobile
> Am 21.11.2015 23:34 schrieb "Stephen Connolly" <
> stephen.alan.connolly@gmail.com>:
> 
>> If you get this working, any chance you could share your work?
>> 
>> On 21 November 2015 at 21:20, Mirko Friedenhagen <mf...@gmail.com>
>> wrote:
>> 
>>> Hello,
>>> 
>>> I want to use to run tests on machine, where Maven is not installed
>>> and access to a repository is not allowed.
>>> However I want to (ab-)use the failsafe plugin so I may use the fine
>>> machinery which allows to specify tests and get XML reports.
>>> 
>>> Using maven-embedded I created an App class which just runs
>>> failsafe:integration tests, all dependencies are found in a shaded
>>> jar.
>>> I already used
>>> org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer
>>> so a complete looking META-INF/plexus/components.xml is created.
>>> 
>>> When I start the jar with java -jar MY_SHADED_JAR.jar I always get the
>>> following error:
>>> 
>>> 22:09:57.365 [main] WARN  Sisu - Error injecting:
>>> org.apache.maven.project.DefaultProjectBuildingHelper
>>> 
>>> com.google.inject.ProvisionException: Unable to provision, see the
>>> following errors:
>>> 
>>> 
>>> 1) No implementation for org.apache.maven.classrealm.ClassRealmManager
>>> was bound.
>>> 
>>>  while locating org.apache.maven.project.DefaultProjectBuildingHelper
>>> 
>>> 
>>> Looking into components.xml DefaultClassRealmManager is not there but
>>> is referenced twice.
>>> 
>>> Grepping through the components.xml files in a Maven installation, I
>>> do not see where the DefaultClassRealmManager is instantiated.
>>> 
>>> Regards Mirko
>>> --
>>> http://illegalstateexception.blogspot.com/
>>> https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
>>> https://bitbucket.org/mfriedenhagen/
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>> 
>>> 
>> 

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder, Takari and Apache Maven
http://twitter.com/jvanzyl
http://twitter.com/takari_io
---------------------------------------------------------

Simplex sigillum veri. (Simplicity is the seal of truth.)













---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Running tests using failsafe from a shaded jar?

Posted by Mirko Friedenhagen <mf...@gmail.com>.
Hello Stephen, I will share how to do this in general. As it it not as easy
as I hoped I will firstly extract a POC project and share that on GitHub
immediately with the risk of never succeeding :-)

Regards
Mirko
-- 
Sent from my mobile
Am 21.11.2015 23:34 schrieb "Stephen Connolly" <
stephen.alan.connolly@gmail.com>:

> If you get this working, any chance you could share your work?
>
> On 21 November 2015 at 21:20, Mirko Friedenhagen <mf...@gmail.com>
> wrote:
>
> > Hello,
> >
> > I want to use to run tests on machine, where Maven is not installed
> > and access to a repository is not allowed.
> > However I want to (ab-)use the failsafe plugin so I may use the fine
> > machinery which allows to specify tests and get XML reports.
> >
> > Using maven-embedded I created an App class which just runs
> > failsafe:integration tests, all dependencies are found in a shaded
> > jar.
> > I already used
> > org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer
> > so a complete looking META-INF/plexus/components.xml is created.
> >
> > When I start the jar with java -jar MY_SHADED_JAR.jar I always get the
> > following error:
> >
> > 22:09:57.365 [main] WARN  Sisu - Error injecting:
> > org.apache.maven.project.DefaultProjectBuildingHelper
> >
> > com.google.inject.ProvisionException: Unable to provision, see the
> > following errors:
> >
> >
> > 1) No implementation for org.apache.maven.classrealm.ClassRealmManager
> > was bound.
> >
> >   while locating org.apache.maven.project.DefaultProjectBuildingHelper
> >
> >
> > Looking into components.xml DefaultClassRealmManager is not there but
> > is referenced twice.
> >
> > Grepping through the components.xml files in a Maven installation, I
> > do not see where the DefaultClassRealmManager is instantiated.
> >
> > Regards Mirko
> > --
> > http://illegalstateexception.blogspot.com/
> > https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
> > https://bitbucket.org/mfriedenhagen/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>

Re: Running tests using failsafe from a shaded jar?

Posted by Stephen Connolly <st...@gmail.com>.
If you get this working, any chance you could share your work?

On 21 November 2015 at 21:20, Mirko Friedenhagen <mf...@gmail.com>
wrote:

> Hello,
>
> I want to use to run tests on machine, where Maven is not installed
> and access to a repository is not allowed.
> However I want to (ab-)use the failsafe plugin so I may use the fine
> machinery which allows to specify tests and get XML reports.
>
> Using maven-embedded I created an App class which just runs
> failsafe:integration tests, all dependencies are found in a shaded
> jar.
> I already used
> org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer
> so a complete looking META-INF/plexus/components.xml is created.
>
> When I start the jar with java -jar MY_SHADED_JAR.jar I always get the
> following error:
>
> 22:09:57.365 [main] WARN  Sisu - Error injecting:
> org.apache.maven.project.DefaultProjectBuildingHelper
>
> com.google.inject.ProvisionException: Unable to provision, see the
> following errors:
>
>
> 1) No implementation for org.apache.maven.classrealm.ClassRealmManager
> was bound.
>
>   while locating org.apache.maven.project.DefaultProjectBuildingHelper
>
>
> Looking into components.xml DefaultClassRealmManager is not there but
> is referenced twice.
>
> Grepping through the components.xml files in a Maven installation, I
> do not see where the DefaultClassRealmManager is instantiated.
>
> Regards Mirko
> --
> http://illegalstateexception.blogspot.com/
> https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
> https://bitbucket.org/mfriedenhagen/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>