“IllegalStateException: 找不到 factory javax.faces.context.FacesContextFactory” in arquillian 中的备份

2022-09-02 22:37:14

java.lang.IllegalStateException:找不到工厂javax.faces.context.FacesContextFactory.的备份,这是由依赖项中存在JSF API引起的。我渴望在我的Java EE应用程序的WAR或EAR中提供依赖项,而不是使用服务器提供的依赖项工件,因为根据我的经验,这增加了必要更新(假设更新服务器工件)时的灵活性。这使得将Payara 4.1.2.181上的部署与Arquillian完成的嵌入式版本进行比较变得容易。我控制类加载与添加到 .<class-loader delegate="false"/>/WEB-INF/glassfish-web.xml

不幸的是,错误消息没有帮助,afaik必须通过Maven依赖项并以试错方法测试排除项。有一些“通常的嫌疑人”值得尝试,我从不同的帖子中收集:,,,。jsf-impl.jarjavax.faces.jarjsf-api.jarjavaee.jar

给定一个相当简单的JSF项目,其中有1个支持豆子,用于部署在Payara上,但不适用于Arquillian的功能测试"Hello world!"h:outputLabel

@RunWith(Arquillian.class)
@RunAsClient
public class FunctionalIT {
    private final static Logger LOGGER = LoggerFactory.getLogger(FunctionalIT.class);

    @Deployment(testable = false)
    public static Archive<?> createDeployment0() throws TransformerException, XPathExpressionException, ParserConfigurationException, SAXException, IOException {
        WebArchive retValue = Maven.configureResolver().workOffline().resolve("richtercloud:arquillian-assertt-statements-web:war:1.0-SNAPSHOT")
                .withoutTransitivity().asSingle(WebArchive.class);
        ByteArrayOutputStream archiveContentOutputStream = new ByteArrayOutputStream();
        retValue.writeTo(archiveContentOutputStream, Formatters.VERBOSE);
        LOGGER.info(archiveContentOutputStream.toString());
        return retValue;
    }

    @Drone
    private WebDriver browser;
    @ArquillianResource
    private URL deploymentUrl;
    @FindBy(id = "helloWorldLabel")
    private WebElement helloWorldLabel;

    @Test
    public void testAll() {
        browser.get(deploymentUrl.toExternalForm()+"/index.xhtml");
        LOGGER.info(browser.getPageSource());
        new WebDriverWait(browser, 10).until(ExpectedConditions.visibilityOf(helloWorldLabel));
    }
}

由于 Arquillian 部署失败,因此(功能测试是使用maven-failsafe-plugin)

java.lang.IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory. 
    at javax.faces.FactoryFinderInstance.getFactory(FactoryFinderInstance.java:541)
    at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:292)
    at javax.faces.webapp.FacesServlet.init(FacesServlet.java:374)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1435)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1243)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5468)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:5713)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:609)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:900)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:684)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2057)
    at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1703)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:294)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:357)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.initialize(ApplicationLifecycle.java:526)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:510)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:549)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:545)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:544)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:575)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:567)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:566)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1474)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:111)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1856)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1732)
    at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:134)
    at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:110)
    at org.jboss.arquillian.container.glassfish.embedded_3_1.GlassFishContainer.deploy(GlassFishContainer.java:193)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:151)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:118)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.executeOperation(ContainerDeployController.java:239)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deploy(ContainerDeployController.java:118)
    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: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.container.impl.client.container.DeploymentExceptionHandler.verifyExpectedExceptionDuringDeploy(DeploymentExceptionHandler.java:47)
    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:86)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
    at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createDeploymentContext(ContainerDeploymentContextHandler.java:71)
    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:86)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
    at org.jboss.arquillian.container.impl.client.ContainerDeploymentContextHandler.createContainerContext(ContainerDeploymentContextHandler.java:54)
    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:86)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
    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.EventImpl.fire(EventImpl.java:62)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$1.perform(ContainerDeployController.java:92)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$1.perform(ContainerDeployController.java:77)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.forEachDeployment(ContainerDeployController.java:232)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.forEachManagedDeployment(ContainerDeployController.java:212)
    at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deployManaged(ContainerDeployController.java:77)
    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: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.EventImpl.fire(EventImpl.java:62)
    at org.jboss.arquillian.container.test.impl.client.ContainerEventController.execute(ContainerEventController.java:96)
    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: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.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:83)
    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:86)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
    at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:69)
    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:86)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:95)
    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.test.impl.EventTestRunnerAdaptor.beforeClass(EventTestRunnerAdaptor.java:80)
    at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:179)
    at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:384)
    at org.jboss.arquillian.junit.Arquillian.access$200(Arquillian.java:54)
    at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:193)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:148)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:369)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:275)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:239)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:160)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:373)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:334)
    at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:119)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:407)

现在,我似乎无法应用上面链接中提供的解决方案,因为似乎没有依赖项匹配或与上面列出的解决方案相似:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] arquillian-assertt-statements
[INFO] arquillian-assertt-statements-web
[INFO] arquillian-assertt-statements-it
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building arquillian-assertt-statements 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ arquillian-assertt-statements ---
[INFO] richtercloud:arquillian-assertt-statements:pom:1.0-SNAPSHOT
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building arquillian-assertt-statements-web 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ arquillian-assertt-statements-web ---
[INFO] richtercloud:arquillian-assertt-statements-web:war:1.0-SNAPSHOT
[INFO] +- org.primefaces:primefaces:jar:6.1:compile
[INFO] \- javax:javaee-web-api:jar:7.0:provided
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building arquillian-assertt-statements-it 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ arquillian-assertt-statements-it ---
[INFO] richtercloud:arquillian-assertt-statements-it:jar:1.0-SNAPSHOT
[INFO] +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-api-javaee:jar:2.0.0:test
[INFO] |  \- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-api-base:jar:2.0.0:compile
[INFO] +- org.jboss.arquillian.junit:arquillian-junit-container:jar:1.2.0.Final:test
[INFO] |  +- org.jboss.arquillian.test:arquillian-test-api:jar:1.2.0.Final:compile
[INFO] |  |  \- org.jboss.arquillian.core:arquillian-core-api:jar:1.2.0.Final:compile
[INFO] |  +- org.jboss.arquillian.test:arquillian-test-spi:jar:1.2.0.Final:compile
[INFO] |  |  \- org.jboss.arquillian.core:arquillian-core-spi:jar:1.2.0.Final:compile
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-test-api:jar:1.2.0.Final:compile
[INFO] |  |  \- org.jboss.shrinkwrap:shrinkwrap-api:jar:1.2.6:compile
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-test-spi:jar:1.2.0.Final:compile
[INFO] |  +- org.jboss.arquillian.core:arquillian-core-impl-base:jar:1.2.0.Final:test
[INFO] |  +- org.jboss.arquillian.test:arquillian-test-impl-base:jar:1.2.0.Final:test
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-impl-base:jar:1.2.0.Final:test
[INFO] |  |  +- org.jboss.arquillian.config:arquillian-config-api:jar:1.2.0.Final:compile
[INFO] |  |  +- org.jboss.arquillian.config:arquillian-config-impl-base:jar:1.2.0.Final:compile
[INFO] |  |  \- org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-spi:jar:2.0.0:compile
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-test-impl-base:jar:1.2.0.Final:compile
[INFO] |  \- org.jboss.shrinkwrap:shrinkwrap-impl-base:jar:1.2.6:test
[INFO] |     \- org.jboss.shrinkwrap:shrinkwrap-spi:jar:1.2.6:test
[INFO] +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-depchain:pom:2.2.6:test
[INFO] |  +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api:jar:2.2.6:compile
[INFO] |  +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-spi:jar:2.2.6:test
[INFO] |  +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-spi-maven:jar:2.2.6:test
[INFO] |  +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api-maven-archive:jar:2.2.6:test
[INFO] |  +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven:jar:2.2.6:test
[INFO] |  |  +- org.eclipse.aether:aether-api:jar:1.0.0.v20140518:test
[INFO] |  |  +- org.eclipse.aether:aether-impl:jar:1.0.0.v20140518:test
[INFO] |  |  +- org.eclipse.aether:aether-spi:jar:1.0.0.v20140518:test
[INFO] |  |  +- org.eclipse.aether:aether-util:jar:1.0.0.v20140518:test
[INFO] |  |  +- org.eclipse.aether:aether-connector-basic:jar:1.0.0.v20140518:test
[INFO] |  |  +- org.eclipse.aether:aether-transport-wagon:jar:1.0.0.v20140518:test
[INFO] |  |  +- org.apache.maven:maven-aether-provider:jar:3.2.5:test
[INFO] |  |  +- org.apache.maven:maven-model:jar:3.2.5:test
[INFO] |  |  +- org.apache.maven:maven-model-builder:jar:3.2.5:test
[INFO] |  |  |  \- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:test
[INFO] |  |  +- org.apache.maven:maven-repository-metadata:jar:3.2.5:test
[INFO] |  |  +- org.apache.maven:maven-settings:jar:3.2.5:test
[INFO] |  |  +- org.apache.maven:maven-settings-builder:jar:3.2.5:test
[INFO] |  |  +- org.codehaus.plexus:plexus-interpolation:jar:1.21:test
[INFO] |  |  +- org.codehaus.plexus:plexus-utils:jar:3.0.20:test
[INFO] |  |  +- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:test
[INFO] |  |  |  \- org.sonatype.plexus:plexus-cipher:jar:1.4:test
[INFO] |  |  +- org.apache.maven.wagon:wagon-provider-api:jar:2.6:test
[INFO] |  |  +- org.apache.maven.wagon:wagon-file:jar:2.6:test
[INFO] |  |  |  \- commons-lang:commons-lang:jar:2.6:test
[INFO] |  |  \- org.apache.maven.wagon:wagon-http-lightweight:jar:2.6:test
[INFO] |  |     \- org.apache.maven.wagon:wagon-http-shared:jar:2.6:test
[INFO] |  \- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven-archive:jar:2.2.6:test
[INFO] |     +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-spi-maven-archive:jar:2.2.6:test
[INFO] |     +- org.eclipse.sisu:org.eclipse.sisu.plexus:jar:0.3.0.M1:test
[INFO] |     |  \- org.eclipse.sisu:org.eclipse.sisu.inject:jar:0.3.0.M1:test
[INFO] |     \- org.codehaus.plexus:plexus-compiler-javac:jar:2.3:test
[INFO] |        \- org.codehaus.plexus:plexus-compiler-api:jar:2.3:test
[INFO] +- org.jboss.arquillian.graphene:graphene-webdriver:pom:2.3.2:test
[INFO] |  +- org.jboss.arquillian.graphene:graphene-webdriver-api:jar:2.3.2:test
[INFO] |  +- org.jboss.arquillian.graphene:graphene-webdriver-spi:jar:2.3.2:test
[INFO] |  +- org.jboss.arquillian.graphene:graphene-webdriver-impl:jar:2.3.2:test
[INFO] |  |  +- org.jboss.arquillian.extension:arquillian-drone-impl:jar:2.5.0:test
[INFO] |  |  +- org.jboss.arquillian.extension:arquillian-drone-configuration:jar:2.5.0:test
[INFO] |  |  +- cglib:cglib-nodep:jar:3.2.5:compile
[INFO] |  |  \- org.objenesis:objenesis:jar:1.2:compile
[INFO] |  \- org.jboss.arquillian.extension:arquillian-drone-webdriver-depchain:pom:2.5.0:test
[INFO] |     +- org.jboss.arquillian.extension:arquillian-drone-spi:jar:2.5.0:test
[INFO] |     \- org.jboss.arquillian.extension:arquillian-drone-webdriver:jar:2.5.0:test
[INFO] |        +- org.arquillian.spacelift:arquillian-spacelift:jar:1.0.2:test
[INFO] |        |  \- org.arquillian.spacelift:arquillian-spacelift-api:jar:1.0.2:test
[INFO] |        +- org.jsoup:jsoup:jar:1.8.3:test
[INFO] |        \- org.awaitility:awaitility:jar:3.0.0:test
[INFO] |           \- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] +- com.codeborne:phantomjsdriver:jar:1.4.1:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-api:jar:3.9.1:compile
[INFO] |  \- org.seleniumhq.selenium:selenium-remote-driver:jar:3.9.1:compile
[INFO] +- org.seleniumhq.selenium:htmlunit-driver:jar:2.28:compile
[INFO] |  \- org.seleniumhq.selenium:selenium-support:jar:3.9.1:compile
[INFO] +- net.sourceforge.htmlunit:htmlunit:jar:2.24:compile
[INFO] |  +- xalan:xalan:jar:2.7.2:compile
[INFO] |  |  \- xalan:serializer:jar:2.7.2:compile
[INFO] |  +- org.apache.commons:commons-lang3:jar:3.5:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] |  +- org.apache.httpcomponents:httpmime:jar:4.5.2:compile
[INFO] |  +- commons-codec:commons-codec:jar:1.10:compile
[INFO] |  +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.23:compile
[INFO] |  +- net.sourceforge.htmlunit:neko-htmlunit:jar:2.24:compile
[INFO] |  |  \- xerces:xercesImpl:jar:2.11.0:compile
[INFO] |  |     \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] |  +- net.sourceforge.cssparser:cssparser:jar:0.9.21:compile
[INFO] |  |  \- org.w3c.css:sac:jar:1.3:compile
[INFO] |  +- commons-io:commons-io:jar:2.5:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  \- org.eclipse.jetty.websocket:websocket-client:jar:9.2.20.v20161216:compile
[INFO] |     +- org.eclipse.jetty:jetty-util:jar:9.2.20.v20161216:compile
[INFO] |     +- org.eclipse.jetty:jetty-io:jar:9.2.20.v20161216:compile
[INFO] |     \- org.eclipse.jetty.websocket:websocket-common:jar:9.2.20.v20161216:compile
[INFO] |        \- org.eclipse.jetty.websocket:websocket-api:jar:9.2.20.v20161216:compile
[INFO] +- org.seleniumhq.selenium:selenium-java:jar:3.9.1:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-chrome-driver:jar:3.9.1:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-edge-driver:jar:3.9.1:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-ie-driver:jar:3.9.1:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-opera-driver:jar:3.9.1:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-safari-driver:jar:3.9.1:compile
[INFO] |  +- net.bytebuddy:byte-buddy:jar:1.7.9:compile
[INFO] |  +- org.apache.commons:commons-exec:jar:1.3:compile
[INFO] |  +- com.google.code.gson:gson:jar:2.8.2:compile
[INFO] |  +- com.google.guava:guava:jar:23.6-jre:compile
[INFO] |  |  +- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] |  |  +- org.checkerframework:checker-compat-qual:jar:2.0.0:compile
[INFO] |  |  +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile
[INFO] |  |  +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO] |  |  \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.4.6:compile
[INFO] |  +- com.squareup.okhttp3:okhttp:jar:3.9.1:compile
[INFO] |  \- com.squareup.okio:okio:jar:1.13.0:compile
[INFO] +- org.seleniumhq.selenium:selenium-firefox-driver:jar:3.9.1:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.9.2:compile
[INFO] +- richtercloud:selenium-tools:jar:1.0-SNAPSHOT:compile
[INFO] |  +- junit:junit:jar:4.12:compile
[INFO] |  |  \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] |  +- org.apache.commons:commons-compress:jar:1.11:compile
[INFO] |  +- ru.yandex.qatools.ashot:ashot:jar:1.5.3:compile
[INFO] |  |  \- com.googlecode.lambdaj:lambdaj:jar:2.3.3:compile
[INFO] |  |     \- org.hamcrest:hamcrest-all:jar:1.1:compile
[INFO] |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.0.3:compile
[INFO] |     +- org.apiguardian:apiguardian-api:jar:1.0.0:compile
[INFO] |     +- org.junit.platform:junit-platform-engine:jar:1.0.3:compile
[INFO] |     |  +- org.junit.platform:junit-platform-commons:jar:1.0.3:compile
[INFO] |     |  \- org.opentest4j:opentest4j:jar:1.0.0:compile
[INFO] |     \- org.junit.jupiter:junit-jupiter-api:jar:5.0.3:compile
[INFO] +- org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api-maven:jar:2.2.6:compile
[INFO] +- org.jboss.arquillian.extension:arquillian-drone-api:jar:2.5.0:compile
[INFO] +- org.jboss.arquillian.junit:arquillian-junit-core:jar:1.2.0.Final:compile
[INFO] +- org.jboss.arquillian.container:arquillian-glassfish-embedded-3.1:jar:1.0.2:compile
[INFO] |  +- org.jboss.arquillian.container:arquillian-container-spi:jar:1.2.0.Final:compile
[INFO] |  +- org.jboss.arquillian.protocol:arquillian-protocol-servlet:jar:1.2.0.Final:compile
[INFO] |  +- org.jboss.arquillian.testenricher:arquillian-testenricher-cdi:jar:1.2.0.Final:compile
[INFO] |  +- org.jboss.arquillian.testenricher:arquillian-testenricher-ejb:jar:1.2.0.Final:compile
[INFO] |  +- org.jboss.arquillian.testenricher:arquillian-testenricher-resource:jar:1.2.0.Final:compile
[INFO] |  \- org.jboss.arquillian.testenricher:arquillian-testenricher-initialcontext:jar:1.2.0.Final:compile
[INFO] \- fish.payara.extras:payara-embedded-all:jar:5.0.0.Alpha3:test
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] arquillian-assertt-statements ...................... SUCCESS [  0.864 s]
[INFO] arquillian-assertt-statements-web .................. SUCCESS [  0.060 s]
[INFO] arquillian-assertt-statements-it ................... SUCCESS [  0.904 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.254 s
[INFO] Finished at: 2018-03-05T11:24:55+01:00
[INFO] Final Memory: 17M/303M
[INFO] ------------------------------------------------------------------------

使用 2.21.0 运行测试时,也会发生相同的错误。嵌入式Payara 5.182和4.1.2.181也存在此问题,它们是5.x和4.x分支中的最新分支。maven-surefire-plugin

SSCCE不包含比上述MCVE更多的信息,但有助于克隆中的实验,可以在 https://gitlab.com/krichter/arquillian-assertt-statementshttps://gitlab.com/krichter/arquillian-assertt-statements/-/jobs/75705830 完整运行的示例输出中找到。


答案 1

这似乎可以通过添加

<listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>

添加到 的部分。由于您可能不想污染生产,因此可以使用以下内容以编程方式插入(例如在Arquillian方法中):web-appweb.xmlweb.xmllistener@Deployment

@Deployment(testable = false)
public static Archive<?> createDeployment0() throws ParserConfigurationException,
        SAXException,
        IOException,
        XPathExpressionException,
        TransformerConfigurationException,
        TransformerException {
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
        //namespace awareness is necessary in order to avoid an empty
        //`xmlns` attribute to be added to the persistence-unit element in
        //the output which causes failure of the functional test due to
        //`java.io.IOException: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 108; Deployment descriptor file META-INF/persistence.xml in archive [project1-jar-1.0-SNAPSHOT.jar].  cvc-complex-type.2.4.a: Invalid content was found starting with element 'persistence-unit'. One of '{"http://xmlns.jcp.org/xml/ns/persistence":persistence-unit}' is expected.`
        //see
        //https://stackoverflow.com/questions/48362284/how-to-avoid-xmlns-to-be-added-to-a-manipulated-xml-root-element
        //for details and an explanation
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document webXmlDocument = documentBuilder.parse(new File("src/main/webapp/WEB-INF/web.xml"));
    XPathFactory xPathfactory = XPathFactory.newInstance();
    XPath xPath = xPathfactory.newXPath();

    XPathExpression expr = xPath.compile("//*[local-name()='web-app']");
    Node webAppNode = (Node) expr.evaluate(webXmlDocument,
            XPathConstants.NODE);
    Element listenerNode = webXmlDocument.createElementNS(webAppNode.getNamespaceURI(),
            "listener");
        //use `createElementNS` instead of `createElement` in order to avoid
        //empty `xmlns` attribute on the created `listener` element which
        //is otherwise added even if the document builder is namespace aware
    Element listenerClassNode = webXmlDocument.createElementNS(webAppNode.getNamespaceURI(),
            "listener-class");
    listenerClassNode.setTextContent("com.sun.faces.config.ConfigureListener");
    listenerNode.appendChild(listenerClassNode);
    webAppNode.appendChild(listenerNode);

    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer transformer = tf.newTransformer();
    StringWriter writer = new StringWriter();
    transformer.transform(new DOMSource(webXmlDocument), new StreamResult(writer));
    String webXml = writer.toString();
    StringAsset webXmlAsset = new StringAsset(webXml);
    WebArchive archive = ShrinkWrap.create(WebArchive.class)
            .setWebXML(webXmlAsset)
            ...;
    return archive;
}

使用和解析 with 来检索 if 在单独的项目中对功能测试使用完整 WAR 存档,如上例所示。org.jboss.shrinkwrap.api.Node webXml = mavenArtifact.get("/WEB-INF/web.xml")webXml.getAsset().openStream()DocumentBuilderweb.xml

我在Payara错误报告1105中找到了解决方案,其中我链接了此处提供的信息,希望能够触发Payara开发人员的进一步调查和修复。

我在 SSCCE 的分支上添加了修复程序。fix


答案 2

推荐