HTTP Status 500 - estou usando JPA e javaEE

java-ee

#1

ESTOU COM OS SEGUINTE ERRO, estou usando uma pagina index.xhtml quando vou aperta button aparece esta mensagem para verificar se hibernate esta tudo ok, mais quando utilizo console funciona de boa .
type Exception report

message javax.persistence.PersistenceException: No Persistence provider for EntityManager named exemplo-pu

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: javax.persistence.PersistenceException: No Persistence provider for EntityManager named exemplo-pu
javax.faces.webapp.FacesServlet.service(Unknown Source)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

javax.faces.el.EvaluationException: javax.persistence.PersistenceException: No Persistence provider for EntityManager named exemplo-pu
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(Unknown Source)
com.sun.faces.application.ActionListenerImpl.processAction(Unknown Source)
javax.faces.component.UICommand.broadcast(Unknown Source)
javax.faces.component.UIViewRoot.broadcastEvents(Unknown Source)
javax.faces.component.UIViewRoot.processApplication(Unknown Source)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(Unknown Source)
com.sun.faces.lifecycle.Phase.doPhase(Unknown Source)
com.sun.faces.lifecycle.LifecycleImpl.execute(Unknown Source)
javax.faces.webapp.FacesServlet.service(Unknown Source)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause

javax.persistence.PersistenceException: No Persistence provider for EntityManager named exemplo-pu
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
devmedia.entity.TesteManeBean.Teste(TesteManeBean.java:12)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.el.parser.AstValue.invoke(AstValue.java:279)
org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:273)
com.sun.faces.facelets.el.TagMethodExpression.invoke(Unknown Source)
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(Unknown Source)
com.sun.faces.application.ActionListenerImpl.processAction(Unknown Source)
javax.faces.component.UICommand.broadcast(Unknown Source)
javax.faces.component.UIViewRoot.broadcastEvents(Unknown Source)
javax.faces.component.UIViewRoot.processApplication(Unknown Source)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(Unknown Source)
com.sun.faces.lifecycle.Phase.doPhase(Unknown Source)
com.sun.faces.lifecycle.LifecycleImpl.execute(Unknown Source)
javax.faces.webapp.FacesServlet.service(Unknown Source)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.86 logs.

TENHO UMA CLASSE Usuario

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column
private String nome;
@Column
private String login;
@Column
private String senha;

public Integer getId() {
	return id;
}

public void setId(Integer id) {
	this.id = id;
}

public String getNome() {
	return nome;
}

public void setNome(String nome) {
	this.nome = nome;
}

public String getLogin() {
	return login;
}

public void setLogin(String login) {
	this.login = login;
}

public String getSenha() {
	return senha;
}

public void setSenha(String senha) {
	this.senha = senha;
}

é o arquivo persistence.xml

<persistence-unit name="exemplo-pu"
	transaction-type="RESOURCE_LOCAL">

	<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
	<class>devmedia.entity.Usuario</class>
	

	<properties>
		<property name="javax.persistence.jdbc.url"
			value="jdbc:mysql://localhost:3306/loja?createDatabaseIfNotExist=true" />
		<property name="javax.persistence.jdbc.user" value="root" />
		<property name="javax.persistence.jdbc.password" value="" />
		<property name="javax.persistence.jdbc.driver"
			value="com.mysql.jdbc.Driver" />


		<property name="hibernate.hbm2ddl.auto" value="update" />
		<property name="hibernate.show_sql" value="true" />
		<property name="hibernate.format_sql" value="true" />
		<property name="hibernate.dialect"
			value="org.hibernate.dialect.MySQL5Dialect" />



	</properties>


</persistence-unit>

#2

algum pode me ajudar ?


#3

Veja, o erro diz:
javax.servlet.ServletException: javax.persistence.PersistenceException: No Persistence provider for EntityManager named exemplo-pu.
A aplicação não conhece a instância de um EntityManager sob o nome ‘exemplo-pu

Seu código deve ter um EntityManagerFactory factory = Persistence.createEntityManagerFactory("exemplo-pu"); ou algo do tipo.


#4

Sua classe persistence.xml pode esta alguma coisa escrito errado verifica se esta tudo certo


#5

pasta META-INF esta dentro de src