Link to home
Create AccountLog in
Avatar of yongsing
yongsing

asked on

JNDI lookup in Spring/Hibernate

We have a datasource called DBPool defined in a WebLogic server. On the same server, we want to run a stand-alone program to access the same datasource. The stand-alone program uses Spring/Hibernate for the database access. In this stand-alone program, we defined the following:

<bean id="MyDBPool" class="org.springframework.jndi.JndiObjectFactoryBean">
  <property name="resourceRef">
    <value>true</value>
  </property>
  <property name="jndiName">
    <value>DBPool</value>
  </property>
</bean>

When this stand-alone program runs, it will fail in the JNDI lookup. In general, is it possible for a stand-alone program to do a JNDI lookup for a datasource defined in a WebLogic server?

Thanks.
Avatar of Mayank S
Mayank S
Flag of India image

Is the stand alone program running in the context of an app-server instance or just like a normal Java program? Not sure if it is possible, maybe it should just try the simple approach instead of JNDI.
Avatar of yongsing
yongsing

ASKER

It's running like a simple Java program.
Then I doubt it. Anyway, wait to see if any other experts confirm this too.
How do I run the program "in the context of an app-server instance"?
no, instead you would use a different standalone datasource
Hi, sorry for the late reply.

In general, is it possible for a stand-alone program to do a JNDI lookup of an object in a app-server? For example, say we want to call a session bean from the stand-alone program. Wouldn't we be doing a JNDI lookup first?
I'd instead use spring to set the data source for your class to use then theres no need for a jndi lookup as it has a reference to its data source.
ASKER CERTIFIED SOLUTION
Avatar of el_dios
el_dios

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer