Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Open
mnovak1 opened this issue Dec 11, 2019 · 3 comments
Assignees

Comments

@mnovak1
Copy link
Member

mnovak1 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.

WORKAROUND USING ServerSetupTask - avoid deploying Creaper in deployment:
https://github.com/mnovak1/eap-microprofile-test-suite/blob/EAP7-1347/microprofile-fault-tolerance/src/test/java/org/jboss/eap/qe/microprofile/fault/tolerance/MultipleJarDeploymentTest.java#L32
https://github.com/mnovak1/eap-microprofile-test-suite/blob/EAP7-1347/microprofile-fault-tolerance/src/test/java/org/jboss/eap/qe/microprofile/fault/tolerance/FaultToleranceServerSetup.java

@mnovak1
Copy link
Member Author

mnovak1 commented Dec 11, 2019

Create Creaper issue: wildfly-extras/creaper#183

@mnovak1
Copy link
Member Author

mnovak1 commented Dec 11, 2019

@jboss-eap-qe/mp-team I've provided link to tests with workaround in descriptions above.

@mnovak1 mnovak1 mentioned this issue Dec 12, 2019
6 tasks
@mnovak1 mnovak1 self-assigned this Jan 22, 2020
@mnovak1
Copy link
Member Author

mnovak1 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant