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.

2
  • 1
    Check here: stackoverflow.com/questions/16440419/… Commented Jan 25, 2016 at 11:59
  • @Baderous: I tried <jee:jndi-lookup id="dataSource" jndi-name="java:jdbc/sampleDataSource" /> same error. Commented Jan 25, 2016 at 12:21

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/dimeDataSource" />this also working fine when i select the server.
@Rajesh: Happy it helped!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.