Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Arquillian in-container JAR deployment with Creaper does not load all classes #183

Open
mnovak opened this issue Dec 11, 2019 · 3 comments

Comments

@mnovak
Copy link
Collaborator

mnovak commented Dec 11, 2019

There is issue creating Arquillian in-container JAR/WAR deployment with Creaper. Creaper requires its dependencies wildfly-cli and wildfly-controller-client to be present which is possible to do with WAR like:

    public static Archive<?> createWarDeployment() {
        // this config will not apply as timeout property was already set by first deployment on hystrix and won't be override
        String mpConfig = "hystrix.command.default.execution.timeout.enabled=true";

        JavaArchive[] libs = Maven.resolver().loadPomFromFile("pom.xml").resolve(
                "org.wildfly.core:wildfly-controller-client:10.0.3.Final",
                "org.wildfly.core:wildfly-cli:10.0.3.Final",
                "org.wildfly.extras.creaper:creaper-core:1.6.1").withoutTransitivity().as(JavaArchive.class);
        WebArchive jarArchive = ShrinkWrap.create(WebArchive.class, SECOND_DEPLOYMENT_JAR + ".war")
                .addClasses(HelloService.class, MyContext.class, HelloFallback.class, FallbackHandler.class)
                .addClasses(MultipleJarDeploymentTest.class, MicroProfileFaultToleranceTestParent.class, LogChecker.class)
                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
                .addAsLibraries(libs)
                .addAsManifestResource(new StringAsset(mpConfig), "microprofile-config.properties");

        return jarArchive;
    }

however in JAR the only way how to add other jars is adding library classes directly into JAR archive:

    public static Archive<?> createSecondJarDeployment() {
        String mpConfig = "hystrix.command.default.execution.timeout.enabled=true";

        JavaArchive[] libs = Maven.resolver().loadPomFromFile("pom.xml").resolve(
                "org.wildfly.core:wildfly-controller-client:10.0.3.Final",
                "org.wildfly.core:wildfly-cli:10.0.3.Final",
                "org.wildfly.extras.creaper:creaper-core:1.6.1").withoutTransitivity().as(JavaArchive.class);
        JavaArchive jarArchive = ShrinkWrap.create(JavaArchive.class, SECOND_DEPLOYMENT_JAR + ".jar")
                .addClasses(HelloService.class, MyContext.class, HelloFallback.class, FallbackHandler.class)
                .addClasses(MultipleJarDeploymentTest.class, MicroProfileFaultToleranceTestParent.class, LogChecker.class)
                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
                .addAsManifestResource(new StringAsset(mpConfig), "microprofile-config.properties");
        Stream.of(libs).forEach(jarArchive::merge);
        return jarArchive;
    }

however it results in 100s of java.lang.NoClassDefFoundError exceptions using JavaArchive:merge():

08:20:46,607 WARN  [org.jboss.modules.define] (Weld Thread Pool -- 7) Failed to define class org.jboss.as.cli.impl.aesh.cmd.ConnectedActivator in Module "deployment.test.war" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/jboss/as/cli/impl/aesh/cmd/ConnectedActivator (Module "deployment.test.war" from Service Module Loader): Failed to link org/wildfly/core/cli/command/aesh/activator/AbstractCommandActivator (Module "deployment.test.war" from Service Module Loader): Failed to link org/wildfly/core/cli/command/aesh/activator/CLICommandActivator (Module "deployment.test.war" from Service Module Loader): org/aesh/command/activator/CommandActivator
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:839)
	at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:424)
	at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:555)
	at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:339)
	at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:126)
	at org.jboss.modules.Module.loadModuleClass(Module.java:731)
	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:247)

I did not find a way to workaround this issue with using Dependencies: ... in META-INF/MANIFEST.MF.

@simkam
Copy link
Collaborator

simkam commented Dec 11, 2019

this doesn't look like Creaper issue.

@Ladicek
Copy link
Contributor

Ladicek commented Dec 11, 2019

Specifying dependencies in the manifest or in jboss-deployment-structure.xml sounds like the right way to do this. The correct dependency names are org.jboss.as.controller-client and org.jboss.as.cli.

@mnovak
Copy link
Collaborator Author

mnovak commented Jan 22, 2020

Looks like the whole issue is caused by enabling Weld by adding beans.xml when I remove it then it's ok.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants