Arquillian ShrinkWrap

I am having trouble building a JUnit test using pom.xml dependency.

The test is done with Arquillian

@RunWith (Arquillian.class)

In this method

public static JavaArchive createDeployment() {


I first create a JavaArchive with a project package that I am testing

   JavaArchive merge =  ShrinkWrap.create(JavaArchive.class).
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");


Then when I run the test there are some missing dependencies

Unable to resolve any beans for Types: [class it.**.**.be.service.EnvironmentRootService]


is present in this addiction



I tried many different things to add these dependencies, the best one seems to be using ShrinkWrap Resolvers ( , particullarry this paragraph shrinkwrap / resolver / blob / master / README.asciidoc # resolution-of-artifacts-defined-in-pom-files )


JavaArchive [] archives = Maven.resolver (). loadPomFromFile (path_to_pom_file). importDependencies (ScopeType.TEST, ScopeType.COMPILE). ... Resolve () withTransitivity () like (JavaArchive.class) ;.


Maven.resolver (). LoadPomFromFile ("/path/to/pom.xml"). ImportRuntimeDependencies () ..resolve () withTransitivity () asFile () ;.

Dependency is ignored anyway (am I missing something?)


JavaArchive [] mistral_be = Maven.configureResolver (). workOffline (). allow ("this is ** Mistral: Mistral-be: .. 0.1.0") .. withTransitivity () like (JavaArchive.class);
    for (int i = 0; i <mistral_be.length; i ++) {
        merge = merge.merge (mistral_be [i]);

With a simple



I can see all files from dependencies are present! Anyway I'm using the local repository workoffline () Maybe I'm missing some dependencies?

But exiting the method with

return merge;


throws a "java.lang.NoClassDefFoundError: com / google / protobuf / GeneratedMessage .... Caused by: java.lang.ClassNotFoundException:".

Then again I tried to add the missing dependencies

// Tryn'g to add protobuf dependencies JavaArchive [] prto_buf = Maven.configureResolver (). WithMavenCentralRepo (true) .resolve (" protobuf-java: 2.3.0"). WithTransitivity (). As (JavaArchive.class);

       for (int i = 0; i < prto_buf.length ; i++) {
           projectPackages = projectPackages.merge(prto_buf[i]);


Throws sameException ... Again, with a simple



I can see com.Google.protobuf.GeneratedMessage is present

Extracting dependencies:








Can anyone help me to solve this problem?


source to share

1 answer

It smells to me like a boot problem. Especially considering the fact that you are using an inline container that basically accepts whatever is in your project classpath.

What is the target container that you are deploying the application to? Perhaps if you try to run your test instead of the built-in container, you will at least see if this is really the problem or if there is something wrong with your deployment artifact.



All Articles