-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate Session Factories
PostPosted: Thu Jun 16, 2005 11:24 am 
Beginner
Beginner

Joined: Wed Jun 01, 2005 6:51 pm
Posts: 27
Location: Philippines
Hibernate version:2.1.6

Just when I thought we had it, the wsabi SessionFactory is now reading from a hibernate.cfg.xml and setting a datasource defined in the webapp's context but when it tries to instantiate the Session the Liferay DSConnectionProvider intercepts and fails.

How do I configure a webapp to use hibernate Session Factories alongside Liferay? My goal is to create a wsabi portlet for the Liferay portal.

Here is the context:
Code:
<Context path="/wsabi4axis" docBase="../webapps/wsabi4axis" debug="99" reloadable="true" crossContext="true">
   <Resource name="jdbc/wsabi4axis" auth="Container" type="javax.sql.DataSource" />
   <ResourceParams name="jdbc/wsabi4axis">
      <parameter>
         <name>driverClassName</name>
         <value>org.hsqldb.jdbcDriver</value>
      </parameter>
      <parameter>
         <name>dialect</name>
         <value>net.sf.hibernate.dialect.HSQLDialect</value>
      </parameter>
      <parameter>
         <name>url</name>
         <value>jdbc:hsqldb:/usr/AlariusAssignments/wsabi_os</value>
      </parameter>
      <parameter>
         <name>username</name>
         <value>sa</value>
      </parameter>
      <parameter>
         <name>password</name>
         <value></value>
      </parameter>
      <parameter>
         <name>maxActive</name>
         <value>20</value>
      </parameter>
   </ResourceParams>
</Context>


The SessionFactory is returned in the wsabi code with

Code:
New Configuration().configure().buildSessionFactory();


Here is the hibernate.cfg.xml:
Code:
<hibernate-configuration>

    <session-factory>

        <property name="connection.datasource">java:comp/env/jdbc/wsabi4axis</property>
        <property name="show_sql">true</property>
        <property name="dialect">net.sf.hibernate.dialect.HSQLDialect</property>

        <!-- Mapping files -->
        <mapping resource="hibernate-mappings/perf_index.hbm.xml"/>

     <mapping resource="hibernate-mappings/audit_log.hbm.xml"/>


    </session-factory>

</hibernate-configuration>


The problem is coming from the Liferay portal that has its libraries all located in the /common/lib/ and the wsabi is a webapp and the Liferay DSConnectionProvider knows nothing about the wsabi factory.

Here is the log excerpt:

Code:
[2005-06-16 14:57:35,265] ERROR ineConfigurationFactoryServlet Unable to find config file.  Creating new servlet engine config file: /WEB-INF/server-config.wsdd
[2005-06-16 14:57:38,281] INFO  DefaultPlugIn                  Starting default module - config = wsabi-default.properties
[2005-06-16 14:57:38,734] INFO  ConfigurePlugIn                Starting configure module - config = wsabi-configure.properties
[2005-06-16 14:57:39,093] INFO  SecurePlugIn                   Starting security module - config = wsabi-secure.properties
[2005-06-16 14:57:39,171] INFO  MonitorPlugIn                  Starting monitor module - config = wsabi-monitor.properties
[2005-06-16 14:57:39,234] ERROR ineConfigurationFactoryServlet Unable to find config file.  Creating new servlet engine config file: /WEB-INF/server-config.wsdd
[2005-06-16 15:00:28,656] INFO  SessionFactoryFactory          create(): No SessionFactory found via JNDI
[2005-06-16 15:00:28,656] INFO  SessionFactoryFactory          create(): Attempting to obtain SessionFactory via config files
[2005-06-16 15:00:28,718] INFO  Environment                    Hibernate 2.1.6
[2005-06-16 15:00:28,781] INFO  Environment                    loaded properties from resource hibernate.properties: {hibernate.dbcp.maxIdle=15, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect, hibernate.dbcp.maxActive=50, hibernate.show_sql=true , hibernate.dbcp.maxWait=5000, hibernate.hbm2ddl.auto=update , hibernate.connection.datasource=java:comp/env/jdbc/wsabi4axis}
[2005-06-16 15:00:28,796] INFO  Configuration                  configuring from resource: /hibernate.cfg.xml
[2005-06-16 15:00:28,796] INFO  Configuration                  Configuration resource: /hibernate.cfg.xml
[2005-06-16 15:00:29,281] INFO  Configuration                  Mapping resource: hibernate-mappings/perf_index.hbm.xml
[2005-06-16 15:00:29,593] INFO  Binder                         Mapping class: org.allesta.wsabi.monitor.index.model.PerfIndex -> perf_index
[2005-06-16 15:00:29,968] INFO  Binder                         Mapping class: org.allesta.wsabi.monitor.index.model.PerfIndexDataPoint -> perf_index_datapoint
[2005-06-16 15:00:29,984] INFO  Configuration                  Mapping resource: hibernate-mappings/audit_log.hbm.xml
[2005-06-16 15:00:30,062] INFO  Binder                         Mapping class: org.allesta.wsabi.monitor.log.model.AuditLog -> audit_log
[2005-06-16 15:00:30,109] INFO  Binder                         Mapping class: org.allesta.wsabi.monitor.log.model.AuditLogDetail -> audit_log_detail
[2005-06-16 15:00:30,109] INFO  Configuration                  Configured SessionFactory: null
[2005-06-16 15:00:30,125] INFO  Configuration                  processing one-to-many association mappings
[2005-06-16 15:00:30,250] INFO  Binder                         Mapping collection: org.allesta.wsabi.monitor.index.model.PerfIndex.dataPoints -> perf_index_datapoint
[2005-06-16 15:00:30,265] INFO  Configuration                  processing one-to-one association property references
[2005-06-16 15:00:30,265] INFO  Configuration                  processing foreign key constraints
[2005-06-16 15:00:30,375] INFO  Dialect                        Using dialect: net.sf.hibernate.dialect.HSQLDialect
[2005-06-16 15:00:30,375] INFO  SettingsFactory                Use outer join fetching: true
[2005-06-16 15:00:30,390] INFO  ConnectionProviderFactory      Initializing connection provider: com.liferay.util.dao.hibernate.DSConnectionProvider
[2005-06-16 15:00:30,406] FATAL ConnectionProviderFactory      Could not instantiate connection provider
java.lang.ClassCastException
   at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:54)
   at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:65)
   at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1155)
   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:789)
   at org.allesta.wsabi.util.hibernate.factory.SessionFactoryFactory.obtainViaConfigFiles(SessionFactoryFactory.java:127)
   at org.allesta.wsabi.util.hibernate.factory.SessionFactoryFactory.create(SessionFactoryFactory.java:84)
   at org.allesta.wsabi.monitor.index.dao.hibernate.PerfIndexDAO.<clinit>(PerfIndexDAO.java:69)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:141)
   at org.allesta.wsabi.monitor.index.dao.IPerfIndexDAOFactory.getSingleton(IPerfIndexDAOFactory.java:63)
   at org.allesta.wsabi.monitor.index.PerfIndexManager.init(PerfIndexManager.java:168)
   at org.allesta.wsabi.monitor.index.PerfIndexManager.getInstance(PerfIndexManager.java:70)
   at org.allesta.wsabi.monitor.index.action.PerfIndexAction.execute(PerfIndexAction.java:81)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.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.doGet(ActionServlet.java:397)


Code:

_________________
Mike "Ollie" Oliver


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.