Advertisement

01.13.2008 at 01:46PM PST, ID: 23079575
[x]
Attachment Details

Configuring an oracle connection for OAS 10.1.3 and Hibernate 3

Asked by markecassidy in Oracle IAS Application Server

Tags: Oracle, Oracle AS, 10.1.3

Hi -
We have an  application that deploys to JBoss - no problem.  It uses Hibernate3 and Oracle 10.  I have been trying to get it to deploy properly to OAS 10.1.3.   I got around some issues with antlr etc by telling the classloader to load our war lib first.

 My remaining problem is getting the connection to work.   I have tried googling the problem, and also read over the documentation about OC4J's datasources for 10.1.3.  

Hibernate finds the xml and configures it.  But when it goes to create a session it gives a class cast exception for the datasource.  I have hibernate3.jar and the ojdbc14.jar in my WEB-INF/lib.
   Caused by: java.lang.ClassCastException: oracle.jdbc.pool.OracleDataSource

I can test the datasource deployed for the app in the console and it works.

Below are relevant portions of hibernate cfg xml, data-sources.xml and the stack trace.

(Any help is appreciated.  I have tried using ManagedDataSource too with connection pool but that seems like I'm going down the wrong path.)

Hibernate cfg xml portion
--------------------------
      <session-factory>
            <property name="hibernate.connection.datasource">
                  java:/mydb
            </property>
            <property name="connection.driver_class">
                  oracle.jdbc.driver.OracleDriver
            </property>
            <property name="dialect">
                  org.hibernate.dialect.Oracle9Dialect
            </property>
            <property name="hibernate.connection.autocommit">
                  false
            </property>
            <property name="hibernate.default_schema">ES</property>
            <property name="hibernate.max_fetch_depth">3</property>
            <property name="hibernate.jdbc.batch_size">0</property>
            <property name="cache.use_query_cache">false</property>


Here is the data-sources.xml   (with name and passwd left blank to protect the innocent)

<?xml version="1.0" encoding="UTF-8" ?>
<data-sources>
      <native-data-source
             name="MyNameds"
             jndi-name="java:/mydb"
             description="Native DataSource"
             data-source-class="oracle.jdbc.pool.OracleDataSource"
             user="...."
             password="...."
             url="jdbc:oracle:thin:@mytestserver:1521:orcl">
      </native-data-source>
</data-sources>


And the stack trace when it tries to open the Hibernate session
---------------------------------------------------------


org.hibernate.HibernateException: Could not find datasource
      at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
      at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
      at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
      at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:366)
      at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)
      at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
      at com.escholar.hibernate.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:95)
      at com.escholar.hibernate.HibernateSessionFactory.getSession(HibernateSessionFactory.java:49)
      at com.escholar.servlets.WSAppLoaderServlet.Initiallize(WSAppLoaderServlet.java:155)
      at com.escholar.servlets.WSAppLoaderServlet.init(WSAppLoaderServlet.java:112)
      at javax.servlet.GenericServlet.init(GenericServlet.java:256)
      at com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:2361)
      at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4810)
      at com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4734)
      at com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4922)
      at com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:1134)
      at com.evermind.server.http.HttpApplication.<init>(HttpApplication.java:738)
      at com.evermind.server.ApplicationStateRunning.getHttpApplication(ApplicationStateRunning.java:414)
      at com.evermind.server.Application.getHttpApplication(Application.java:545)
      at com.evermind.server.http.HttpSite$HttpApplicationRunTimeReference.createHttpApplicationFromReference(HttpSite.java:1990)
      at com.evermind.server.http.HttpSite$HttpApplicationRunTimeReference.<init>(HttpSite.java:1909)
      at com.evermind.server.http.HttpSite.addHttpApplication(HttpSite.java:1606)
      at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplicationBinder.java:238)
      at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplicationBinder.java:99)
      at oracle.oc4j.admin.internal.ApplicationDeployer.bindWebApp(ApplicationDeployer.java:547)
      at oracle.oc4j.admin.internal.ApplicationDeployer.doDeploy(ApplicationDeployer.java:202)
      at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:93)
      at oracle.oc4j.admin.jmx.server.mbeans.deploy.OC4JDeployerRunnable.doRun(OC4JDeployerRunnable.java:52)
      at oracle.oc4j.admin.jmx.server.mbeans.deploy.DeployerRunnable.run(DeployerRunnable.java:81)
      at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)
      at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassCastException: oracle.jdbc.pool.OracleDataSource
      at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
      ... 31 moreStart Free Trial
[+][-]01.13.2008 at 03:32PM PST, ID: 20649860

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.27.2008 at 09:58PM PST, ID: 20757095

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle IAS Application Server
Tags: Oracle, Oracle AS, 10.1.3
Sign Up Now!
Solution Provided By: markecassidy
Participating Experts: 0
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628