jndi - Spring fails to lookup jdbc configured Data Source -
i have deployed application on tomcat 5.5 , ide eclipse myeclipse plugin. when try start tomcat server following error:
error - contextloader.initwebapplicationcontext(219) | context initialization failed org.springframework.beans.factory.beancreationexception: error creating bean name 'datasource' defined in servletcontext resource [/web-inf/xaconfig/daojpaconfig.xml]: invocation of init method failed; nested exception javax.naming.namenotfoundexception: name java:comp not bound in context @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1412) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:519) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:456) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:291) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:222) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:288) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:190) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:546) @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:871) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:423) @ org.springframework.web.context.contextloader.createwebapplicationcontext(contextloader.java:272) @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:196) @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:47) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:3669) @ org.apache.catalina.core.standardcontext.start(standardcontext.java:4104) @ org.apache.catalina.core.containerbase.start(containerbase.java:1012) @ org.apache.catalina.core.standardhost.start(standardhost.java:718) @ org.apache.catalina.core.containerbase.start(containerbase.java:1012) @ org.apache.catalina.core.standardengine.start(standardengine.java:442) @ org.apache.catalina.core.standardservice.start(standardservice.java:450) @ org.apache.catalina.core.standardserver.start(standardserver.java:683) @ org.apache.catalina.startup.catalina.start(catalina.java:537) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.apache.catalina.startup.bootstrap.start(bootstrap.java:271) @ org.apache.catalina.startup.bootstrap.main(bootstrap.java:409) caused by: javax.naming.namenotfoundexception: name java:comp not bound in context @ org.apache.naming.namingcontext.lookup(namingcontext.java:778) @ org.apache.naming.namingcontext.lookup(namingcontext.java:161) @ javax.naming.initialcontext.lookup(initialcontext.java:392) @ org.springframework.jndi.jnditemplate$1.doincontext(jnditemplate.java:154) @ org.springframework.jndi.jnditemplate.execute(jnditemplate.java:87) @ org.springframework.jndi.jnditemplate.lookup(jnditemplate.java:152) @ org.springframework.jndi.jnditemplate.lookup(jnditemplate.java:178) @ org.springframework.jndi.jndilocatorsupport.lookup(jndilocatorsupport.java:95) @ org.springframework.jndi.jndiobjectlocator.lookup(jndiobjectlocator.java:105) @ org.springframework.jndi.jndiobjectfactorybean.lookupwithfallback(jndiobjectfactorybean.java:201) @ org.springframework.jndi.jndiobjectfactorybean.afterpropertiesset(jndiobjectfactorybean.java:187) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory.java:1469) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1409) ... 27 more
i have configured datasource in apache software foundation\tomcat 5.5\conf as:
<globalnamingresources> <environment name="simplevalue" type="java.lang.integer" value="30"/> <resource name="jdbc/paymentsdb" type="javax.sql.datasource" maxactive="20" maxidle="10" username="root" maxwait="20000" validationquery="select=1" driverclassname="com.mysql.jdbc.driver" password="root" url="jdbc\:mysql\://devserver\:3306/payhub"/> <resource auth="container" description="user database can updated , saved" name="userdatabase" type="org.apache.catalina.userdatabase" factory="org.apache.catalina.users.memoryuserdatabasefactory" pathname="conf/tomcat-users.xml"/> </globalnamingresources>
and added apache software foundation\tomcat 5.5\conf\ context.xml page , added webinf\web.xml
<resource-ref> <description>paymentsdatabase</description> <res-ref-name>jdbc/paymentsdb</res-ref-name> <res-type>javax.sql.datasource</res-type> <res-auth>container</res-auth> </resource-ref>
i using spring framework,hybernate+jpa . please let me know, problem be?
i not recommend putting in global config tomcat. there's no guarantee you'll have access it. better put in meta-inf/context.xml.
you didn't show spring config jndi data source. please include that.
nested exception javax.naming.namenotfoundexception: name java:comp not bound in context
shouldn't java:comp/env
?
Comments
Post a Comment