Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Binding session factory to weblogic jndi

 
Sandeep Awasthi
Ranch Hand
Posts: 597
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,


I am trying bind SessionFactory to weblgic jndi. When try to lookup from client, it returns null.
(weblogic 8.1, hibernate 3.22, oracle 9i)


hibernate.cfg.xml

hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.username">weblogic</property>
<property name="connection.password">weblogic</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="connection.datasource">PBDS</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>
<property name="transaction.factory.class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">weblogic.transaction.UserTransaction</property>
<property name="hibernate.session_factory_name">session_factory</property>
<property name="jndi.class">weblogic.jndi.WLInitialContextFactory</property>
<property name="jndi.url">t3://170.60.203.248:7001</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">jta</property>
<property name="hbm2ddl.auto">create</property>

<mapping resource="Emp.hbm.xml"/>
<mapping resource="Dept.hbm.xml"/>
<mapping resource="Doc.hbm.xml"/>
<mapping resource="DocLine.hbm.xml"/>
<mapping resource="Cust.hbm.xml"/>
<mapping resource="Part.hbm.xml"/>
<mapping resource="Hobby.hbm.xml"/>
</session-factory>
</hibernate-configuration>







Client

Properties p1 = new Properties();
p1.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
p1.put(Context.PROVIDER_URL,"t3://170.60.203.248:7001");
p1.put(Context.SECURITY_CREDENTIALS,"weblogic");
p1.put(Context.SECURITY_PRINCIPAL,"weblogic");
try {
Context context = new InitialContext(p1);
Object obj = context.lookup("session_factory");
sessionFactory = (SessionFactory)PortableRemoteObject.narrow(obj, org.hibernate.SessionFactory.class);
if (sessionFactory == null ) {
System.out.println("Null session factory ");
}



It always gives me null session factory. I tried to bind through servlet and also with WLSStartup class.

but when I try to lookup from client, it gives me null.

Please help me

[ June 14, 2007: Message edited by: Rajesh Thakare ]
[ June 14, 2007: Message edited by: Rajesh Thakare ]
 
Sandeep Awasthi
Ranch Hand
Posts: 597
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

It was problem with class path.

I changed my clients classpath and added jars in the same sequence as they were in my startWeblogic.cmd. It worked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic