vert-x3 / issues

Apache License 2.0
37 stars 7 forks source link

cannot I use maven invoke vertx? #461

Closed hu-chia closed 5 years ago

hu-chia commented 5 years ago

We use maven and testng build and invoke our unittest, therefore I try report my unittest result to a http server using vertx.createHttpClient(). this is the error message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project Project: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test failed: There was an error in the forked process
[ERROR] java.util.ServiceConfigurationError: io.vertx.core.spi.VertxFactory: io.vertx.core.impl.VertxFactoryImpl not a subtype
[ERROR]         at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:590)
[ERROR]         at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1237)
[ERROR]         at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1265)
[ERROR]         at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1300)
[ERROR]         at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1385)
[ERROR]         at io.vertx.core.ServiceHelper.loadFactories(ServiceHelper.java:60)
[ERROR]         at io.vertx.core.ServiceHelper.loadFactories(ServiceHelper.java:47)
[ERROR]         at io.vertx.core.ServiceHelper.loadFactoryOrNull(ServiceHelper.java:37)
[ERROR]         at io.vertx.core.ServiceHelper.loadFactory(ServiceHelper.java:29)
[ERROR]         at io.vertx.core.Vertx.<clinit>(Vertx.java:578)
[ERROR]         at common.report.SwaggerReporter.post(SwaggerReporter.java:40)
[ERROR]         at common.report.SwaggerReporter.generateReport(SwaggerReporter.java:36)
[ERROR]         at org.testng.TestNG.generateReports(TestNG.java:1097)
[ERROR]         at org.testng.TestNG.run(TestNG.java:1022)
[ERROR]         at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:293)
[ERROR]         at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
[ERROR]         at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:91)
[ERROR]         at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
[ERROR]         at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
[ERROR]         at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
tsegismont commented 5 years ago

Can you share a small reproducer (class, test class and how to run)? Thanks

hu-chia commented 5 years ago

this is my testng listener, it was invoked by mvn test command, I omitted some of not important code. actually, there also is error occurs to Google Guava. I don't know is testng or maven runtime environment result in error.

public class SwaggerReporter implements IReporter {

    @Override
    public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
        // collect test result

        post(params);
    }

    private static void post(String params) {
        HttpClient httpClient = Vertx.vertx().createHttpClient();
        HttpClientRequest post = httpClient.post(url, response -> {
            // do something
        });
        post.write(params);
        post.end();
    }
}
tsegismont commented 5 years ago

Can you please share a full reproducer (even simplified) ? As it's most likely a classpath issue, the snippet above won't help.

hu-chia commented 5 years ago

I upgraded my maven plugins and vertx, at the newest version of them, webclient can work correctly. thanks for your concerning, please close this issue.