java - Cannot build Hibernate SessionFactory when calling from a Servlet -


i have vanilla tomcat simple java servlets set try persist person's info mysql database hibernate. application deploys properly, able hit servlet proper servlet-mapping cannot build sessionfactory access database.

stacktrace:

javax.servlet.servletexception: servlet execution threw exception     org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) caused by: java.lang.exceptionininitializererror     meetme.dao.dao.<clinit>(dao.java:23)     meetme.web.loginservlet.dopost(loginservlet.java:25)     javax.servlet.http.httpservlet.service(httpservlet.java:650)     javax.servlet.http.httpservlet.service(httpservlet.java:731)     org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) caused by: org.hibernate.boot.registry.classloading.spi.classloadingexception: unable load class [meetme.meeting.person]     org.hibernate.boot.registry.classloading.internal.classloaderserviceimpl.classforname(classloaderserviceimpl.java:232)     org.hibernate.boot.model.source.internal.annotations.annotationmetadatasourceprocessorimpl.<init>(annotationmetadatasourceprocessorimpl.java:103)     org.hibernate.boot.model.process.spi.metadatabuildingprocess$1.<init>(metadatabuildingprocess.java:147)     org.hibernate.boot.model.process.spi.metadatabuildingprocess.complete(metadatabuildingprocess.java:141)     org.hibernate.boot.model.process.spi.metadatabuildingprocess.build(metadatabuildingprocess.java:83)     org.hibernate.boot.internal.metadatabuilderimpl.build(metadatabuilderimpl.java:418)     org.hibernate.boot.internal.metadatabuilderimpl.build(metadatabuilderimpl.java:87)     org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:692)     org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:724)     meetme.dao.dao.<clinit>(dao.java:19)     meetme.web.loginservlet.dopost(loginservlet.java:25)     javax.servlet.http.httpservlet.service(httpservlet.java:650)     javax.servlet.http.httpservlet.service(httpservlet.java:731)     org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) caused by: java.lang.noclassdeffounderror: com/sun/javaws/exceptions/invalidargumentexception     java.lang.class.forname0(native method)     java.lang.class.forname(class.java:274)     org.hibernate.boot.registry.classloading.internal.classloaderserviceimpl.classforname(classloaderserviceimpl.java:226)     org.hibernate.boot.model.source.internal.annotations.annotationmetadatasourceprocessorimpl.<init>(annotationmetadatasourceprocessorimpl.java:103)     org.hibernate.boot.model.process.spi.metadatabuildingprocess$1.<init>(metadatabuildingprocess.java:147)     org.hibernate.boot.model.process.spi.metadatabuildingprocess.complete(metadatabuildingprocess.java:141)     org.hibernate.boot.model.process.spi.metadatabuildingprocess.build(metadatabuildingprocess.java:83)     org.hibernate.boot.internal.metadatabuilderimpl.build(metadatabuilderimpl.java:418)     org.hibernate.boot.internal.metadatabuilderimpl.build(metadatabuilderimpl.java:87)     org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:692)     org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:724)     meetme.dao.dao.<clinit>(dao.java:19)     meetme.web.loginservlet.dopost(loginservlet.java:25)     javax.servlet.http.httpservlet.service(httpservlet.java:650)     javax.servlet.http.httpservlet.service(httpservlet.java:731)     org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) caused by: java.lang.classnotfoundexception: com.sun.javaws.exceptions.invalidargumentexception     org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1722)     org.apache.catalina.loader.webappclassloader.loadclass(webappclassloader.java:1573)     java.lang.class.forname0(native method)     java.lang.class.forname(class.java:274)     org.hibernate.boot.registry.classloading.internal.classloaderserviceimpl.classforname(classloaderserviceimpl.java:226)     org.hibernate.boot.model.source.internal.annotations.annotationmetadatasourceprocessorimpl.<init>(annotationmetadatasourceprocessorimpl.java:103)     org.hibernate.boot.model.process.spi.metadatabuildingprocess$1.<init>(metadatabuildingprocess.java:147)     org.hibernate.boot.model.process.spi.metadatabuildingprocess.complete(metadatabuildingprocess.java:141)     org.hibernate.boot.model.process.spi.metadatabuildingprocess.build(metadatabuildingprocess.java:83)     org.hibernate.boot.internal.metadatabuilderimpl.build(metadatabuilderimpl.java:418)     org.hibernate.boot.internal.metadatabuilderimpl.build(metadatabuilderimpl.java:87)     org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:692)     org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:724)     meetme.dao.dao.<clinit>(dao.java:19)     meetme.web.loginservlet.dopost(loginservlet.java:25)     javax.servlet.http.httpservlet.service(httpservlet.java:650)     javax.servlet.http.httpservlet.service(httpservlet.java:731)     org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) 

here's servlet snippet:

protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {         string organizeremail = request.getparameter("email");          persondao dao = new persondao(); 

i static init of session factory in persondao parent abstract class:

protected static final sessionfactory sessionfactory;  static {     try {         configuration configuration = new configuration().configure();         sessionfactory = configuration.buildsessionfactory(); //<-- exception!     } catch (hibernateexception ex) {         system.err.println("initial sessionfactory creation failed. " + ex);         ex.printstacktrace();         throw new exceptionininitializererror(ex);     } } 

it's odd i'm getting classnotfoundexception com.sun.javaws.exceptions.invalidargumentexception when hit hibernate code. see read hibernate config file it's not path issue. doesn't seem able map person class use persisting data. threw quick standalone test make sure hibernate stuff solid:

public class maindaotest {     public static void main(string[] args) {         persondao dao = new persondao();         system.out.println(dao.getorganizerbyemail("asdf@asdf.com").getorganizerguid());     } } 

works great. connects db , pulls organizer person. here's mapped class, fyi:

@entity @table( name = "participants" ) public class person {      @id     @generatedvalue(strategy = generationtype.identity)     @column(name = "participantid")     private long participantid;     @column(name = "email", unique=true)     private string email;     @column(name = "name")     private string name;     @column(name = "guid")     private string organizerguid;      public person(string name, string email) {         this.name = name;         this.email = email;     }      protected person() {         this.name = null;         this.email = null;     }      public person(string name, string email, string id) {         this(name, email);         this.organizerguid = id;     }      // getters , setters...  } 

hibernate config:

<hibernate-configuration>     <session-factory>         <property name="hibernate.dialect">org.hibernate.dialect.mysqldialect</property>         <property name="connection.driver_class">com.mysql.jdbc.driver</property>          <!-- database connection details -->         <property name="hibernate.connection.url">jdbc:mysql://my.url.com</property>         <property name="hibernate.connection.username">user</property>         <property name="hibernate.connection.password">pass</property>          <!-- jdbc connection pool (use built-in) -->         <property name="connection.pool_size">1</property>         <property name="current_session_context_class">thread</property>          <mapping class="meetme.meeting.person" />     </session-factory> </hibernate-configuration> 

edit: here's library list module in intellij in case versions clashing:

module's classpath

let me know if there's else can post setup may shed more light on issue. similar question (java - hibernate exception - feedback cannot mapped [ feedback ]) have class mapping in config.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -