Solucionado (ver solução)
Solucionado
(ver solução)
7
respostas

erro no projeto

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named financas at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) at br.com.caelum.financas.teste.TesteJPA.main(TesteJPA.java:19)

7 respostas

Oi Paulo, duas coisas: me informa exatamente a pasta do seu persistence.xml e também cola o código dele aqui. Provavelmente, na tag persistence-unit vc não definiu o nome finanças.

quando tento adicionar o projeto ao servidor aparece essa mensagem de erro:

there are no resoources that can be added or removed from the sever não há recursos que podem ser adicionados ou removidos a partir do servidor

pasta onde está o arquivo persistence.xml : META-INF

todo código do arquivo:

org.hibernate.ejb.HibernatePersistence br.com.caelum.financas.modelo.Conta

org.hibernate.ejb.HibernatePersistence br.com.caelum.financas.modelo.Conta

por último apareceu este erro:

jul 26, 2016 9:06:05 PM org.hibernate.annotations.common.Version INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final} jul 26, 2016 9:06:05 PM org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.2.21.Final} jul 26, 2016 9:06:05 PM org.hibernate.cfg.Environment INFO: HHH000206: hibernate.properties not found jul 26, 2016 9:06:05 PM org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist jul 26, 2016 9:06:05 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!) jul 26, 2016 9:06:05 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000115: Hibernate connection pool size: 20 jul 26, 2016 9:06:05 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000006: Autocommit mode: true jul 26, 2016 9:06:05 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost/financas] jul 26, 2016 9:06:05 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure INFO: HHH000046: Connection properties: {user=root, autocommit=true, release_mode=auto} jul 26, 2016 9:06:08 PM org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure WARN: HHH000342: Could not obtain connection to query metadata : Communications link failure

Last packet sent to the server was 0 ms ago. Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: financas] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:925) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:900) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) at br.com.caelum.financas.teste.TesteJPA.main(TesteJPA.java:19) Caused by: org.hibernate.HibernateException: Dialect class not found: org.hibernate.dialect.MySQLSInnoDBDialect at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:77) at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:65) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:170) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156) at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1827) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1785) at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:96) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915) ... 5 more Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.dialect.MySQLSInnoDBDialect] at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:151) at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:74) ... 14 more Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.dialect.MySQLSInnoDBDialect at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:318) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:148) ... 15 more

Tem alguma coisa escrita errada aqui => org.hibernate.dialect.MySQLSInnoDBDialect . Ele deu ClassNotFoundException

solução!

org.hibernate.dialect.MySQLSInnoDBDialect está escrito com S. Troca para org.hibernate.dialect.MySQL5InnoDBDialect