java.lang.NoClassDefFoundError

1. java.lang.NoClassDefFoundError

Pedro Henrique
PedroR.66

(usa Ubuntu)

Enviado em 24/06/2016 - 23:39h

Salve galera,
Preciso de ajuda... por favor

Estou tentando gerar as tabelas no banco de dados usando JPA, Hibernate, projeto Java simples apenas para gerar as tabelas no banco e quando executo a classe para gerar as tabela da esse erro no console:
Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/service/jndi/JndiNameException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.jboss.logging.Logger$1.run(Logger.java:2554)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2529)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2516)
at org.hibernate.ejb.Ejb3Configuration.<clinit>(Ejb3Configuration.java:144)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at com.testehibernate.GerarTabelas.main(GerarTabelas.java:8)
Caused by: java.lang.ClassNotFoundException: org.hibernate.service.jndi.JndiNameException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 11 more
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="GerarPU" transaction-type="RESOURCE_LOCAL">

<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.testehibernate.GerarTabelas</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/ebookjpa" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="root" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="create" />
</properties>

</persistence-unit>
</persistence>


main

package com.testehibernate;

//import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class GerarTabelas {
public static void main(String[] args) {
Persistence.createEntityManagerFactory ("GerarPU");
}
}


Uso eclipse
Obs.: Já procurei em muitos sites e nenhum tem a reposta.
Valeu galera


  


2. Re: java.lang.NoClassDefFoundError

Taynara
taynara

(usa Linux Mint)

Enviado em 27/09/2016 - 15:12h

No trecho abaixo, tente colocar vírgula:

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">;

ou tente instanciar um objeto Persistence.
Acho que pode ser isso.






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts