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 to sort dates in a string array in Java?
How to set integer value ranging from 1000 to 9999 in Java? [closed]
Getting the value of a selected listview
Edittext to ratingbar in Android
Checking and breaking out of a do-while loop
Text on Button not visible on Button Android layout
How to sort a Linked List based in one word of the String java
Java how to read from an InputStream the incomed size? [duplicate]
Eclipse breakpoint
Unit test for for a calss with Annotation checks using mocking
Which performs better : for each or iterator in LinkedList?
What is difference between Accesss Modifiers and Access Specifiers [duplicate]
Composing Spring test configuration instead of inheriting it?
Count Words Function not giving correct answers
Netbeans GlassFish Server 4, deploy, Connection refused: connect, false , The module has not been deployed. See the server log for details
convert milliseconds to seconds, minutes without rounding

Categories

HOME
google-chrome-extension
wso2-am
debugging
zeromq
mediawiki
dictionary
mean-stack
yarn
cross-browser
ios-charts
gitpitch
cloudkit
node-pdfkit
spring-xd
export-to-csv
resize
zend-framework3
task
orchardcms
dynamics-crm-online
workload-scheduler
opentracing
footer
aurigma
dbext
ml
xlsxwriter
scriptcs
tibco-mdm
h2db
poltergeist
internet-explorer-9
rst2pdf
maxmind
fluentvalidation
maquette
ping
saas
primitive
react-chartjs
bosh
http-status-code-503
contact-form
catel
calibre
jna
document.write
email-templates
pdf-reactor
isbn
midl
netcdf4
s
flickr-api
dotcover
azure-application-gateway
apache-fop
ionicons
pebble-watch
return-value
statsd
directory-structure
typed-lambda-calculus
nsarray
knpmenubundle
pdfclown
chord-diagram
smart-table
gnome-shell-extensions
objective-c-swift-bridge
deadbolt-2
log4c
disque
hexdump
photobucket
historian
ford-fulkerson
jfugue
intellij-14
comobject
iis-arr
twirl
sysinternals
unity5.2.3
system.reflection
operator-precedence
tween
typekit
c3
device-manager
document-classification
terminfo
dealloc
mqx
dmoz
labwindows
ticoredatasync
qtkit
nsdatecomponents
mercurial-server
gnu-prolog
joyent
invite
w3wp.exe
phonon
project-hosting
paul-graham
ajax-forms

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