Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jpa Can';我找不到阿奎利安的持久单位_Jpa_Glassfish_Jboss Arquillian - Fatal编程技术网

Jpa Can';我找不到阿奎利安的持久单位

Jpa Can';我找不到阿奎利安的持久单位,jpa,glassfish,jboss-arquillian,Jpa,Glassfish,Jboss Arquillian,我用Arquillian和一个远程Glassfish实例设置了一个单元测试: @RunWith(Arquillian.class) public class ClientTest { @EJB private ClientService client; @Deployment public static Archive<?> createDeployment() { return ShrinkWrap.create(WebA

我用Arquillian和一个远程Glassfish实例设置了一个单元测试:

@RunWith(Arquillian.class)
public class ClientTest {

    @EJB
    private ClientService client;

    @Deployment
    public static Archive<?> createDeployment() {

           return ShrinkWrap.create(WebArchive.class, "test.war")
                   .addPackage(Client.class.getPackage())
                   .addPackage(ClientService.class.getPackage())
                   .addPackage(Client_.class.getPackage())
                   .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
                   .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
    }

    @Test
    public void testCreate() {
        Assert.assertNotNull("Client not null", client);
        Client c = client.getClientById(1L);
        assertNotNull(c);
    }
线路

.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
告诉Shrinkwrap在test/resources文件夹中查找test-persistence.xml文件,并将其添加到META-INF文件夹中的war文件中


您必须将persistence.xml文件重命名为test-persistence.xml,并确保它在您的test/resources文件夹中可用。您也可以从源代码直接指向persistence.xml文件

.addAsResource("META-INF/persistence.xml")

这将缓解您的问题。

谢谢您的提问。
persistence.xml
部署正确-我仔细检查了它。解决方案是重新启动我的glassfish服务器。不知道为什么,但重启后一切正常

.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
.addAsResource("META-INF/persistence.xml")