2

I have a JBoss EAP 6.1.0.GA (AS 7.2.0.Final-redhat-8) and I want to deploy a java web-project that uses JPA. I use with Eclipse / Maven and upon deploying the application I recieve the error:

Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011047:
Can't find a persistence unit named cinemaReservationPersistenceUnit in deployment "javakurs3.final.project.cinema.war"

This is my project structure in Eclipse:

enter image description here

After having read some of the related questions here, for example:

JBoss7.1.0: Can't find a persistence unit named null in subdeployment

I was not able to find a solution to my Problem This is my persistence.xml file:

 <?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
     http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">

    <persistence-unit name="cinemaReservationPersistenceUnit" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>

        <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
            <property name="hibernate.max_fetch_depth" value="3" />
            <property name="hibernate.hbm2ddl.auto" value="create.update" />
            <property name="hibernate.show_sql" value="true" />
        </properties>
    </persistence-unit>
</persistence>

Could you please help?

Alex Mi
  • 1,409
  • 2
  • 21
  • 35

1 Answers1

2

As you package project in war file you need to move persistence.xml under resources/webapp/WEB-INF folder.

  • I think you are not right. I have just successfully deployed another Java web-project that had the persistence.xml under the same structure as the project above and the deployment was successful – Alex Mi Apr 26 '19 at 11:36
  • Like this: @Stateless(mappedName = "FilmService") public class FilmService { @PersistenceContext(unitName = "cinemaReservationPersistenceUnit") private EntityManager em; – Alex Mi Apr 26 '19 at 11:42
  • 1
    Try to rename META_INF on META-INF – Олег Гаврилів Apr 26 '19 at 11:48