首页

异常"javax.naming.NameNotFoundException: Name [toa/maDS] is not bound in this Context. Unable to find [toa]."解决方法

标签:exception,java异常,初始化失败,JNDI,Resource,jndi,context.xml,Java命名和目录接口     发布时间:2016-04-28   

一、异常描述

启动Java Web项目无法正常启动,抛出“javax.naming.NameNotFoundException: Name [toa/maDS] is not bound in this Context. Unable to find [toa].”异常,详细日志如下

javax.naming.NameNotFoundException: Name [toa/maDS] is not bound in this Context. Unable to find [toa].@b@    at org.apache.naming.NamingContext.lookup(NamingContext.java:819)@b@    at org.apache.naming.NamingContext.lookup(NamingContext.java:153)@b@    at org.apache.naming.NamingContext.lookup(NamingContext.java:830)@b@    at org.apache.naming.NamingContext.lookup(NamingContext.java:153)@b@    at org.apache.naming.NamingContext.lookup(NamingContext.java:830)@b@    at org.apache.naming.NamingContext.lookup(NamingContext.java:167)@b@    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:156)@b@    at javax.naming.InitialContext.lookup(InitialContext.java:417)@b@    at com.xwood.system.JndiTemplate$1.doInContext(JndiTemplate.java:96)@b@    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87)@b@    at com.xwood.system.JndiTemplate.lookup(JndiTemplate.java:92)@b@    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)@b@    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)@b@    at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)@b@    at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)@b@    at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)@b@    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)@b@    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)@b@    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)@b@    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedMap(BeanDefinitionValueResolver.java:378)@b@    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:161)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)@b@    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)@b@    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1079)@b@    at com.xwood.soofa.app.lwc.service.persistence.dao.ibatis.support.SqlMapClientDaoSupport._initDao(SqlMapClientDaoSupport.java:128)@b@    at com.xwood.soofa.app.lwc.service.persistence.dao.ibatis.support.SqlMapClientDaoSupport.afterPropertiesSet(SqlMapClientDaoSupport.java:93)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)@b@    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)@b@    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:437)@b@    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:411)@b@    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:543)@b@    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:147)@b@    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)@b@    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:298)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)@b@    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)@b@    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)@b@    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)@b@    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)@b@    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)@b@    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)@b@    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)@b@    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)@b@    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)@b@    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)@b@    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)@b@    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)@b@    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)@b@    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)@b@    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)@b@    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)@b@    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)@b@    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)@b@    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)@b@    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)@b@    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)@b@    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)@b@    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)@b@    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)@b@    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)@b@    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)@b@    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)@b@    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:467)@b@    at com.xwood.soofa.web.PispatcherServlet.createWebApplicationContext(PDispatcherServlet.java:25)@b@    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:483)@b@    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:358)@b@    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:325)@b@    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)@b@    at javax.servlet.GenericServlet.init(GenericServlet.java:158)@b@    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)@b@    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)@b@    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)@b@    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210)@b@    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493)@b@    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)@b@    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)@b@    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)@b@    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)@b@    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)@b@    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1898)@b@    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)@b@    at java.util.concurrent.FutureTask.run(FutureTask.java:266)@b@    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)@b@    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)@b@    at java.lang.Thread.run(Thread.java:745)@b@@b@四月 28, 2016 7:47:41 下午 org.apache.catalina.startup.HostConfig deployDirectory@b@信息: Deployment of web application directory D:z.168.1.8appsapache-tomcat-7.0.54webapps	oa-mgw1.3.0 has finished in 9,855 ms@b@四月 28, 2016 7:47:41 下午 org.apache.coyote.AbstractProtocol start@b@信息: Starting ProtocolHandler ["http-bio-9999"]@b@四月 28, 2016 7:47:41 下午 org.apache.coyote.AbstractProtocol start@b@信息: Starting ProtocolHandler ["ajp-bio-9109"]@b@四月 28, 2016 7:47:41 下午 org.apache.catalina.startup.Catalina start@b@信息: Server startup in 22250 ms

二、解决步骤

1.  点击项目关于tomcat服务Servers配置的项,在Context.xml添加Resource的JNDI的目录资源注入

异常"javax.naming.NameNotFoundException: Name [toa/maDS] is not bound in this Context. Unable to find [toa]."解决方法

2. JNDI的Resource的格式参考模板如下

<Resource driverClassName="oracle.jdbc.driver.OracleDriver" maxActive="4" maxIdle="2"@b@@b@ maxWait="50" name="toa/maDS" password="1234" type="javax.sql.DataSource" url="jdbc:oracle:thin:@172.168.1.8:1526:d0toa" username="toadata"/>

3. 重启服务,问题解决了 

<<推荐下载>>
  • (1) 阿里巴巴Java开发手册8种不同版本
  • (2) Web前端开发视频教程
  • (3) 30+明星讲师PPT课件分享一线大厂架构实战经验
  • (4) java开发_架构篇_视频资源分享_v2208
  • (5) java开发_高级篇_视频资源分享_v2208
  • (6) java开发_进阶篇(中级)_视频资源分享_v2208
  • (7) java开发_入门篇_视频资源分享_v2208
  • (8) 微信小程序开发视频1+167源码+实战demo等下载
  • (9) easy-shopping电子商务java源码(附脚本和安装文档说明)下载
  • (10) java常用的72份知名实用的电子书下载
  • (11) java开发性能优化资料整理大全(8份电子文档+3份实战优化)下载
  • (12) 9个常用的算法设计资料和100以上视频课件内容下载
  • (13) vue开发必备常用手册16件下载
  • (14) 21种不同技术集群方案(es、flink、redis、nginx、zk、lvs、kafka、mysql、k8s等)参考资料下载
  • (15) 20种技术代码规范(js/java/dba/阿里/华为/oracle/mysql等)参考资料下载
  • (16) 微服务五套资料(0-1,架构设计,springcloud,nacos等)下载
  • (17) 架构师(28知识图谱+3套简历模板+6套架构实战文档等)完整资料整理下载
  • (18) 大数据18套实战基础知识+8套简历模板下载
  • (19) 并发编程全套(7套+阿里巴巴+亿级实战等)实战资料下载
  • (20) Kafka九套学习整理知识点全套(面试+笔记+代码api+命令+容备等)资料下载
  • (21) java全套9个不同方向类型的面试题(基础+核心+大厂+架构师+近万套题库等)下载
  • (22) JAVA开发常用API帮助文档大全(超52种以上技术资料,高手必备)下载
  • (23) springcloud超详细139件全套学习实战资料( 视频课件+源码demo+文档资料等)下载
  • <<热门文章>>