-->
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.  [ 2 posts ] 
Author Message
 Post subject: Can't make Hibernate work with Oracle OS authentication
PostPosted: Fri Aug 17, 2007 11:00 am 
Newbie

Joined: Fri Aug 17, 2007 8:44 am
Posts: 4
Hi,

First of all, sorry if this topic has already been covered, but I didn't find relevant information about it while searching here or anywhere else.

Recently I became involved in a Java project relying massively on Hibernate (v3.1.2).

My problem is to have a batch treatment come to working state again. It uses Hibernate and formerly connected through a classic thin driver/URL/user/password way, working fine. Now, due to internal company security policies I have to make it connect to Oracle through OS authentication, using the OCI driver and that's it.

As an indication, the project comes with several other "simple" batch applications, which I succeeded to modify into using the Oracle connection with external authentication :
- the URL became jdbc:oracle:oci@ (instead of jdbc:oracle:thin@machine.port.SID) ;
- and the values passed as user and password are "" (empty string).
These simple apps don't use Hibernate : the tools managing the DB connection are Oracle's OracleDataSource and Jakarta commons-dbutils' QueryRunner.
Everything works fine with these, I didn't have to change a single line of code, just the connection parameters stored in a property file. Thus, this gets me into believing that the Oracle config and the Unix user rights are appropriately set, and so my problem with the Hibernate batch treatment doesn't come from there.

In fact, I attempted to reproduce the same operation with the hibernate.cfg.xml file :
Quote:
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="format_sql">true</property>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="max_fetch_depth">1</property>
<property name="hibernate.connection.username"></property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.url">jdbc:oracle:oci:@</property>


I then get the following error :
Quote:
org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:363)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:122)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:125)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1309)
at com.maboite.infra.application.hibernate.composant.HibernateAG.beginTransaction(HibernateAG.java:43)
... 4 more
Caused by: java.sql.SQLException: Exception d'E/S: The Network Adapter could not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:539)
at java.sql.DriverManager.getConnection(DriverManager.java:158)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:360)
... 9 more


While browsing the Net and these forums, I couldn't find an exemple pointing to a way to implement OS authentication with Hibernate (but then again, nowhere could I find the statement "no OS authentication with Hibernate").

==> My question is a triple one :
1) Is there a possibility to implement the OS authentication with Hibernate ? (if your answer is "yes, using driver Foo from FooSoftware", it's a dead end because we are already way over budget)
2) If not, knowing that with less sophisticated tools I can use Oracle's external authentication in my "simple" apps, is there a way for me to force Hibernate to use a connection I'd open beforehand in that way ?
3) the way I'm trying to connect here is by using Oracle's OCI driver, which is a "type 2" JDBC driver. But in the exception stack, there are the T4CConnection and T4CDriverExtension classes which terribly resemble something related to "type 4" driver connectivity. Hence, is it possible that I'm not describing the driver_class parameter correctly, and so there would be a way to force Hibernate to use the "type 2" driver I want (and finally let me connect to Oracle) ?

Thanks in advance for your contributions,
G4rF

_________________
--
Seasons of gasoline and gold
Wise men fold (Nik Kershaw, "The riddle")


Top
 Profile  
 
 Post subject: Found it !
PostPosted: Fri Aug 17, 2007 12:00 pm 
Newbie

Joined: Fri Aug 17, 2007 8:44 am
Posts: 4
Hey there,
I found the solution by myself. It happens that, being quite a fat batch application, another hibernate config file was stuck in the classpath which got the priority on the one I was editing.

The good part is : you can definitely use Oracle OS authentication with Hibernate.
The bad part is : I wish I hadn't used a full day of work to figure this out.

C U,
g4rf

_________________
--
Seasons of gasoline and gold
Wise men fold (Nik Kershaw, "The riddle")


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

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.