hibernate - ClassNotFound : javax.persistence.Persistence when creating entity Manager Factory -


i working on project jsf , hibernate.

i divided project 3 layers (view, service, dao)

in service layer creating instance of dao class, when reaching persistence.createentitymanagerfactory("e_gym") throws exception, see below blocks

public abstract class basedao<t> implements serializable {     private static final long serialversionuid = 1l;      //the next line #18     private static final entitymanagerfactory emf = persistence.createentitymanagerfactory("e_gym"); 

//.... }

public class techniqueservice implements serializable {     private static final long serialversionuid = -853877188695729368l;      private techniquedao techniquedao = new techniquedao();      public techniqueservice() {}     //crud service methods... } 

here persistence.xml file:

<?xml version="1.0" encoding="utf-8"?> 

http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

<persistence-unit name="e_gym" transaction-type="resource_local">     <provider>org.hibernate.ejb.hibernatepersistence</provider>      <properties>         <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.driver" />        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/e_gym" />          <property name="javax.persistence.jdbc.user" value="root" />         <property name="javax.persistence.jdbc.password" value="root" />         <property name="hibernate.show_sql" value="true" />          <property name="hibernate.connection.shutdown" value="true" />         <property name="hibernate.dialect" value="org.hibernate.dialect.mysqldialect" />      </properties> </persistence-unit> 

but facing exception :

java.lang.classnotfoundexception: javax.persistence.persistence @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1720) @ org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1571) @ nassar.apps.orm.dao.basedao.<clinit>(basedao.java:18) @ nassar.apps.gym.services.techniqueservice.<init>(techniqueservice.java:12) @ nassar.apps.gym.views.techniquesview.gettechniqueservice(techniquesview.java:90) @ nassar.apps.gym.views.techniquesview.filltechniques(techniquesview.java:41) @ nassar.apps.gym.views.techniquesview.<init>(techniquesview.java:26) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(unknown source) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(unknown source) @ java.lang.reflect.constructor.newinstance(unknown source) @ java.lang.class.newinstance(unknown source) @ com.sun.faces.mgbean.beanbuilder.newbeaninstance(beanbuilder.java:186) @ com.sun.faces.mgbean.beanbuilder.build(beanbuilder.java:100) @ com.sun.faces.mgbean.beanmanager.createandpush(beanmanager.java:409) @ com.sun.faces.mgbean.beanmanager.create(beanmanager.java:269) @ com.sun.faces.el.managedbeanelresolver.resolvebean(managedbeanelresolver.java:244) @ com.sun.faces.el.managedbeanelresolver.getvalue(managedbeanelresolver.java:116) @ com.sun.faces.el.demuxcompositeelresolver._getvalue(demuxcompositeelresolver.java:176) @ com.sun.faces.el.demuxcompositeelresolver.getvalue(demuxcompositeelresolver.java:203) @ org.apache.el.parser.astidentifier.getvalue(astidentifier.java:71) @ org.apache.el.parser.astvalue.getvalue(astvalue.java:160) @ org.apache.el.valueexpressionimpl.getvalue(valueexpressionimpl.java:184) @ com.sun.faces.facelets.el.tagvalueexpression.getvalue(tagvalueexpression.java:109) @ javax.faces.component.componentstatehelper.eval(componentstatehelper.java:194) @ javax.faces.component.componentstatehelper.eval(componentstatehelper.java:182) @ javax.faces.component.uidata.getvalue(uidata.java:732) @ org.primefaces.component.datatable.datatable.getvalue(datatable.java:1002) @ org.primefaces.component.api.uidata.getdatamodel(uidata.java:629) @ javax.faces.component.uidata.getrowcount(uidata.java:356) @ org.primefaces.component.api.uidata.calculatefirst(uidata.java:175) @ org.primefaces.component.datatable.datatablerenderer.prerender(datatablerenderer.java:110) @ org.primefaces.component.datatable.datatablerenderer.encodeend(datatablerenderer.java:82) @ javax.faces.component.uicomponentbase.encodeend(uicomponentbase.java:924) @ javax.faces.component.uicomponent.encodeall(uicomponent.java:1863) @ javax.faces.render.renderer.encodechildren(renderer.java:176) @ javax.faces.component.uicomponentbase.encodechildren(uicomponentbase.java:894) @ javax.faces.component.uicomponent.encodeall(uicomponent.java:1856) @ javax.faces.component.uicomponent.encodeall(uicomponent.java:1859) @ javax.faces.component.uicomponent.encodeall(uicomponent.java:1859) @ com.sun.faces.application.view.faceletviewhandlingstrategy.renderview(faceletviewhandlingstrategy.java:443) @ com.sun.faces.application.view.multiviewhandler.renderview(multiviewhandler.java:131) @ com.sun.faces.lifecycle.renderresponsephase.execute(renderresponsephase.java:120) @ com.sun.faces.lifecycle.phase.dophase(phase.java:101) @ com.sun.faces.lifecycle.lifecycleimpl.render(lifecycleimpl.java:219) @ javax.faces.webapp.facesservlet.service(facesservlet.java:647) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:303) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:241) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:220) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:122) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:505) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:170) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:103) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:957) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:116) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:423) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1079) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:620) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:316) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) @ java.lang.thread.run(unknown source) 

any appreciated...

thanks guys. found error. grouping hibernate jars inside folder inside lib, below.

webcontent/web-inf/lib/hibernate-2/[list of required jars], below

hibernate jars folder

so moving jars directly under lib folder fixed problem. or think adding hibernate folder deployment assemply project properties fix problem also.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -