Hibernate/JPA doesn't work -


this third question far trying fix this. tried lot of things, yet keeps failing , throwing exact same error on , on. let's see if can me time.

see, 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> 

it connects wamp mysql server via jndi connection pool "jdbc/nuevaconexion".

here try use (just testing purposes, entity!):

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();     } } 

i error, strange because tells me change provider, but... it's changed. check:

> may 09, 2016 10:36:49 org.hibernate.ejb.hibernatepersistence > logdeprecation warn: hhh015016: encountered deprecated > javax.persistence.spi.persistenceprovider > [org.hibernate.ejb.hibernatepersistence]; use > [org.hibernate.jpa.hibernatepersistenceprovider] instead. may 09, 2016 > 10:36:49 org.hibernate.ejb.hibernatepersistence logdeprecation > warn: hhh015016: encountered deprecated > javax.persistence.spi.persistenceprovider > [org.hibernate.ejb.hibernatepersistence]; use > [org.hibernate.jpa.hibernatepersistenceprovider] instead. may 09, 2016 > 10:36:49 org.hibernate.ejb.hibernatepersistence logdeprecation > warn: hhh015016: encountered deprecated > javax.persistence.spi.persistenceprovider > [org.hibernate.ejb.hibernatepersistence]; use > [org.hibernate.jpa.hibernatepersistenceprovider] instead. exception in > thread "main" javax.persistence.persistenceexception: unable locate > persistence units     @ > org.hibernate.jpa.hibernatepersistenceprovider.getentitymanagerfactorybuilderornull(hibernatepersistenceprovider.java:99) >   @ > org.hibernate.ejb.hibernatepersistence.getentitymanagerfactorybuilderornull(hibernatepersistence.java:93) >   @ > org.hibernate.jpa.hibernatepersistenceprovider.getentitymanagerfactorybuilderornull(hibernatepersistenceprovider.java:86) >   @ > org.hibernate.ejb.hibernatepersistence.getentitymanagerfactorybuilderornull(hibernatepersistence.java:101) >   @ > org.hibernate.jpa.hibernatepersistenceprovider.createentitymanagerfactory(hibernatepersistenceprovider.java:67) >   @ > org.hibernate.ejb.hibernatepersistence.createentitymanagerfactory(hibernatepersistence.java:54) >   @ > javax.persistence.persistence.createentitymanagerfactory(persistence.java:55) >   @ > javax.persistence.persistence.createentitymanagerfactory(persistence.java:39) >   @ 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}'. >  >   @ > org.hibernate.jpa.boot.internal.persistencexmlparser.validate(persistencexmlparser.java:377) >   @ > org.hibernate.jpa.boot.internal.persistencexmlparser.loadurl(persistencexmlparser.java:310) >   @ > org.hibernate.jpa.boot.internal.persistencexmlparser.parsepersistencexml(persistencexmlparser.java:114) >   @ > org.hibernate.jpa.boot.internal.persistencexmlparser.doresolve(persistencexmlparser.java:104) >   @ > org.hibernate.jpa.boot.internal.persistencexmlparser.locatepersistenceunits(persistencexmlparser.java:86) >   @ > 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) 

it seems persistence.xml file cannot validated. either contains invalid character (check encoding, bom...) or schema cannot resolved (you should remove declaration xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd").


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -