"IllegalStateException: не удалось найти резервную копию для фабрики javax.faces.context.FacesContextFactory" в arquillian
java.lang.IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory.
вызвано наличием JSF API внутри зависимостей. Я желаю предоставить зависимости в WAR или EAR для приложений Java EE вместо использования артефактов зависимостей, предоставляемых сервером, потому что это увеличивает гибкость, когда речь заходит о необходимых обновлениях (при условии обновления артефактов сервера) в моем опыте. Это упрощает сравнение развертывания в Payara 4.1.2.181 с одним во встроенную версию, выполненную Arquillian. Я управляю загрузкой классов с помощью <class-loader delegate="false"/>
добавленного в /WEB-INF/glassfish-web.xml
.
К сожалению, сообщение об ошибке не полезно, и afaik нужно пройти через зависимости Maven и проверить исключения в методе пробной ошибки. Есть некоторые "обычные подозреваемые", которые стоит попробовать, которые я собрал из разных сообщений: jsf-impl.jar
, javax.faces.jar
, jsf-api.jar
, javaee.jar
.
Учитывая довольно простой проект JSF с 1 бэк-бэндом, производящим "Hello world!"
для h:outputLabel
развертывание работает на Payara, но не с Arquillian с функциональным тестом
@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] ------------------------------------------------------------------------
Такая же ошибка возникает, когда тест выполняется с помощью maven-surefire-plugin
2.21.0. Проблема также возникает со встроенными Payara 5.182 и 4.1.2.181, которые являются последними из ветвей 5.x и 4.x.
SSCCE, который не содержит больше информации, чем MCVE выше, но облегчает эксперименты в клоне, можно найти на https://gitlab.com/krichter/arquillian-assertt-statements и примере вывода полного запуска на https://gitlab.com/krichter/arquillian-assertt-statements / -/jobs/75705830.
Ответы
Ответ 1
Кажется, это исправлено добавлением
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
в раздел web-app
web.xml
. Так как вы можете не захотеть загрязнять ваш web.xml
вы можете использовать следующее для вставки listener
программно (например, в метод @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/info/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;
}
Используйте org.jboss.shrinkwrap.api.Node webXml = mavenArtifact.get("/WEB-INF/web.xml")
и проанализируйте webXml.getAsset().openStream()
с DocumentBuilder
чтобы получить web.xml
если вы используете полный архив WAR в отдельном проекте для функциональных тестов, как в приведенном выше примере.
Я нашел решение в отчете 1105 об ошибке Payara, в котором я связал предоставленную здесь информацию, которая, надеюсь, приведет к дальнейшему расследованию и исправлению разработчиками Payara.
Я добавил исправление на ветку fix
SSCCE.