oracle - Error upon integrating JNDI with Spring -


this first attempt @ spring jndi getting below mentioned exception when trying create applicationcontext like:

applicationcontext context = new classpathxmlapplicationcontext("master-job.xml"); 

the spring configuration file follows:

<bean id="datasource" class="org.springframework.jndi.jndiobjectfactorybean">     <property name="jndiname" value="/jdbc/eqpstatus"/>     <property name="resourceref" value="true" /> </bean>  <bean id="masterdao" class="com.dao.masterdao">     <property name="datasource" ref="datasource"/> </bean> 

on server have required resource entry jndi name.

<resource auth="container" driverclassname="oracle.jdbc.oracledriver"         maxactive="10" maxidle="2" maxwait="10000" name="jdbc/eqpstatus"         password="xxxx" type="javax.sql.datasource"         url="jdbc:oracle:thin:@(description=(load_balance=on)(address=(protocol=tcp)(host=xxxx) (port=1521))(address=(protocol=tcp)(host=xxxx) (port=1521))(connect_data=(service_name=xyz)))"         username="xxx"/> 

the error see is:

 javax.naming.namenotfoundexception: name jdbc not bound in context 

would highly appreciate inputs on new spring-jndi integration.

if using tomcat , fine tomcat configuration; should enough:

<jee:jndi-lookup id="datasource" jndi-name="java:comp/env/jdbc/datasource" /> 

where jdbc/datasource name defined in tomcat config.

edit:

my bad, forgot jndi.properties; there 2 possibilities:

  • either provide jndi.properties on classpath or
  • set values in in <jee:jndi-environment/> element of <jee:jndi-lookup /> (see reference)

the java.naming.factory.initial property needs set sure, org.apache.naming.java.javaurlcontextfactory, possibly other values well, like:

java.naming.factory.url.pkgs=org.apache.naming   java.naming.factory.url.pkgs.prefixes=org.apache.naming   java.naming.provider.url=org.apache.naming   

also see reference.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -