mysql - ClassNotFoundException using Play2 + Hibernate -


i new jvm-based world , trying build test webservice using scala, play 2 framework , hibernate. problem hibernate configuration. hibernate.cfg.xml looks this:

<?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-configuration system         "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">  <hibernate-configuration>     <session-factory>         <property name="hibernate.dialect">             org.hibernate.dialect.mysqldialect         </property>         <property name="hibernate.connection.driver_class">             com.mysql.jdbc.driver         </property>          <property name="hibernate.connection.url">             jdbc:mysql://localhost/parking-webservice         </property>         <property name="hibernate.connection.username">             root         </property>         <property name="hibernate.connection.password">             root         </property>          <mapping resource="hibernate.hbm.xml" package="models"/>      </session-factory> </hibernate-configuration> 

and hibernate.hbm.xml looks this:

 <?xml version='1.0' encoding='utf-8'?>     <!doctype hibernate-mapping public         "-//hibernate/hibernate mapping dtd 3.0//en"         "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">     <hibernate-mapping package="models">          <class name="server" table="load_balancer_server" schema="parking-webservice">             <id name="id" column="id"/>             <property name="url" column="url"/>         </class>         <class name="platerecognitionlogentry" table="log_platerecognitionlogentry" schema="parking-webservice">             <id name="id" column="id"/>             <property name="platenumber" column="plate_number"/>             <property name="confidence" column="confidence"/>             <property name="countrytype" column="country_type"/>             <property name="time" column="time"/>             <property name="image" column="image"/>             <property name="ipaddress" column="ip_address"/>         </class>         <class name="user" table="parking_auth_user" schema="parking-webservice">             <id name="id" column="id"/>             <property name="token" column="token"/>             <property name="admin" column="admin"/>             <property name="username" column="username"/>         </class>     </hibernate-mapping> 

intellij idea has generated play 2 project me. had controllers , views directories inside app directory. have created models package there , added classes there. 1 of classes looks (generated java code converted scala):

package models class server {   private var id: int = 0   private var url: string = null    def getid: int = id    def setid(id: int) {     this.id = id   }    def geturl: string = url    def seturl(url: string) {     this.url = url   }    override def hashcode: int = {     var result: int = id     result = 31 * result + (if (url != null) url.hashcode else 0)     result   } } 

what trying in controller:

object application extends controller {   private val _configuration = (new configuration()).configure()   private val _serviceregistry = new serviceregistrybuilder().applysettings(_configuration.getproperties).buildserviceregistry()   private val _sessionfactory = _configuration.buildsessionfactory(_serviceregistry)    def sessionfactory = _sessionfactory    def server_get = action { request =>     val session = sessionfactory.opensession     val query = session.createquery("from session")     val servers: seq[server] = scala.asscala(query.list).map({case d: server => d})     val responselist = servers.map(s => s.geturl)     val result = json.newobject     result.set("servers", json.tojson(responselist))     ok(result.tostring)   } } 

and getting exception:

play.api.http.httperrorhandlerexceptions$$anon$1: execution exception[[exceptionininitializererror: null]] ...<unuseful stack trace>... caused by: java.lang.exceptionininitializererror: null ...<more stack trace>... caused by: org.hibernate.invalidmappingexception: not parse mapping document resource hibernate.hbm.xml ...<stack trace refers (new configuration()).configure() call>... caused by: org.hibernate.mappingexception: class models.server not found while looking property: id ...<more stack trace>... caused by: java.lang.classnotfoundexception: models.server ...<stack trace says urlclassloader.findclass failed>... 

i have tried removing package attribute .hbm.cfg , adding qualified class names, e.g., models.server, no success, getting same error. either don't know qualified name play 2 classes or there different thing doing wrong.

any appreciated


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -