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

Exception (guava) when adding suite-extension on Wildfly 10 #45

Open
awilhelmer opened this issue Jan 16, 2018 · 10 comments
Open

Exception (guava) when adding suite-extension on Wildfly 10 #45

awilhelmer opened this issue Jan 16, 2018 · 10 comments

Comments

@awilhelmer
Copy link

Hello,

i've got problems to get this extension to work. I have an EAR package based on this example https://github.com/wildfly/quickstart/tree/10.x/kitchensink-ear . I already have working test cases, but when I only add your dependency

<dependency>
            <groupId>org.eu.ingwar.tools</groupId>
            <artifactId>arquillian-suite-extension</artifactId>
            <version>1.1.4</version>
            <scope>test</scope>
        </dependency>

i get this exception when running a test:

java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor

	at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:165)
	at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:102)
	at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:52)
	at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:113)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:161)
	... 8 more
Caused by: java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.core.impl.ManagerImpl
	at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:165)
	at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:102)
	at org.jboss.arquillian.core.spi.ManagerBuilder.create(ManagerBuilder.java:77)
	at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:62)
	... 13 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.jboss.arquillian.core.spi.SecurityActions.newInstance(SecurityActions.java:161)
	... 16 more
Caused by: java.lang.NoSuchMethodError: com.google.common.collect.Sets$SetView.iterator()Lcom/google/common/collect/UnmodifiableIterator;
	at org.reflections.Reflections.expandSuperTypes(Reflections.java:380)
	at org.reflections.Reflections.<init>(Reflections.java:126)
	at org.reflections.Reflections.<init>(Reflections.java:168)
	at org.eu.ingwar.tools.arquillian.extension.suite.ArquillianSuiteExtension.getDeploymentClass(ArquillianSuiteExtension.java:82)
	at org.eu.ingwar.tools.arquillian.extension.suite.ArquillianSuiteExtension.register(ArquillianSuiteExtension.java:65)
	at org.jboss.arquillian.core.impl.loadable.LoadableExtensionLoader.load(LoadableExtensionLoader.java:79)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
	at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
	at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
	at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
	at org.jboss.arquillian.core.impl.ManagerImpl.fireProcessing(ManagerImpl.java:346)
	at org.jboss.arquillian.core.impl.ManagerImpl.<init>(ManagerImpl.java:100)
	... 21 more


@hoeppy
Copy link

hoeppy commented Jan 18, 2018

Hello awilhelmer,
The extension expected a class annotated with @ArquillianSuiteDeployment.
In this class should be a method annotated with @deployment
And SuiteExtension expeced only one such class in class path.

I hope that will help. Please Read doku first:
https://github.com/ingwarsw/arquillian-suite-extension

best regards Robert

@awilhelmer
Copy link
Author

awilhelmer commented Jan 18, 2018

Hello hoeppy,

it doesn't change anything. I already read the doku:

Add arquillian-suite as dependency
Check if its working (should work slow as before)

I've got a basic deployment class with only one EAR deployment, file based from local maven repo, the Test class is extending from it. Adding the annotation on the Deployment class doesn't change anything, the exception still appears. Without the dependency everything works as expected.

@famod
Copy link

famod commented Jan 18, 2018

I ran into the same problem with JBoss EAP 6.4 (an early commercial version of Wildfly).
The problem is that you typically import one or more BOM (bill of material) dependencies in your Maven pom.xml to bring in all the relevant libraries that JBoss EAP/ Wildfly provides so that you can compile your code with that classpath.
These BOMs bring in an older version of guava (com.google.common.*) which does not (yet) have the SetView.iterator() method that is required by org.reflections.Reflections.

So this is an incompatibility problem.
I ended up implementing my own extension which does not rely on classpath scanning and which also provides more flexibility. An early version can be found in issue #44.

@awilhelmer
Copy link
Author

Hello @famod ,

this seems to be working but now i've got problems to run all test classes. I have this construct:

public class Deployments {

   @Deployment()
   public static Archive createDeployment() {
      return Deployments.getApplicationEar();

   }
   public static EnterpriseArchive getApplicationEar() {
      System.out.println("DEPLOYMENT TRIGGERED!");

      File file = new File(System.getProperty("user.home")
                       + "\\.m2\\repository\\de\\conuti\\traceboard\\traceboard-backend\\traceboard-app\\traceboard-ear\\1.0.0-SNAPSHOT\\traceboard-ear-1.0.0-SNAPSHOT.ear");

      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "application-ear.ear")
            .as(ZipImporter.class)
            .importFrom(file)
            .as(EnterpriseArchive.class);
      //now add the testClass and any test util classes that are not in the archive
      JavaArchive testLibraryHelper = ShrinkWrap
            .create(JavaArchive.class)
//            .addClass(Deployments.class)
            .addClass(EjbTest.class)
            .addClass(EjbTest2.class)
            //now for CDI working in testLibraryHelper
            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

      ear.addAsLibrary(testLibraryHelper);

      return ear;
   }
}
@RunWith(Arquillian.class)
@ReuseDeployment(Deployments.class)
public class EjbTest extends Deployments {
 @Test
   public void test() {
}
}
@RunWith(Arquillian.class)
@ReuseDeployment(Deployments.class)
public class EjbTest2 extends Deployments {
  @Test
   public void test2() {
  }
}

when i run mvn test -Parq-wildfly-remote only EjbTest class is executed. The EjbTest2 is ignored. What is wrong? :(

@famod
Copy link

famod commented Jan 21, 2018

@awilhelmer I never tested my implementation with the remote container adapter, only the "managed" one.
But basically it should work with the remote one as well.
I'll try and have a look later next week.

@awilhelmer
Copy link
Author

awilhelmer commented Feb 4, 2018

@famod Thanks for your info.
After some tests i'am able to run both tests. My problem was, dthat surefire or Junit scans only for files with the pattern *Test.java, Test*.java class files.

But it seems that your simple extension doesn't work for remote tests:

Feb 04, 2018 6:21:46 PM de.conuti.traceboard.service.basic.suite.ReuseDeploymentExtension$ReuseDeploymentHandler generateDeployment
INFO: Generating reusable deployment for de.conuti.traceboard.service.test.EjbOneTest: class de.conuti.traceboard.service.basic.Deployments
DEPLOYMENT TRIGGERED!
Feb 04, 2018 6:21:46 PM de.conuti.traceboard.service.basic.suite.ReuseDeploymentExtension$ReuseDeploymentHandler generateDeployment
INFO: Generating reusable deployment for de.conuti.traceboard.service.test.EjbTwoTest: class de.conuti.traceboard.service.basic.Deployments
DEPLOYMENT TRIGGERED!
Feb 04, 2018 6:21:46 PM org.xnio.Xnio <clinit>

It seems that surefire runs a VM for each test? I tried to make the attributes activeReusableDeploymentClass and generatedReusableDeploymentScenarios static but with the same result.

@famod
Copy link

famod commented Feb 4, 2018

@awilhelmer First off: Sorry, didn't have the time to look at the problem.

It seems that surefire runs a VM for each test?

Well, with default settings Surefire should not run each test in a separate JVM. See: http://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html

Can you add -Darquillian.debug=true (see http://lukas.fryc.eu/blog/2013/06/debugging-arquillian.html) and post the output here?

@awilhelmer
Copy link
Author

@famod Thanks four your help.
Here the output:
https://gist.github.com/awilhelmer/56ad3ec8a0d73aebb5560dc79cc8d07c

DEPLOYMENT TRIGGERED!
DEPLOYMENT TRIGGERED!

This is the output from the deployment method getApplicationEar(), so its called twice...

I rerun the test with System outs on your loggings (windows doesnt pipe evertyhing in git bash ...)

(E) BeforeClass
        (I) TestContextHandler.createSuiteContext
        (I) TestContextHandler.createClassContext
        (E) TestClass
        (O) ContainerEventController.execute
        (E) StartClassContainers
                (O) ContainerLifecycleController.startClassContainers
        (E) GenerateDeployment
                (I) ReuseDeploymentHandler.generateDeployment
Generating reusable deployment for de.conuti.traceboard.service.test.EjbOneTest: class de.conuti.traceboard.service.basic.Deployments
                (E) GenerateReusableDeployment
                        (I) ReuseDeploymentHandler.generateDeployment
                        (O) DeploymentGenerator.generateDeployment
DEPLOYMENT TRIGGERED!
Generating reusable deployment for de.conuti.traceboard.service.test.EjbTwoTest: class de.conuti.traceboard.service.basic.Deployments
                (E) GenerateReusableDeployment
                        (I) ReuseDeploymentHandler.generateDeployment
                        (O) DeploymentGenerator.generateDeployment
DEPLOYMENT TRIGGERED!

@famod
Copy link

famod commented Feb 26, 2018

@awilhelmer
Hm, it really seems your Surefire is configured to run multiple tests concurrently, judging by the following output from your gist:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
(E) ManagerProcessing
(E) ManagerProcessing
	(O) LoadableExtensionLoader.load
	(O) LoadableExtensionLoader.load
	(E) ServiceRegistryLoader
	(E) ServiceRegistryLoader
(E) ManagerStarted
	(O) ConfigurationRegistrar.loadConfiguration
(E) ManagerStarted
	(O) ConfigurationRegistrar.loadConfiguration

Can you post an output with mvn -X ...?

Which version of Arquillian are you using?

@nosaku
Copy link

nosaku commented Apr 26, 2019

I am also getting the Guava error. Any ideas on how to resolve this? I am using the embedded Glassfish container.

java.lang.RuntimeException: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:146) at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:89) at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:49) at org.jboss.arquillian.junit.AdaptorManager.initializeAdaptor(AdaptorManager.java:21) at org.jboss.arquillian.junit.AdaptorManagerWithNotifier.initializeAdaptor(AdaptorManagerWithNotifier.java:19) at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:109) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) Caused by: java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:88) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57) at java.lang.reflect.Constructor.newInstance(Constructor.java:436) at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:144) at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:89) at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:49) at org.jboss.arquillian.junit.AdaptorManager.initializeAdaptor(AdaptorManager.java:21) at org.jboss.arquillian.junit.AdaptorManagerWithNotifier.initializeAdaptor(AdaptorManagerWithNotifier.java:19) at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:109) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) Caused by: java.lang.NoSuchMethodError: com/google/common/collect/Sets$SetView.iterator()Lcom/google/common/collect/UnmodifiableIterator; at org.reflections.Reflections.expandSuperTypes(Reflections.java:380) at org.reflections.Reflections.<init>(Reflections.java:126) at org.reflections.Reflections.<init>(Reflections.java:168) at org.eu.ingwar.tools.arquillian.extension.suite.DeploymentClassFinder.getDeploymentClassFromAnnotation(DeploymentClassFinder.java:62) at org.eu.ingwar.tools.arquillian.extension.suite.DeploymentClassFinder.getDeploymentClass(DeploymentClassFinder.java:46) at org.eu.ingwar.tools.arquillian.extension.suite.SuiteDeployer.configure(SuiteDeployer.java:80) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) at java.lang.reflect.Method.invoke(Method.java:507) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:90) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:133) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:105) at org.jboss.arquillian.core.impl.ManagerImpl.bindAndFire(ManagerImpl.java:232) at org.jboss.arquillian.core.impl.InstanceImpl.set(InstanceImpl.java:67) at org.jboss.arquillian.config.impl.extension.ConfigurationRegistrar.loadConfiguration(ConfigurationRegistrar.java:72) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) at java.lang.reflect.Method.invoke(Method.java:507) at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:86) at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:103) at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:90) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:133) at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:105) at org.jboss.arquillian.core.impl.ManagerImpl.start(ManagerImpl.java:253) at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.<init>(EventTestRunnerAdaptor.java:61) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:88) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57) at java.lang.reflect.Constructor.newInstance(Constructor.java:436) at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:144) at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:89) at org.jboss.arquillian.test.spi.TestRunnerAdaptorBuilder.build(TestRunnerAdaptorBuilder.java:49) at org.jboss.arquillian.junit.AdaptorManager.initializeAdaptor(AdaptorManager.java:21) at org.jboss.arquillian.junit.AdaptorManagerWithNotifier.initializeAdaptor(AdaptorManagerWithNotifier.java:19) at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:109) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

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

No branches or pull requests

4 participants