java - JBoss Hibernate Unable to locate persister error -
i've run bit of trouble again after fixing previous issue. tried many common fixes none seems working me. here relevant files project:
hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?> <!doctype hibernate-configuration public "-//hibernate/hibernate configuration dtd 3.0//en" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/accountdb</property> <property name="connection.username">root</property> <property name="connection.password">pass</property> <!-- hibernate properties --> <property name="show_sql">true</property> <property name="dialect">org.hibernate.dialect.mysqldialect</property> <property name="hbm2ddl.auto">update</property> <!-- mapping files --> <mapping resource="com/gto/test/account.hbm.xml"/> </session-factory> </hibernate-configuration>
persistence.xml
<?xml version="1.0" encoding="utf-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="testejb3project"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <class>com.gto.test.account</class> </persistence-unit>
account.hbm.xml
<?xml version="1.0"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.gto.test.account" table="account"> <id name="id" column="id"> <generator class="increment" /> </id> <property name="accesscount" column="accesscount"/> </class> </hibernate-mapping>
account.java
package com.gto.test; import java.io.serializable; import javax.persistence.*; import java.util.list; @entity @table(name="account") @namedquery(name="account.findall", query="select account a") public class account implements serializable { private static final long serialversionuid = 1l; @id private int id; private int accesscount; //bi-directional many-to-one association accountaccesslog @onetomany(mappedby="account") private list<accountaccesslog> accountaccesslogs; public account() { } public int getid() { return this.id; } public void setid(int id) { this.id = id; } public int getaccesscount() { return this.accesscount; } public void setaccesscount(int accesscount) { this.accesscount = accesscount; } public list<accountaccesslog> getaccountaccesslogs() { return this.accountaccesslogs; } public void setaccountaccesslogs(list<accountaccesslog> accountaccesslogs) { this.accountaccesslogs = accountaccesslogs; } public accountaccesslog addaccountaccesslog(accountaccesslog accountaccesslog) { getaccountaccesslogs().add(accountaccesslog); accountaccesslog.setaccount(this); return accountaccesslog; } public accountaccesslog removeaccountaccesslog(accountaccesslog accountaccesslog) { getaccountaccesslogs().remove(accountaccesslog); accountaccesslog.setaccount(null); return accountaccesslog; } }
server log
12:58:58,694 warn [org.hibernate.orm.connections] (ejb default - 1) hhh10001002: using hibernate built-in connection pool (not production use!) 12:58:58,698 info [org.hibernate.orm.connections] (ejb default - 1) hhh10001005: using driver [com.mysql.jdbc.driver] @ url [jdbc:mysql://localhost:3306/accountdb] 12:58:58,699 info [org.hibernate.orm.connections] (ejb default - 1) hhh10001001: connection properties: {user=root, password=****} 12:58:58,699 info [org.hibernate.orm.connections] (ejb default - 1) hhh10001003: autocommit mode: false 12:58:58,701 info [org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl] (ejb default - 1) hhh000115: hibernate connection pool size: 20 (min=1) 12:58:58,847 info [org.jboss.as] (controller boot thread) wflysrv0060: http management interface listening on http://127.0.0.1:9990/management 12:58:58,847 info [org.jboss.as] (controller boot thread) wflysrv0051: admin console listening on http://127.0.0.1:9990 12:58:58,847 info [org.jboss.as] (controller boot thread) wflysrv0025: jboss eap 7.0.0.ga (wildfly core 2.1.2.final-redhat-1) started in 5746ms - started 401 of 670 services (379 services lazy, passive or on-demand) 12:58:58,860 error [stderr] (ejb default - 1) thu jul 28 12:58:58 ist 2016 warn: establishing ssl connection without server's identity verification not recommended. according mysql 5.5.45+, 5.6.26+ , 5.7.6+ requirements ssl connection must established default if explicit option isn't set. compliance existing applications not using ssl verifyservercertificate property set 'false'. need either explicitly disable ssl setting usessl=false, or set usessl=true , provide truststore server certificate verification. 12:58:58,930 info [org.hibernate.dialect.dialect] (ejb default - 1) hhh000400: using dialect: org.hibernate.dialect.mysql5dialect 12:58:58,949 info [org.hibernate.envers.boot.internal.enversserviceimpl] (ejb default - 1) envers integration enabled? : true 12:58:58,957 info [org.hibernate.tool.hbm2ddl.schemaupdate] (ejb default - 1) hhh000228: running hbm2ddl schema update 12:58:59,000 error [org.jboss.as.ejb3] (ejb default - 1) wflyejb0020: error invoking timeout timer: [id=e4f1edcd-d8cb-4f38-9a17-78df26ccc2ea timedobjectid=testejb3project.testejb3project.timerbean auto-timer?:true persistent?:true timerservice=org.jboss.as.ejb3.timerservice.timerserviceimpl@5550bd initialexpiration=null intervalduration(in milli sec)=0 nextexpiration=thu jul 28 12:59:00 ist 2016 timerstate=in_timeout info=calls accountaccessbean every 30 seconds]: javax.ejb.ejbexception: org.hibernate.unknownentitytypeexception: unable locate persister: com.gto.test.account @ org.jboss.as.ejb3.tx.cmttxinterceptor.handleexceptioninourtx(cmttxinterceptor.java:187) @ org.jboss.as.ejb3.tx.timercmttxinterceptor.handleexceptioninourtx(timercmttxinterceptor.java:53) @ org.jboss.as.ejb3.tx.cmttxinterceptor.invokeinourtx(cmttxinterceptor.java:277) @ org.jboss.as.ejb3.tx.cmttxinterceptor.required(cmttxinterceptor.java:327) @ org.jboss.as.ejb3.tx.cmttxinterceptor.processinvocation(cmttxinterceptor.java:239) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.as.ejb3.component.interceptors.currentinvocationcontextinterceptor.processinvocation(currentinvocationcontextinterceptor.java:41) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.as.ejb3.security.securitycontextinterceptor.processinvocation(securitycontextinterceptor.java:100) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.as.ejb3.component.interceptors.shutdowninterceptorfactory$1.processinvocation(shutdowninterceptorfactory.java:64) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.as.ee.component.namespacecontextinterceptor.processinvocation(namespacecontextinterceptor.java:50) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.as.ejb3.component.interceptors.additionalsetupinterceptor.processinvocation(additionalsetupinterceptor.java:54) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.invocation.contextclassloaderinterceptor.processinvocation(contextclassloaderinterceptor.java:64) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.invocation.interceptorcontext.run(interceptorcontext.java:356) @ org.wildfly.security.manager.wildflysecuritymanager.dochecked(wildflysecuritymanager.java:636) @ org.jboss.invocation.accesscheckinginterceptor.processinvocation(accesscheckinginterceptor.java:61) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.invocation.interceptorcontext.run(interceptorcontext.java:356) @ org.jboss.invocation.privilegedwithcombinerinterceptor.processinvocation(privilegedwithcombinerinterceptor.java:80) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.invocation.chainedinterceptor.processinvocation(chainedinterceptor.java:61) @ org.jboss.as.ejb3.timerservice.timedobjectinvokerimpl.calltimeout(timedobjectinvokerimpl.java:99) @ org.jboss.as.ejb3.timerservice.calendartimertask.invokebeanmethod(calendartimertask.java:64) @ org.jboss.as.ejb3.timerservice.calendartimertask.calltimeout(calendartimertask.java:53) @ org.jboss.as.ejb3.timerservice.timertask.run(timertask.java:155) @ org.jboss.as.ejb3.timerservice.timerserviceimpl$task$1.run(timerserviceimpl.java:1214) @ org.wildfly.extension.requestcontroller.requestcontroller$queuedtask$1.run(requestcontroller.java:497) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) @ org.jboss.threads.jbossthread.run(jbossthread.java:320) caused by: org.hibernate.unknownentitytypeexception: unable locate persister: com.gto.test.account @ org.hibernate.internal.sessionfactoryimpl.locateentitypersister(sessionfactoryimpl.java:797) @ org.hibernate.internal.sessionimpl.locateentitypersister(sessionimpl.java:2710) @ org.hibernate.internal.sessionimpl.access$2500(sessionimpl.java:164) @ org.hibernate.internal.sessionimpl$identifierloadaccessimpl.<init>(sessionimpl.java:2648) @ org.hibernate.internal.sessionimpl$identifierloadaccessimpl.<init>(sessionimpl.java:2635) @ org.hibernate.internal.sessionimpl.byid(sessionimpl.java:1102) @ org.hibernate.internal.sessionimpl.get(sessionimpl.java:975) @ com.gto.test.accountaccessbean.resigteraccountevent(accountaccessbean.java:47) @ com.gto.test.timerbean.scheduledtimeout(timerbean.java:29) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.jboss.as.ee.component.managedreferencemethodinterceptor.processinvocation(managedreferencemethodinterceptor.java:52) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.invocation.weavedinterceptor.processinvocation(weavedinterceptor.java:57) @ org.jboss.as.ee.component.interceptors.userinterceptorfactory$1.processinvocation(userinterceptorfactory.java:61) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.invocation.interceptorcontext$invocation.proceed(interceptorcontext.java:437) @ org.jboss.as.weld.ejb.jsr299bindingsinterceptor.domethodinterception(jsr299bindingsinterceptor.java:82) @ org.jboss.as.weld.ejb.jsr299bindingsinterceptor.processinvocation(jsr299bindingsinterceptor.java:95) @ org.jboss.as.ee.component.interceptors.userinterceptorfactory$1.processinvocation(userinterceptorfactory.java:61) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.invocation.weavedinterceptor.processinvocation(weavedinterceptor.java:57) @ org.jboss.as.ee.component.interceptors.userinterceptorfactory$1.processinvocation(userinterceptorfactory.java:61) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.as.jpa.interceptor.sbinvocationinterceptor.processinvocation(sbinvocationinterceptor.java:47) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.invocation.interceptorcontext$invocation.proceed(interceptorcontext.java:437) @ org.jboss.weld.ejb.abstractejbrequestscopeactivationinterceptor.aroundinvoke(abstractejbrequestscopeactivationinterceptor.java:73) @ org.jboss.as.weld.ejb.ejbrequestscopeactivationinterceptor.processinvocation(ejbrequestscopeactivationinterceptor.java:83) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.as.ee.concurrent.concurrentcontextinterceptor.processinvocation(concurrentcontextinterceptor.java:45) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.invocation.initialinterceptor.processinvocation(initialinterceptor.java:21) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.invocation.chainedinterceptor.processinvocation(chainedinterceptor.java:61) @ org.jboss.as.ee.component.interceptors.componentdispatcherinterceptor.processinvocation(componentdispatcherinterceptor.java:52) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.as.ejb3.component.pool.pooledinstanceinterceptor.processinvocation(pooledinstanceinterceptor.java:51) @ org.jboss.invocation.interceptorcontext.proceed(interceptorcontext.java:340) @ org.jboss.as.ejb3.tx.cmttxinterceptor.invokeinourtx(cmttxinterceptor.java:275) ... 33 more
i've been stuck setting hibernate while now, appreciated.
fixed it! used addannotatedclass() method while building sessionfactory in bean uses hibernate access database. here's entire code:
accountaccessbean.java
@stateless(mappedname = "accountaccessbean") @localbean public class accountaccessbean { public void resigteraccountevent() { configuration configuration = new configuration().configure(); serviceregistry registry = new standardserviceregistrybuilder() .applysettings(configuration.getproperties()) .build(); sessionfactory sessionfactory = configuration .addannotatedclass(account.class) .addannotatedclass(accountaccesslog.class) .buildsessionfactory(registry); session session = sessionfactory.opensession(); session.begintransaction(); account accountentity = (account) session.get(account.class, new integer(1)); system.out.println(accountentity.getid()); } }
Comments
Post a Comment