当我尝试使用PostgreSQL使用Arquilian.class运行一个简单的测试时,我遇到了这个问题(我可以用H2做)
JBAS014775: New missing/unsatisfied dependencies:
service jboss.data-source.reference-factory.java:jboss/datasources/mavenjeeTestDS (missing) dependents: [service jboss.naming.context.java.jboss.datasources.mavenjeeTestDS]
service jboss.deployment.unit."test.war".WeldBootstrapService (missing) dependents: [service jboss.deployment.unit."test.war".component."javax.faces.webapp.FacetTag".WeldInstantiator]
service jboss.deployment.unit."test.war".WeldStartService (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./test.UndertowDeploymentInfoService, service jboss.deployment.unit."test.war".component.CuentasDAO.WeldInstantiator, service jboss.deployment.unit."test.war".component."org.jboss.weld.servlet.WeldTerminalListener".WeldInstantiator, service jboss.deployment.unit."test.war".CdiValidatorFactoryService, JBAS014799: ... and 9 more ]
service jboss.deployment.unit."test.war".beanmanager (missing) dependents: [service jboss.persistenceunit."test.war#primary"]
service jboss.deployment.unit."test.war".component.CuentasDAO.CREATE (missing) dependents: [service jboss.deployment.unit."test.war".component.CuentasDAO.START]
service jboss.deployment.unit."test.war".component.CuentasDAO.START (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./test.UndertowDeploymentInfoService, service jboss.deployment.unit."test.war".moduleDeploymentRuntimeInformationStart, service jboss.undertow.deployment.default-server.default-host./test, service jboss.deployment.unit."test.war".deploymentCompleteService]
service jboss.deployment.unit."test.war".component.CuentasDAO.WeldInstantiator (missing) dependents: [service jboss.deployment.unit."test.war".component.CuentasDAO.START]
service jboss.deployment.unit."test.war".component.CuentasDAO.WeldInterceptorBindingsService (missing) dependents: [service jboss.deployment.unit."test.war".component.CuentasDAO.WeldInstantiator]
service jboss.deployment.unit."test.war".component.CuentasDAO.ejb.non-functional-timerservice (missing) dependents: [service jboss.deployment.unit."test.war".component.CuentasDAO.START]
service jboss.deployment.unit."test.war".component.CuentasService.CREATE (missing) dependents: [service jboss.deployment.unit."test.war".component.CuentasService.START]
service jboss.deployment.unit."test.war".component.CuentasService.START (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./test.UndertowDeploymentInfoService, service jboss.deployment.unit."test.war".moduleDeploymentRuntimeInformationStart, service jboss.undertow.deployment.default-server.default-host./test, service jboss.deployment.unit."test.war".deploymentCompleteService]
service jboss.deployment.unit."test.war".component.CuentasService.VIEW."ar.gob.ssn.apps.mavenjee.service.CuentasService".LOCAL (missing) dependents: [service jboss.deployment.unit."test.war".component.CuentasService.START]
service jboss.deployment.unit."test.war".component.CuentasService.WeldInstantiator (missing) dependents: [service jboss.deployment.unit."test.war".component.CuentasService.START]
service jboss.deployment.unit."test.war".component.CuentasService.WeldInterceptorBindingsService (missing) dependents: [service jboss.deployment.unit."test.war".component.CuentasService.WeldInstantiator]
service jboss.deployment.unit."test.war".component.CuentasService.ejb.non-functional-timerservice (missing) dependents: [service jboss.deployment.unit."test.war".component.CuentasService.START]
service jboss.deployment.unit."test.war".component."com.sun.faces.config.ConfigureListener".CREATE (missing) dependents: [service jboss.deployment.unit."test.war".component."com.sun.faces.config.ConfigureListener".START]
service jboss.deployment.unit."test.war".component."com.sun.faces.config.ConfigureListener".START (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./test.UndertowDeploymentInfoService, service jboss.undertow.deployment.default-server.default-host./test, service jboss.deployment.unit."test.war".deploymentCompleteService]
service jboss.deployment.unit."test.war".component."com.sun.faces.config.ConfigureListener".WeldInstantiator (missing) dependents: [service jboss.deployment.unit."test.war".component."com.sun.faces.config.ConfigureListener".START]
service jboss.deployment.unit."test.war".component."javax.faces.webapp.FacetTag".CREATE (missing) dependents: [service jboss.deployment.unit."test.war".component."javax.faces.webapp.FacetTag".START]
service jboss.deployment.unit."test.war".component."javax.faces.webapp.FacetTag".WeldInstantiator (missing) dependents: [service jboss.deployment.unit."test.war".component."javax.faces.webapp.FacetTag".START]
service jboss.deployment.unit."test.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".CREATE (missing) dependents: [service jboss.deployment.unit."test.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START]
service jboss.deployment.unit."test.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".WeldInstantiator (missing) dependents: [service jboss.deployment.unit."test.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START]
service jboss.deployment.unit."test.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./test.UndertowDeploymentInfoService, service jboss.undertow.deployment.default-server.default-host./test, service jboss.deployment.unit."test.war".deploymentCompleteService]
service jboss.deployment.unit."test.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".WeldInstantiator (missing) dependents: [service jboss.deployment.unit."test.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START]
service jboss.deployment.unit."test.war".component."org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner".CREATE (missing) dependents: [service jboss.deployment.unit."test.war".component."org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner".START]
service jboss.deployment.unit."test.war".component."org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner".WeldInstantiator (missing) dependents: [service jboss.deployment.unit."test.war".component."org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner".START]
service jboss.deployment.unit."test.war".component."org.jboss.weld.servlet.WeldInitialListener".CREATE (missing) dependents: [service jboss.deployment.unit."test.war".component."org.jboss.weld.servlet.WeldInitialListener".START]
service jboss.deployment.unit."test.war".component."org.jboss.weld.servlet.WeldInitialListener".START (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./test.UndertowDeploymentInfoService, service jboss.undertow.deployment.default-server.default-host./test, service jboss.deployment.unit."test.war".deploymentCompleteService]
service jboss.deployment.unit."test.war".component."org.jboss.weld.servlet.WeldInitialListener".WeldInstantiator (missing) dependents: [service jboss.deployment.unit."test.war".component."org.jboss.weld.servlet.WeldInitialListener".START]
service jboss.deployment.unit."test.war".component."org.jboss.weld.servlet.WeldTerminalListener".CREATE (missing) dependents: [service jboss.deployment.unit."test.war".component."org.jboss.weld.servlet.WeldTerminalListener".START]
service jboss.deployment.unit."test.war".component."org.jboss.weld.servlet.WeldTerminalListener".START (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./test.UndertowDeploymentInfoService, service jboss.undertow.deployment.default-server.default-host./test, service jboss.deployment.unit."test.war".deploymentCompleteService]
service jboss.deployment.unit."test.war".component."org.jboss.weld.servlet.WeldTerminalListener".WeldInstantiator (missing) dependents: [service jboss.deployment.unit."test.war".component."org.jboss.weld.servlet.WeldTerminalListener".START]
service jboss.deployment.unit."test.war".ee.ComponentRegistry (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./test.UndertowDeploymentInfoService]
service jboss.deployment.unit."test.war".jndiDependencyService (missing) dependents: [service jboss.deployment.unit."test.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START, service jboss.deployment.unit."test.war".component."org.jboss.weld.servlet.WeldInitialListener".START, service jboss.deployment.unit."test.war".component.CuentasService.START, service jboss.deployment.unit."test.war".component."javax.faces.webapp.FacetTag".START, JBAS014799: ... and 7 more ]
service jboss.deployment.unit."test.war".moduleDeploymentRuntimeInformation (missing) dependents: [service jboss.deployment.unit."test.war".moduleDeploymentRuntimeInformationStart]
service jboss.jdbc-driver.postgresql (missing) dependents: [service jboss.data-source.java:jboss/datasources/mavenjeeTestDS]
service jboss.persistenceunit."test.war#primary" (missing) dependents: [service jboss.deployment.unit."test.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START, service jboss.undertow.deployment.default-server.default-host./test.UndertowDeploymentInfoService, service jboss.deployment.unit."test.war".component.CuentasService.START, service jboss.undertow.deployment.default-server.default-host./test, JBAS014799: ... and 8 more ]
service jboss.undertow.deployment.default-server.default-host./test (missing) dependents: [service jboss.deployment.unit."test.war".deploymentCompleteService]
service jboss.undertow.deployment.default-server.default-host./test.UndertowDeploymentInfoService (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./test]
service jboss.undertow.deployment.default-server.default-host./test.codec (missing) dependents: [service jboss.undertow.deployment.default-server.default-host./test.UndertowDeploymentInfoService]
这是我的测试类,只有@deployment部分
@RunWith(Arquillian.class)
public class CuentaTest {
@Deployment
public static Archive<?> createTestArchive() {
File[] libs = Maven.resolver().loadPomFromFile("pom.xml").resolve("org.postgresql:postgresql").withTransitivity().asFile();
return ShrinkWrap.create(WebArchive.class, "test.war")
.addClasses(Cuenta.class, CuentasService.class, Resources.class, CuentasDAO.class)
.addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsLibraries(libs)
// Deploy our test datasource
.addAsWebInfResource("test-ds.xml");
}
我将属性 wildfly.jpa.twophasebootstrap 设置为false
如果您需要更多.xml文件以便帮助我,请告诉我
更新1
我按照Eclipse的向导创建了一个Maven Wildfly JEE7 webapp,所以这是我的 test-ds.xml
<datasources xmlns="http://www.jboss.org/ironjacamar/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<datasource jndi-name="java:jboss/datasources/mavenjeeTestDS"
pool-name="mavenjee-test" enabled="true"
use-java-context="true">
<connection-url>jdbc:postgresql://XXX.XX.X.XXX:5432/xxx</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<driver>postgresql</driver>
<security>
<user-name>XXX</user-name>
<password>XXX</password>
</security>
</datasource>
</datasources>
test-persistence.xml
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="primary">
<jta-data-source>java:jboss/datasources/mavenjeeTestDS</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.show_sql" value="true" />
<property name="wildfly.jpa.twophasebootstrap" value="false"/>
</properties>
</persistence-unit>
</persistence>
更新2
带有Arquillian配置的 pom.xml 部分
<profile>
<id>arq-wildfly-managed</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1201-jdbc41</version>
</dependency>
</dependencies>
</profile>
arquillian.xml
<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<container qualifier="jboss" default="true">
<property name="jbossHome">C:/MUNDO_JAVA/Servers/wildfly-8.2.0.MavenJtaJpa</property>
</configuration>
</container>
</arquillian>
由于