これはこれまでこれを修正しようとする私の3番目の質問です。私はすでに多くのことを試しましたが、これは失敗を続け、まったく同じエラーを繰り返し投げます。今回は誰かが私を助けることができるかどうかを見てみましょう。Hibernate/JPAは動作しません
を参照してください、これは私のpersistence.xmlのです:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="PruebaswebPU" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:app/jdbc/nuevaConexion</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<!-- Hibernate properties -->
<properties>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
<property name="hibernate.connection.charSet" value="UTF-8"/>
<property name="hibernate.validator.apply_to_ddl" value="false"/>
<property name="hibernate.validator.autoregister_listeners" value="false"/>
<property name="hibernate.show_sql" value="false"/>
</properties>
</persistence-unit>
</persistence>
これは、JNDI接続プール "JDBC/nuevaConexion" を介してWAMP MySQLサーバに接続します。ここで
私はそれを使用しよう:私はいつもそれがプロバイダを変更するために私に語ったので、奇妙で、このエラーを取得
public class samplePersistence {
public static void main(String[] args) {
EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("PruebaswebPU");
EntityManager entitymanager = emfactory.createEntityManager();
entitymanager.getTransaction().begin();
testEntity ent = new testEntity();
ent.setId(5l);
ent.setNombre("One name");
entitymanager.persist(ent);
entitymanager.getTransaction().commit();
entitymanager.close();
emfactory.close();
}
}
、しかし...(私のエンティティとして、テスト目的!)それはすでに変更されています。確認:
> may 09, 2016 10:36:49 AM org.hibernate.ejb.HibernatePersistence
> logDeprecation WARN: HHH015016: Encountered a deprecated
> javax.persistence.spi.PersistenceProvider
> [org.hibernate.ejb.HibernatePersistence]; use
> [org.hibernate.jpa.HibernatePersistenceProvider] instead. may 09, 2016
> 10:36:49 AM org.hibernate.ejb.HibernatePersistence logDeprecation
> WARN: HHH015016: Encountered a deprecated
> javax.persistence.spi.PersistenceProvider
> [org.hibernate.ejb.HibernatePersistence]; use
> [org.hibernate.jpa.HibernatePersistenceProvider] instead. may 09, 2016
> 10:36:49 AM org.hibernate.ejb.HibernatePersistence logDeprecation
> WARN: HHH015016: Encountered a deprecated
> javax.persistence.spi.PersistenceProvider
> [org.hibernate.ejb.HibernatePersistence]; use
> [org.hibernate.jpa.HibernatePersistenceProvider] instead. Exception in
> thread "main" javax.persistence.PersistenceException: Unable to locate
> persistence units at
> org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:99)
> at
> org.hibernate.ejb.HibernatePersistence.getEntityManagerFactoryBuilderOrNull(HibernatePersistence.java:93)
> at
> org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:86)
> at
> org.hibernate.ejb.HibernatePersistence.getEntityManagerFactoryBuilderOrNull(HibernatePersistence.java:101)
> at
> org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:67)
> at
> org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
> at
> javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
> at
> javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
> at testing.samplePersistence.main(samplePersistence.java:20) Caused
> by: javax.persistence.PersistenceException: Invalid persistence.xml.
> Error parsing XML [line : -1, column : -1] : cvc-complex-type.2.4.b:
> El contenido del elemento 'persistence' no está completo. Se esperaba
> uno de '{"http://xmlns.jcp.org/xml/ns/persistence":persistence-unit}'.
>
> at
> org.hibernate.jpa.boot.internal.PersistenceXmlParser.validate(PersistenceXmlParser.java:377)
> at
> org.hibernate.jpa.boot.internal.PersistenceXmlParser.loadUrl(PersistenceXmlParser.java:310)
> at
> org.hibernate.jpa.boot.internal.PersistenceXmlParser.parsePersistenceXml(PersistenceXmlParser.java:114)
> at
> org.hibernate.jpa.boot.internal.PersistenceXmlParser.doResolve(PersistenceXmlParser.java:104)
> at
> org.hibernate.jpa.boot.internal.PersistenceXmlParser.locatePersistenceUnits(PersistenceXmlParser.java:86)
> at
> org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:95)
> ... 8 more
> C:\Users\hp\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53:
> Java returned: 1 BUILD FAILED (total time: 0 seconds)