Hi all
I have used hibernate3.jar and i wrote a DAO to persist data into MySql database.
I am using Jboss-4.0.0 and i have written the hibernate.cfg.xml file and is stored in the WEB-INF/classes.
I code of my DAO is as follows:--
try{
System.out.println("************Hello World 1************");
config = new Configuration().configure();
System.out.println("************Hello World 2************");
config.addClass(UserDataBO.class);
System.out.println("************Hello World 3************");
sessionFactory = config.buildSessionFactory();
System.out.println("************Hello World 4******************");
session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
System.out.println("************Creating transaction*************");
session.save(userData);
session.flush();
tx.commit();
System.out.println("**************Committing**************");
session.close();
}
*************************************************************
I get an error on the Jboss console when i enter data and click onsubmit on the page, the error is as follows:--
15:42:20,078 INFO [STDOUT] ************Hello World 1************
15:42:20,093 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
15:42:20,093 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
15:42:20,109 INFO [Configuration] Mapping resource: com/businessobjects/UserDataBO.hbm
.xml
15:42:20,109 INFO [HbmBinder] Mapping class: com.businessobjects.UserDataBO -> user
15:42:20,125 INFO [Configuration] Configured SessionFactory: ehaa
15:42:20,125 INFO [STDOUT] ************Hello World 2************
15:42:20,125 INFO [Configuration] Mapping resource: com/businessobjects/UserDataBO.hbm
.xml
15:42:20,125 ERROR [Configuration] Could not compile the mapping document
org.hibernate.MappingException: duplicate import: com.businessobjects.UserDataBO
at org.hibernate.cfg.Mappings.addImport(Mappings.java:100)
at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:5
38)
at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:485)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:231)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:149)
at org.hibernate.cfg.Configuration.add(Configuration.java:358)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:395)
at org.hibernate.cfg.Configuration.addClass(Configuration.java:463)
at com.dao.RegisterDAO.registerUser(RegisterDAO.java:60)
at com.actions.RegisterAction.execute(RegisterAction.java:64)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProces
sor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.ja
va:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext
Valve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalVal
ve.java:44)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssoci
ationValve.java:169)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137
)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118
)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:683)
at java.lang.Thread.run(Thread.java:534)
15:42:20,125 INFO [STDOUT] Hibernate Exception :Error reading resource: com/businessob
jects/UserDataBO.hbm.xml
*************************************************************
I even tried using the hibernate.properties in the place of hibenate.cfg.xml fine but still no gain.
If some one could guide me through this it would be really great.
A thousand thanks in advance.
With Regards
S.R.K.Vivek Raju.
|