java


Class not found exception in jsf hibernate application


Just I started learning hibernate with jsf, a sample applications created by myself. I am getting class not found exception(i.e POJO class ) and below are the my code, please help me in coding.
HibernateBean is my POJO class
package com.bectran.employee;
public class HibernateBean {
private int id;
private String userName;
private String passwd;
public HibernateBean() {
// TODO Auto-generated constructor stub
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPasswd() {
return passwd;
}
public void setPasswd(String passwd) {
this.passwd = passwd;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
Connection class
package com.bectran.employee;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
public class LoginMain {
public LoginMain() {
// TODO Auto-generated constructor stub
}
public static void save1(){
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");
ServiceRegistryBuilder registry = new ServiceRegistryBuilder();
registry.applySettings(cfg.getProperties());
ServiceRegistry serviceRegistry = registry.buildServiceRegistry();
SessionFactory sessionFactory = cfg.buildSessionFactory(serviceRegistry);
Session session = sessionFactory.openSession();
HibernateBean hb=new HibernateBean();
Transaction tx = session.beginTransaction();
session.save(hb);
System.out.println("Object saved successfully.....!!");
tx.commit();
session.close();
sessionFactory.close();
}
}
hbm file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.bectran.employee.HibernateBean" table="logintable">
<id name="id" column="id">
<generator class="assigned" />
</id>
<property name="userName" type="String" column="username" />
<property name="passwd" type="String" column="pass" />
</class>
</hibernate-mapping>
cfg.xml file
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/testdb</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="com/bectran/employee/HibernateBean.hbm.xml" ></mapping>
</session-factory>
</hibernate-configuration>
home.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:body>
<h1><marquee>Login Page</marquee></h1>
<h:form>
UserName : <h:inputText value="#{userBean.userName}" />
Password : <h:inputSecret value="#{userBean.passwd}" />
<h:commandButton value="Submit" action="#{loginBean.save1}" />
</h:form>
</h:body>
</html>

Related Links

How do I invalidate a login session initialized in one servlet in another servlet with a href in between?
Values are overriden in my ArrayList [duplicate]
Insert Template by Placeholder
Changing database in eclipse/hibernate project
Android Audio Not Playing
org.hibernate.exception.LockAcquisitionException - Threads
currentThread() is always the currentThread()?
Java Database Connectivity doesn't work
Why non-volatile approach works?
Enable Spring Expression Language when using custom FilterSecurityInterceptor
Having trouble with installing Apache Tomcat 8.0.9 in eclipse kepler
How can I compare the speed of the various caching frameworks?
Add cookie from controller having #ResponseBody annotation in spring
How to change the location of compiled code to WAR file in maven
How to add and use all the different JDK versions in netbean?
Android how to speed up reading from a file to create Java objects using Buffered Input/Output?

Categories

HOME
wso2
deployment
vbscript
azure-data-factory
fluentd
mockito
ngrx
alfresco
routes
infragistics
sharepoint-designer
webpack-2
angular-ui-bootstrap
wamp
in-app-purchase
webrequest
primary-key
spring-kafka
midi
modelica
leiningen
orchardcms
event-handling
progressive-web-apps
django-admin
propel
evopdf
physics-engine
spark-jobserver
url-scheme
jspm
primitive
google-sites-2016
y86
disassembling
withings
az-application-insights
webix-treetable
unobtrusive-validation
leading-zero
graphenedb
node-sass
angular2-meteor
cubic-spline
azure-application-gateway
theming
jlink
togetherjs
drupal-6
nodebb
typed-lambda-calculus
qtwebview
imanage
webdriverjs
gnome-shell-extensions
yt-project
nested-sets
underscore.js-templating
asp.net-4.5
google-web-starter-kit
fputcsv
ready-api
qgraphicsview
whois
apachebench
bluegiga
independentsoft
browser-link
intel-fortran
feedback
emailrelay
android-listview
responsive-images
fluid-dynamics
ami
iiviewdeckcontroller
pretty-print
umbraco6
dia
tt-news
openexr
hippomocks
comexception
undefined-reference
geos
ms-project-server-2010
cos
mqx
lcs
path-separator
quickdialog
pysimplesoap
errai
dotnethighcharts
fireworks
data-loss
infobox
joyent
xmemcached
yetanotherforum
appendto
anti-piracy
w3wp
grid-system
wsdl.exe
3gp

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App