I am trying to deploy my application on my Wildfly 11 server, but am having the following problem.
Cannot upload deployment: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"javaee-angularjs.war\".WeldStartService" => "Failed to start service Caused by: java.lang.IllegalArgumentException: WFLYWELD0037: Error injecting persistence unit into CDI managed bean. Can't find a persistence unit named 'siscorp' in deployment javaee-angularjs.war for injection point private javax.persistence.EntityManager br.com.rafaelvicio.siscorp.util.Persistence.entityManager"}}
this is my persistence class:
package br.com.rafaelvicio.siscorp.util;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@ApplicationScoped
public class Persistence {
@PersistenceContext(unitName="siscorp")
private EntityManager entityManager;
@Produces
public EntityManager getEntityManager() {
return entityManager;
}
}
this is my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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="siscorp">
<!-- provedor/implementacao do JPA -->
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<!-- entidade mapeada -->
<class>br.com.rafaelvicio.siscorp.model.CEP</class>
<properties>
<!-- dados da conexao -->
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/siscorp" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="admin123" />
<!-- propriedades do hibernate -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<!-- atualiza o banco, gera as tabelas se for preciso -->
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>