6

I created a JNDI connection with the following Values:

i selected Generic Data Source option

Name: jdbc/sampleDataSource

JNDI Name: jdbc/sampleDataSource

Spring Config File:

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/sampleDataSource" />

I'm getting below error.

Error An error occurred during activation of changes, please see the log for details.
Error javax.naming.NameNotFoundException: While trying to lookup 'jdbc.sampleDataSource' didn't find subcontext 'jdbc'. Resolved ''; remaining name 'jdbc/sampleDataSource'
Error While trying to lookup 'jdbc.sampleDataSource' didn't find subcontext 'jdbc'. Resolved ''; remaining name 'jdbc/sampleDataSource' 

I was unable to resolve it. How do i configure in Spring 4. Any addition jar file is required. Please help on this.

Rajesh Narravula
  • 1,433
  • 3
  • 26
  • 54

1 Answers1

6

Sometimes this happens when you forget to Target your defined datasource to a specific server. You can find it in Weblogic's administration server :

enter image description here

then in the Targets tab:

enter image description here

you should select the target.

If that wasn't the problem, you may try the way of getting your datasource in the applicationContext.xml:

<bean id="dataSource" name="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jdbc/mcdsDS"/>
    <property name="resourceRef" value="true"/>
</bean>

And use the dataSource reference wherever you need a datasource.

Hope this would be helpful.

STaefi
  • 4,297
  • 1
  • 25
  • 43