I'm Using JBoss applcation server with Hibernate..
when ever I started the server I'm getting the exception stating
Duplicate Import and the Browser gives Blank page . This happens only at startup and after refreshing the page one or two time the desired values are displayed.
I'm giving the full stack trace:
10:51:04,406 INFO [Environment] Hibernate 2.1.2
10:51:04,422 INFO [Environment] loaded properties from resource hibernate.properties: {hibernate.transaction.manager_loo
kup_class=net.sf.hibernate.transaction.JBossTransactionManagerLookup, hibernate.cglib.use_reflection_optimizer=true, hibe
rnate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTA
TransactionFactory, hibernate.connection.datasource=java:/transera_phase1_db}
10:51:04,438 INFO [Environment] using CGLIB reflection optimizer
10:51:04,625 INFO [Configuration] Mapping resource: com/transerainc/provisioning/common/db/Address.hbm.xml
10:51:04,969 INFO [Binder] Mapping class: com.transerainc.provisioning.common.db.Address -> address_mst
10:51:05,406 INFO [Configuration] Mapping resource: com/transerainc/provisioning/common/db/Contact.hbm.xml
10:51:05,453 INFO [Binder] Mapping class: com.transerainc.provisioning.common.db.Contact -> contact_mst
10:51:05,453 INFO [Configuration] Mapping resource: com/transerainc/provisioning/common/db/Team.hbm.xml
10:51:05,531 INFO [Binder] Mapping class: com.transerainc.provisioning.common.db.Team -> team_mst
10:51:05,531 INFO [Configuration] Mapping resource: com/transerainc/provisioning/common/db/Tenant.hbm.xml
10:51:05,672 INFO [Binder] Mapping class: com.transerainc.provisioning.common.db.Tenant -> tenant_mst
10:51:05,672 INFO [Configuration] Mapping resource: com/transerainc/provisioning/common/db/TenantType.hbm.xml
10:51:05,891 INFO [Binder] Mapping class: com.transerainc.provisioning.common.db.TenantType -> tenant_type
10:51:05,891 INFO [Configuration] Mapping resource: com/transerainc/provisioning/common/db/VirtualTeam.hbm.xml
10:51:05,985 INFO [Binder] Mapping class: com.transerainc.provisioning.common.db.VirtualTeam -> virtual_team_mst
10:51:05,985 INFO [Configuration] Mapping resource: com/transerainc/provisioning/common/db/Site.hbm.xml
10:51:06,047 INFO [Binder] Mapping class: com.transerainc.provisioning.common.db.Site -> site_mst
10:51:06,047 INFO [Configuration] Mapping resource: com/transerainc/provisioning/common/db/DnToTeamMapping.hbm.xml
10:51:06,156 INFO [Binder] Mapping class: com.transerainc.provisioning.common.db.DnToTeamMapping -> cds_dn_to_team_mappi
ng_mst
10:51:06,172 INFO [Configuration] Mapping resource: com/transerainc/provisioning/common/db/ServerMappingStore.hbm.xml
10:51:06,438 INFO [Binder] Mapping class: com.transerainc.provisioning.common.db.ServerMappingStore -> SERVER_MAPPING_MS
T
10:51:06,531 INFO [Configuration] Mapping resource: com/transerainc/provisioning/common/db/PopMappingStore.hbm.xml
10:51:06,563 INFO [Configuration] Mapping resource: com/transerainc/provisioning/common/db/Address.hbm.xml
10:51:06,594 ERROR [Configuration] Could not compile the mapping document
net.sf.hibernate.MappingException: duplicate import: Address
at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1229)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:249)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:285)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:333)
at com.transerainc.provisioning.common.db.HibernateSession.loadClasses(HibernateSession.java:92)
at com.transerainc.provisioning.common.db.HibernateSession.currentSession(HibernateSession.java:40)
at com.transerainc.provisioning.common.db.BaseDAO.retrieveObjs(BaseDAO.java:164)
at com.transerainc.provisioning.common.db.EnterpriseDAO.getEnterprises(EnterpriseDAO.java:15)
at org.apache.jsp.createTree_005fnew_jsp._jspService(createTree_005fnew_jsp.java:69)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.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(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.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(StandardValveContext.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.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
10:51:06,875 INFO [STDOUT] Mar 17, 2005 10:51:06 AM com.transerainc.provisioning.common.db.HibernateSession loadClasses
WARNING: Problem while loading classes : Error reading resource: com/transerainc/provisioning/common/db/Address.hbm.xml
10:51:06,891 INFO [STDOUT] Mar 17, 2005 10:51:06 AM com.transerainc.provisioning.common.db.HibernateSession currentSessi
on
SEVERE: Error Creating SessionFactory : Error reading resource: com/transerainc/provisioning/common/db/Address.hbm.xml
10:51:06,906 INFO [Binder] Mapping class: com.transerainc.provisioning.common.db.PopMappingStore -> POP_MAPPING_MST
10:51:06,922 INFO [Configuration] processing one-to-many association mappings
10:51:06,922 INFO [Configuration] processing one-to-one association property references
10:51:06,938 INFO [Configuration] processing foreign key constraints
10:51:06,938 INFO [STDOUT] com.transerainc.provisioning.common.db.DAOException: Error reading resource: com/transerainc/
provisioning/common/db/Address.hbm.xml wraps: [net.sf.hibernate.MappingException: Error reading resource: com/transerainc
/provisioning/common/db/Address.hbm.xml]
10:51:06,953 INFO [STDOUT] at com.transerainc.provisioning.common.db.HibernateSession.loadClasses(HibernateSession.j
ava:97)
10:51:06,953 INFO [STDOUT] at com.transerainc.provisioning.common.db.HibernateSession.currentSession(HibernateSessio
n.java:40)
10:51:06,969 INFO [STDOUT] at com.transerainc.provisioning.common.db.BaseDAO.retrieveObjs(BaseDAO.java:164)
10:51:06,969 INFO [STDOUT] at com.transerainc.provisioning.common.db.EnterpriseDAO.getEnterprises(EnterpriseDAO.java
:15)
10:51:07,016 INFO [STDOUT] at org.apache.jsp.createTree_005fnew_jsp._jspService(createTree_005fnew_jsp.java:69)
10:51:07,016 INFO [STDOUT] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
10:51:07,016 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
10:51:07,031 INFO [STDOUT] at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
10:51:07,031 INFO [STDOUT] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
10:51:07,031 INFO [STDOUT] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
10:51:07,078 INFO [STDOUT] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
10:51:07,078 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChai
n.java:237)
10:51:07,094 INFO [STDOUT] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:1
57)
10:51:07,094 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
10:51:07,110 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104
)
10:51:07,110 INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
10:51:07,156 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java
:198)
10:51:07,156 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
10:51:07,172 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104
)
10:51:07,172 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve
.java:72)
10:51:07,188 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102
)
10:51:07,203 INFO [STDOUT] at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:
275)
10:51:07,235 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102
)
10:51:07,235 INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
10:51:07,250 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
10:51:07,250 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104
)
10:51:07,266 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
10:51:07,266 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102
)
10:51:07,297 INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
10:51:07,297 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
10:51:07,297 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104
)
10:51:07,313 INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
10:51:07,313 INFO [STDOUT] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
10:51:07,313 INFO [STDOUT] at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
10:51:07,328 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
10:51:07,328 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http
11Protocol.java:705)
10:51:07,344 INFO [STDOUT] at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
10:51:07,344 INFO [STDOUT] at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
10:51:07,360 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)
10:51:07,360 INFO [STDOUT] net.sf.hibernate.MappingException: Error reading resource: com/transerainc/provisioning/commo
n/db/Address.hbm.xml
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:336)
at com.transerainc.provisioning.common.db.HibernateSession.loadClasses(HibernateSession.java:92)
at com.transerainc.provisioning.common.db.HibernateSession.currentSession(HibernateSession.java:40)
at com.transerainc.provisioning.common.db.BaseDAO.retrieveObjs(BaseDAO.java:164)
at com.transerainc.provisioning.common.db.EnterpriseDAO.getEnterprises(EnterpriseDAO.java:15)
at org.apache.jsp.createTree_005fnew_jsp._jspService(createTree_005fnew_jsp.java:69)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.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(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.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(StandardValveContext.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.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: net.sf.hibernate.MappingException: duplicate import: Address
at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1229)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:249)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:285)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:333)
... 39 more
10:51:07,610 INFO [STDOUT] net.sf.hibernate.MappingException: Error reading resource: com/transerainc/provisioning/commo
n/db/Address.hbm.xml
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:336)
at com.transerainc.provisioning.common.db.HibernateSession.loadClasses(HibernateSession.java:92)
at com.transerainc.provisioning.common.db.HibernateSession.currentSession(HibernateSession.java:40)
at com.transerainc.provisioning.common.db.BaseDAO.retrieveObjs(BaseDAO.java:164)
at com.transerainc.provisioning.common.db.EnterpriseDAO.getEnterprises(EnterpriseDAO.java:15)
at org.apache.jsp.createTree_005fnew_jsp._jspService(createTree_005fnew_jsp.java:69)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.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(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.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(StandardValveContext.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.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: net.sf.hibernate.MappingException: duplicate import: Address
at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1229)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:249)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:285)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:333)
... 39 more
I'm giving the HibernateSession.java file
package com.transerainc.provisioning.common.db;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.MappingException;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
This class is used to get a ThreadLocal instance of the Session class.
This design pattern is documented at:
<a href="http://www.hibernate.org/42.html">http://www.hibernate.org/42.html</a>
@author <a href="mailto:nick@systemmobile.com">Nick Heudecker</a>
*/
public class HibernateSession {
private static Logger lgr = Logger
.getLogger("com.transerainc.provisioning.common.db.HibernateSession");
/**
Returns the ThreadLocal Session instance. This method will initialize
the <code>SessionFactory</code> if necessary.
@return Session
@throws DAOException
*/
public static Session currentSession() throws DAOException {
Session s = (Session) session.get();
try {
if(s == null ) {
if (sf == null) {
try {
loadClasses();
sf = cfg.buildSessionFactory();
}
catch(Exception e) {
//System.err.println("%%%% Error Creating SessionFactory %%%%");
lgr.severe("Error Creating SessionFactory : "+ e.getMessage());
e.printStackTrace();
}
}
s = sf.openSession();
session.set(s);
}
}
catch (HibernateException he) {
throw new DAOException(he);
}
return s;
}
/**
Closes the session object.
@throws DAOException
*/
public static void closeSession() throws DAOException {
Session s = (Session) session.get();
session.set(null);
if(s != null) {
try {
s.close();
}
catch (HibernateException he) {
throw new DAOException(he);
}
}
}
/**
Loads the mapping documents for the persistent classes.
@throws DAOException if there is a problem with the
mapping docs
*/
private static void loadClasses() throws DAOException {
Class[] classes = new Class[] {Address.class,Contact.class,Team.class,Tenant.class,TenantType.class,VirtualTeam.class,Site.class, DnToTeamMapping.class, ServerMappingStore.class, PopMappingStore.class};
for (int i = 0; i<classes.length; i++) {
try {
cfg.addClass(classes[i]);
}
catch (MappingException me) {
//System.out.println("inside classes*********************************");
lgr.warning("Problem while loading classes : "+ me.getMessage());
throw new DAOException(me);
}
}
}
public static final ThreadLocal session = new ThreadLocal();
private static final Configuration cfg = new Configuration();
private static SessionFactory sf;
}
In this file I'm adding a set of ten classes to configuration()
|