-->
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.  [ 7 posts ] 
Author Message
 Post subject: binding SessionFactory to JNDI with WebLogic
PostPosted: Wed Sep 17, 2003 2:00 am 
Newbie

Joined: Wed Sep 17, 2003 1:31 am
Posts: 7
Location: tampa, FL
i was running thru the forum and also thru the documentation trying to get a handle on how to bind the SessionFactory to JNDI. It seems as though by doing this:

SessionFactory factory = new Configuration().configure().buildSessionFactory();

will bind it because of the values in the hibernate.cfg.xml file. However, I don't see this happening. I also saw a post where someone else was doing a Startup class in WebLogic to bind it to JNDI. I also thought of having an HibernateInit servlet that would create the SessionFactory and bind it to JNDI. Can someone clue me in on if this is necessary, if hibernate does actually do the bind for you, etc. Again I'm on Weblogic 8.1 .

Regards,

Jeff Mikres


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2003 10:07 am 
Beginner
Beginner

Joined: Tue Aug 26, 2003 1:02 pm
Posts: 34
Location: Akron, OH
They must have broken that somewhere between 6.1 and 8.1 because it works fine for me. Are you sure it is not getting published, or are you looking it up incorrectly?
My cfg.xml:
Code:
<hibernate-configuration>
  <session-factory name="hibernate.session-factory.Oracle">
    <property name="jndi.class">weblogic.jndi.WLInitialContextFactory</property>
    <property name="jndi.url">t3://127.0.0.1:7001</property>
    <!-- irrelevant properties deleted -->
  </session-factory>
</hibernate-configuration>


I create the Session Factory in the (almost) the same way. Then retrieve it with:
Code:
InitialContext initialContext = new InitialContext();
SessionFactory sf = (SessionFactory) initialContext.lookup("hibernate.session-factory.Oracle");

(Simplified, of course)

Do you see any entries like this in your logs?
Code:
10:01:56,563  INFO SessionFactoryImpl:132 - building session factory
10:01:56,583  INFO NamingHelper:26 - JNDI InitialContext properties:{java.naming.provider.url=t3://127.0.0.1:7001,
    java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory}
10:01:57,935  INFO SessionFactoryObjectFactory:86 - Factory name: hibernate.session-factory.Oracle
10:01:57,935  INFO NamingHelper:26 - JNDI InitialContext properties:{java.namin.provider.url=t3://127.0.0.1:7001,
    java.naming.factory.initial=weblogic.jndi.WLnitialContextFactory}
10:01:57,945  INFO SessionFactoryObjectFactory:91 - Bound factory to JNDI name:hibernate.session-factory.Oracle
10:01:57,945  WARN SessionFactoryObjectFactory:101 - InitialContext did not impement EventContext

Especially the "Bound factory..." message.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 10:48 am 
Newbie

Joined: Tue Jun 15, 2004 10:45 am
Posts: 18
Location: Boston, USA
FYI I am using Weblogic 8.1 and binding to the JNDI tree works fine through the hibernate.cfg.xml.

Below is a snippet from my config file if it helps:

Code:
<property name="connection.datasource">myDataSource</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<property name="jndi.class">weblogic.jndi.WLInitialContextFactory</property>
<property name="jndi.url">t3://127.0.0.1:7001</property>


_________________
Quinton Wall

"The most difficult thing in the world is to know how to do a thing and to watch somebody else doing it wrong,without comment" -
- T.H. White


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2004 11:02 am 
Newbie

Joined: Wed Dec 10, 2003 8:40 pm
Posts: 9
only way I could get the session factory into jndi was by manually binding it in weblogic 8.1


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 27, 2004 2:25 pm 
Beginner
Beginner

Joined: Tue Jul 20, 2004 1:53 am
Posts: 43
Location: India
Please see this thread. Excuse the cross-post.

_________________
Thanks,
Binil Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 30, 2004 10:45 pm 
Regular
Regular

Joined: Sat Aug 28, 2004 4:15 pm
Posts: 61
With binding the SessionFactory to JNDI in weblogic you don't need hibernate.jndi.url and hibernate.jndi.class to be specified in the manner as you all have in this topic. Those values are the defaults used by weblogic for the initial context(as per e-docs on bea site). So, you only need to specify those if you have another configuration such as a different ip or wish to implement your own class.

Otherwise, you should have no problems binding the session factory once you give your session factory a name in the hibernate config and execute SessionFactory sess = new Configuration().configure().buildSessionFactory();

The configure() is key as it is what actually causes the hibernate config to be read. I spent several hours missing the configure() method.


GOod luck


Joe

_________________
Joe W


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 23, 2008 2:57 pm 
Beginner
Beginner

Joined: Tue Jun 06, 2006 3:37 am
Posts: 29
is this error still exist within weblogic 9.2 m2 ? I'm facing an error with the following config

Code:
<!-- Hibernate session factory -->
   <bean id="annotedSessionFactory"
      class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
      <property name="dataSource">
         <ref bean="datecDataSourcej" />
      </property>
      <property name="hibernateProperties">
         <props>
            <!--
               <prop
               key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
            -->
            <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
            
            <prop key="hibernate.hbm2ddl.auto">update</prop>
         
            <prop key="hibernate.show_sql" >true</prop>
            <prop key="hibernate.connection.isolation" >8</prop>
            
         </props>
      </property>
...
<bean id="datecDataSourcej" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="jdbc/test" />
   </bean>



and I got this

Code:

<23 sept. 2008 17.02. h CEST> <Error> <HTTP> <BEA-101020> <[weblogic.servlet.internal.WebAppServletContext@13e6514 - appName: 'yamina-1', name: 'yamina-1.0
APSHOT-.dir', context-path: '/yamina-1.0.0-SNAPSHOT-.dir'] Servlet failed with Exception
org.hibernate.exception.GenericJDBCException: Cannot open connection
        at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
        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:426)
        Truncated. see log file for complete stacktrace
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory ([NDSQL02\DEV]Impossible d'ouvrir la base de donnÚes "test" demandÚe p
connexion. La connexion a ÚchouÚ.)
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1228)
        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:884)
        at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:82)
        at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
        at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
        Truncated. see log file for complete stacktrace
com.inet.tds.be: Msg 4060, Level 11, State 1, Line 1, Sqlstate 01000
[NDSQL02\DEV]Impossible d'ouvrir la base de donnÚes "test" demandÚe par la connexion. La connexion a ÚchouÚ.
        at com.inet.tds.al.a(Unknown Source)
        at com.inet.tds.n.b(Unknown Source)
        at com.inet.tds.n.a(Unknown Source)
        at com.inet.tds.n.<init>(Unknown Source)
        at com.inet.tds.aj.<init>(Unknown Source)
        Truncated. see log file for complete stacktrace



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