Java JPA Hibernate Connection Issue -
Java JPA Hibernate Connection Issue -
i'm using netbeans connect database. want utilize java persistence retrieve info database i'm getting these errors:
jun 18, 2014 9:41:44 org.hibernate.annotations.common.version <clinit> info: hcann000001: hibernate commons annotations {4.0.2.final} jun 18, 2014 9:41:44 org.hibernate.version logversion info: hhh000412: hibernate core {4.2.6.final} jun 18, 2014 9:41:44 org.hibernate.cfg.environment <clinit> info: hhh000206: hibernate.properties not found jun 18, 2014 9:41:44 org.hibernate.cfg.environment buildbytecodeprovider info: hhh000021: bytecode provider name : javassist exception in thread "awt-eventqueue-0" java.lang.exceptionininitializererror @ controle_entregas.controleentregasui.jmenuitemnovaentregaactionperformed(controleentregasui.java:199) @ controle_entregas.controleentregasui.access$100(controleentregasui.java:18) @ controle_entregas.controleentregasui$2.actionperformed(controleentregasui.java:85) @ javax.swing.abstractbutton.fireactionperformed(abstractbutton.java:2022) @ javax.swing.abstractbutton$handler.actionperformed(abstractbutton.java:2346) @ javax.swing.defaultbuttonmodel.fireactionperformed(defaultbuttonmodel.java:402) @ javax.swing.defaultbuttonmodel.setpressed(defaultbuttonmodel.java:259) @ javax.swing.abstractbutton.doclick(abstractbutton.java:376) @ javax.swing.plaf.basic.basicmenuitemui.doclick(basicmenuitemui.java:833) @ javax.swing.plaf.basic.basicmenuitemui$handler.mousereleased(basicmenuitemui.java:877) @ java.awt.component.processmouseevent(component.java:6527) @ javax.swing.jcomponent.processmouseevent(jcomponent.java:3321) @ java.awt.component.processevent(component.java:6292) @ java.awt.container.processevent(container.java:2234) @ java.awt.component.dispatcheventimpl(component.java:4883) @ java.awt.container.dispatcheventimpl(container.java:2292) @ java.awt.component.dispatchevent(component.java:4705) @ java.awt.lightweightdispatcher.retargetmouseevent(container.java:4898) @ java.awt.lightweightdispatcher.processmouseevent(container.java:4533) @ java.awt.lightweightdispatcher.dispatchevent(container.java:4462) @ java.awt.container.dispatcheventimpl(container.java:2278) @ java.awt.window.dispatcheventimpl(window.java:2739) @ java.awt.component.dispatchevent(component.java:4705) @ java.awt.eventqueue.dispatcheventimpl(eventqueue.java:746) @ java.awt.eventqueue.access$400(eventqueue.java:97) @ java.awt.eventqueue$3.run(eventqueue.java:697) @ java.awt.eventqueue$3.run(eventqueue.java:691) @ java.security.accesscontroller.doprivileged(native method) @ java.security.protectiondomain$1.dointersectionprivilege(protectiondomain.java:75) @ java.security.protectiondomain$1.dointersectionprivilege(protectiondomain.java:86) @ java.awt.eventqueue$4.run(eventqueue.java:719) @ java.awt.eventqueue$4.run(eventqueue.java:717) @ java.security.accesscontroller.doprivileged(native method) @ java.security.protectiondomain$1.dointersectionprivilege(protectiondomain.java:75) @ java.awt.eventqueue.dispatchevent(eventqueue.java:716) @ java.awt.eventdispatchthread.pumponeeventforfilters(eventdispatchthread.java:201) @ java.awt.eventdispatchthread.pumpeventsforfilter(eventdispatchthread.java:116) @ java.awt.eventdispatchthread.pumpeventsforhierarchy(eventdispatchthread.java:105) @ java.awt.eventdispatchthread.pumpevents(eventdispatchthread.java:101) @ java.awt.eventdispatchthread.pumpevents(eventdispatchthread.java:93) @ java.awt.eventdispatchthread.run(eventdispatchthread.java:82) caused by: javax.persistence.persistenceexception: unable configure entitymanagerfactory @ org.hibernate.ejb.ejb3configuration.configure(ejb3configuration.java:387) @ org.hibernate.ejb.hibernatepersistence.createentitymanagerfactory(hibernatepersistence.java:58) @ javax.persistence.persistence.createentitymanagerfactory(persistence.java:63) @ javax.persistence.persistence.createentitymanagerfactory(persistence.java:47) @ controle_entregas.cadeditentrega.<clinit>(cadeditentrega.java:33) ... 41 more caused by: java.lang.runtimeexception: error while reading file:/c:/users/huberto/documents/netbeansprojects/controle_entregas/build/classes/ @ org.hibernate.ejb.packaging.nativescanner.getclassesinjar(nativescanner.java:131) @ org.hibernate.ejb.ejb3configuration.addscannedentries(ejb3configuration.java:487) @ org.hibernate.ejb.ejb3configuration.addmetadatafromscan(ejb3configuration.java:477) @ org.hibernate.ejb.ejb3configuration.configure(ejb3configuration.java:363) ... 45 more caused by: java.io.ioexception: invalid constant type: 18 @ javassist.bytecode.constpool.readone(constpool.java:1113) @ javassist.bytecode.constpool.read(constpool.java:1056) @ javassist.bytecode.constpool.<init>(constpool.java:150) @ javassist.bytecode.classfile.read(classfile.java:765) @ javassist.bytecode.classfile.<init>(classfile.java:109) @ org.hibernate.ejb.packaging.abstractjarvisitor.checkannotationmatching(abstractjarvisitor.java:246) @ org.hibernate.ejb.packaging.abstractjarvisitor.executejavaelementfilter(abstractjarvisitor.java:212) @ org.hibernate.ejb.packaging.abstractjarvisitor.addelement(abstractjarvisitor.java:173) @ org.hibernate.ejb.packaging.explodedjarvisitor.getclassnamesintree(explodedjarvisitor.java:126) @ org.hibernate.ejb.packaging.explodedjarvisitor.getclassnamesintree(explodedjarvisitor.java:134) @ org.hibernate.ejb.packaging.explodedjarvisitor.doprocesselements(explodedjarvisitor.java:92) @ org.hibernate.ejb.packaging.abstractjarvisitor.getmatchingentries(abstractjarvisitor.java:149) @ org.hibernate.ejb.packaging.nativescanner.getclassesinjar(nativescanner.java:128) ... 48 more
this how phone call it:
public class cadeditentrega extends javax.swing.jframe { static dbconnect connection = null; private static final string tabela = "clientes"; private integer id = null; private date date = null; @persistencecontext static entitymanagerfactory emf = persistence.createentitymanagerfactory("controle_entregaspu"); public entitymanager em = emf.createentitymanager(); /** * creates new form cadeditentrega * @param connection * @throws java.sql.sqlexception * @throws java.lang.classnotfoundexception */ public cadeditentrega(dbconnect connection) throws sqlexception, classnotfoundexception { cadeditentrega.connection = connection; this.date = new date(); initcomponents(); jdatechooser.setdate(date); preenchecombocliente(); preenchecomboproduto(); } private void preenchecombocliente() throws sqlexception{ /*resultset result = connection.dbselect("*", "clientes"); while(result.next()){ jcomboboxcliente.additem(result.getstring("cliente_nome")); }*/ em.gettransaction().begin(); list<clientes> list = em.createnamedquery("clientes.findall", clientes.class).getresultlist(); em.gettransaction().commit(); em.close(); } }
and persistence.xml:
<?xml version="1.0" encoding="utf-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="controle_entregaspu" transaction-type="resource_local"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <class>controle_entregas.clientes</class> <class>controle_entregas.movimentacao</class> <class>controle_entregas.movimentacaoprodutos</class> <class>controle_entregas.produtos</class> <class>controle_entregas.tiposmovimentacao</class> <properties> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://mysql22.******:3306/******?zerodatetimebehavior=converttonull"/> <property name="javax.persistence.jdbc.user" value="******"/> <property name="javax.persistence.jdbc.driver" value="******"/> <property name="javax.persistence.jdbc.password" value="******"/> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.nocacheprovider"/> <property name="hibernate.hbm2ddl.auto" value="update"/> </properties> </persistence-unit> </persistence>
my project:
http://i.stack.imgur.com/yuayl.png
are using java 8? if you might want utilize latest javassist. @ to the lowest degree found when using version of 3.12 ga of javassist had problem. in maven pom:
<dependency> <groupid>org.javassist</groupid> <artifactid>javassist</artifactid> <version>3.18.2-ga</version> </dependency>
hibernate jpa persistence java-8 persistence.xml
Comments
Post a Comment