-->
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.  [ 8 posts ] 
Author Message
 Post subject: hibernate - weblogic newbie problems
PostPosted: Wed Mar 17, 2004 3:02 pm 
Beginner
Beginner

Joined: Thu Feb 26, 2004 11:32 am
Posts: 32
Hi:
I am trying to create a sample application using hibernate-2.1, weblogic 8.1 and Oracle 8i. I have a simple java client invoking the SSB which then tries to establish a hiberante session.


the code in my SSB is :

Configuration cfg = new Configuration();
cfg.setProperty("jndi.url","t3://localhost:7001");
cfg.setProperty("jndi.class", "weblogic.jndi.WLInitialContextFactory");
cfg.setProperty("hibernate.connection.datasource", "testDataSource");
cfg.setProperty("hibernate.dialect", "net.sf.hibernate.dialect.OracleDialect");
cfg.setProperty("hibernate.show_sql", "true");
cfg.setProperty("hibernate.transaction.factory_class", "net.sf.hibernate.transaction.JTATransactionFactory");
cfg.setProperty("jta.UserTransaction", "java:comp/UserTransaction");

cfg.addClass(EasTlKeyvaluelookup.class);

/******************* this is line number 61********************/
defaultSessionFactory = cfg.buildSessionFactory();
if(defaultSessionFactory != null)
System.out.println("MADE SESSION FACTORY!!!");
else
System.out.println("could not make session factory");


session = defaultSessionFactory.openSession();

/************************ this is line number 70***************/
List myList = session.createQuery(
"from EasTlKeyvaluelookup as lookup where lookup.keyidentifier = 'EASDaemonPollInterval'"
).list();



I get the following bunch of messages :

The userid-passwd combination is correct, although there is authenication failure message.

Mar 17, 2004 1:42:22 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
WARNING: Could not obtain connection metadata
java.sql.SQLException: User: easusr01_dv, failed to be authenticated.
at weblogic.jdbc.common.internal.RmiDataSource.getSubject(RmiDataSource.java:257)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:188)
at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionPro
vider.java:56)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1119)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:748)
at hibertest.TestHibernateBean.doQuery(TestHibernateBean.java:61)
at hibertest.TestHibernate_j4ohqo_EOImpl.doQuery(TestHibernate_j4ohqo_EOImpl.java:45)
at hibertest.TestHibernate_j4ohqo_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Mar 17, 2004 1:42:22 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: false
Mar 17, 2004 1:42:22 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): false
Mar 17, 2004 1:42:22 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
Mar 17, 2004 1:42:22 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: echoing all SQL to stdout
Mar 17, 2004 1:42:22 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {no='N', true=1, yes='Y', false=0}
Mar 17, 2004 1:42:22 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.hibernate.cache.HashtableCacheProvider
Mar 17, 2004 1:42:22 PM net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
Mar 17, 2004 1:42:22 PM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Mar 17, 2004 1:42:22 PM net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: no JNDI name configured
Mar 17, 2004 1:42:22 PM net.sf.hibernate.cache.UpdateTimestampsCache <init>
INFO: starting update timestamps cache at region: net.sf.hibernate.cache.UpdateTimestampsCache
Mar 17, 2004 1:42:22 PM net.sf.hibernate.cache.QueryCache <init>
INFO: starting query cache at region: net.sf.hibernate.cache.QueryCache
MADE SESSION FACTORY!!!
Mar 17, 2004 1:42:22 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: null
Mar 17, 2004 1:42:22 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: User: easusr01_dv, failed to be authenticated.
Mar 17, 2004 1:42:22 PM net.sf.hibernate.JDBCException <init>
SEVERE: Cannot open connection
java.sql.SQLException: User: easusr01_dv, failed to be authenticated.
at weblogic.jdbc.common.internal.RmiDataSource.getSubject(RmiDataSource.java:257)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:188)
at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionPro
vider.java:56)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3264)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3244)
at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:65)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:704)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:185)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:950)
at net.sf.hibernate.loader.Loader.list(Loader.java:941)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at hibertest.TestHibernateBean.doQuery(TestHibernateBean.java:70)
at hibertest.TestHibernate_j4ohqo_EOImpl.doQuery(TestHibernate_j4ohqo_EOImpl.java:45)
at hibertest.TestHibernate_j4ohqo_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Errornet.sf.hibernate.JDBCException: Cannot open connection


TIA

sp


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 17, 2004 11:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Are you able to manualy get a connection from the "testDataSource" datasource and use it successfully?

Also, the following two lines are completely unecessary when running in an app-server and all the resources are local:
cfg.setProperty("jndi.url","t3://localhost:7001");
cfg.setProperty("jndi.class", "weblogic.jndi.WLInitialContextFactory");


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 10:09 am 
Beginner
Beginner

Joined: Thu Feb 26, 2004 11:32 am
Posts: 32
I am able to obtain connection to 'testDataSource' and using plain jdbc, I am able to fetch values.My hibernate.properties file below, doesnt contain much as I am trying to set hibernate properties through my code.




sp


## define query language constants / function names

hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'

#################################
### Hibernate Connection Pool ###
#################################

hibernate.connection.pool_size 1

## Properties for external configuration of Proxool
hibernate.proxool.pool_alias pool1

## specify a JDBC isolation level
#hibernate.connection.isolation 4


## set the JDBC fetch size

#hibernate.jdbc.fetch_size 25


## set the maximum JDBC 2 batch size (a nonzero value enables batching)

hibernate.jdbc.batch_size 0

## enable use of JDBC 2 scrollable ResultSets (specifying a Dialect will cause Hibernate to use a sensible default)

#hibernate.jdbc.use_scrollable_resultset true


## use streams when writing binary types to / from JDBC

hibernate.jdbc.use_streams_for_binary true


## use JDBC 3 PreparedStatement.getGeneratedKeys to get the identifier of an inserted row

#hibernate.jdbc.use_get_generated_keys true


## specify a default schema for unqualified tablenames

#hibernate.default_schema test


## use a custom stylesheet for XML generation (if not specified, hibernate-default.xslt will be used)

#hibernate.xml.output_stylesheet C:/Hibernate/net/sf/hibernate/hibernate-default.xslt


## enable outerjoin fetching (specifying a Dialect will cause Hibernate to use sensible default)

#hibernate.use_outer_join false


## set the maximum depth of the outer join fetch tree

hibernate.max_fetch_depth 1


## enable CGLIB reflection optimizer (enabled by default)

#hibernate.cglib.use_reflection_optimizer false



##########################
### Second-level Cache ###
##########################

## optimize chache for minimal "puts" instead of minimal "gets" (good for clustered cache)

#hibernate.cache.use_minimal_puts true


## enable the query cache

hibernate.cache.use_query_cache true


## choose a cache implementation

hibernate.cache.provider_class net.sf.hibernate.cache.HashtableCacheProvider


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 10:20 am 
Beginner
Beginner

Joined: Thu Feb 26, 2004 11:32 am
Posts: 32
Hi:
I also want to point out the line 61 in my code
defaultSessionFactory = cfg.buildSessionFactory();

figures in the stacktrace and also returns me a non-null Sessionfactory, which is kind of contradictory to me

tia

sp


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 10:48 am 
Beginner
Beginner

Joined: Thu Feb 26, 2004 11:32 am
Posts: 32
Hi:
I guess the reson weblogic is refusing connection is that I also have to specify my weblogic user-id and weblogic-password somewhere, so hibernate can do a sucessfull jndi look-up, as is normally done in any jndi look-up

for eg:
props.put(Context.SECURITY_PRINCIPAL, <weblogic-userid>);
props.put(Context.SECURITY_CREDENTIALS, <weblogic-passowrd>");


I am just not sure how to specify this with hibernate, could someone point out the properties that need to be set for this,


tia

sp


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 12:18 pm 
Beginner
Beginner

Joined: Thu Feb 26, 2004 11:32 am
Posts: 32
I tried passing security info to hibernate as below for obtaining a connection but didnt have any success.

cfg.setProperty("hibernate.jndi.java.naming.security.principal", <weblogic-userid>);
cfg.setProperty("hibernate.jndi.java.naming.security.credentials", <weblogic-passowrd>);


still looking for pointers to my problem

sp


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 12:40 pm 
Beginner
Beginner

Joined: Thu Feb 26, 2004 11:32 am
Posts: 32
figured out my mistake.

hibernate.connection.username & hibernate.connection.password need app-server user-id & password and not database info since that is already configured in my datasource

sp


Top
 Profile  
 
 Post subject: Could you help out
PostPosted: Wed Apr 14, 2004 1:23 pm 
Newbie

Joined: Tue Apr 13, 2004 9:47 am
Posts: 4
Location: Atlanta, Ga
Looking to do the same thing you are doing with WebLogic 8 and Oracle or MySQL. Is it possible to send me what you have done so far. I am brand new and just got the auction java console program to run and am struggling to get a web application started. It would be greatly appreciated and any work I do I will send back to you.

My emai lis john.neal@cingular.com

Thanks,

John


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.