在使用JNDI获取获取数据源的时候,报了一个错误: 说数据源没有绑定到上下文中。
原因是因为:
在项目中的WEB-INF/web.xml文件中没有引用数据源:
添加下面一段就好了..
<!-- 数据源引用 -->
<resource-ref>
<description>datasource</description>
<!--数据源名称-->
<res-ref-name>jdbc/datasource</res-ref-name>
<!--引用类型-->
<res-type>javax.sql.DataSource</res-type>
<!--容器-->
<res-auth>Container</res-auth>
</resource-ref>
错误:
javax.naming.NameNotFoundException: Name datasource is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:803)
at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.pack.security.filter.AuthorizationFilter.getConnection(AuthorizationFilter.java:71)
at com.pack.security.filter.AuthorizationFilter.getPreparedStatment(AuthorizationFilter.java:84)
at com.pack.security.filter.AuthorizationFilter.getResultSet(AuthorizationFilter.java:96)
at com.pack.security.filter.AuthorizationFilter.getUserModelByUserID(AuthorizationFilter.java:109)
at com.pack.security.filter.AuthorizationFilter.doFilter(AuthorizationFilter.java:47)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:582)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:279)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
2012-1-11 10:44:39 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet [jsp] in context with path [/TomcatSecurityValidte] threw exception
分享到:
相关推荐
在IT行业中,我们经常遇到各种异常,其中之一是“Javax.naming.NameNotFoundException”。这个异常通常在Java命名和目录接口(JNDI)中出现,当我们尝试查找一个在命名上下文中不存在的名称时,就会抛出这个异常。...
在这个问题中,开发者遇到了一个常见的错误:“Name jdbc is not bound in this Context”,这通常意味着在Tomcat的环境中,指定的数据源没有被正确地绑定或配置。 要解决这个问题,首先需要在Tomcat的配置文件中...
javax.naming.NamingException: Cannot create resource instance类加载异常,希望可以帮助跟我一样错误的人。
在Java编程环境中,图片处理是一项常见的任务,但有时可能会遇到“javax.imageio.IIOException: Unsupported Image Type”的错误。这个异常通常表示Java的`ImageIO`类库无法识别或支持所尝试读取或写入的图像格式。...
赠送jar包:javax.servlet-3.0.0.v201112011016.jar; 赠送原API文档:javax.servlet-3.0.0.v201112011016-javadoc.jar; 赠送源代码:javax.servlet-3.0.0.v201112011016-sources.jar; 赠送Maven依赖信息文件:...
赠送jar包:javax.servlet-3.0.0.v201112011016.jar; 赠送原API文档:javax.servlet-3.0.0.v201112011016-javadoc.jar; 赠送源代码:javax.servlet-3.0.0.v201112011016-sources.jar; 赠送Maven依赖信息文件:...
在Oracle 11.2.0.4中调用 javax.mail 发送邮件时可能会遇到以下错误: ORA-29532: Java call terminated by uncaught Java exception: javax.mail.MessagingException: IOException while sending message; nested ...
赠送jar包:javax.annotation-api-1.3.2.jar; 赠送原API文档:javax.annotation-api-1.3.2-javadoc.jar; 赠送源代码:javax.annotation-api-1.3.2-sources.jar; 赠送Maven依赖信息文件:javax.annotation-api-...
赠送jar包:javax.mail-1.5.6.jar; 赠送原API文档:javax.mail-1.5.6-javadoc.jar; 赠送源代码:javax.mail-1.5.6-sources.jar; 赠送Maven依赖信息文件:javax.mail-1.5.6.pom; 包含翻译后的API文档:javax.mail...
本话题将围绕在Android中使用DES加密和解密时遇到的一个常见问题展开:`javax.crypto.IllegalBlockSizeException: last block incomplete in decryption`。 这个异常通常发生在解密过程中,当输入的数据块大小与DES...
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '***' Gradle (Short): implementation 'javax.servlet:javax.servlet-api:***' Gradle (Kotlin): implementation("javax.servlet:...
赠送jar包:javax.transaction-api-1.2.jar; 赠送原API文档:javax.transaction-api-1.2-javadoc.jar; 赠送源代码:javax.transaction-api-1.2-sources.jar; 赠送Maven依赖信息文件:javax.transaction-api-1.2....
赠送jar包:javax.mail-1.6.2.jar; 赠送原API文档:javax.mail-1.6.2-javadoc.jar; 赠送源代码:javax.mail-1.6.2-sources.jar; 赠送Maven依赖信息文件:javax.mail-1.6.2.pom; 包含翻译后的API文档:javax.mail...
当你遇到“找不到javax.servlet.*”这样的错误时,通常是因为你的项目缺少了这个库,所以需要引入`javax.servlet.jar`来解决问题。 1. **Java Servlet简介** Java Servlet是Java平台上的一个标准,用于扩展服务器...
import javax.media.jai.JAI; import javax.media.jai.RenderedOp; jai_core-1.1.3.jar jai_codec-1.1.3.jar
赠送jar包:javax.activation-1.2.0.jar; 赠送原API文档:javax.activation-1.2.0-javadoc.jar; 赠送源代码:javax.activation-1.2.0-sources.jar; 赠送Maven依赖信息文件:javax.activation-1.2.0.pom; 包含...
赠送jar包:javax.annotation-api-1.2.jar; 赠送原API文档:javax.annotation-api-1.2-javadoc.jar; 赠送源代码:javax.annotation-api-1.2-sources.jar; 赠送Maven依赖信息文件:javax.annotation-api-1.2.pom;...
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '***' Gradle (Short): implementation 'javax.servlet:javax.servlet-api:***' Gradle (Kotlin): implementation("javax.servlet:...
在本例中,我们关注的`jar`包是`javax.annotation.zip`,它包含了`javax.annotation`相关的API,主要用于处理Java的注解(Annotation)。 `javax.annotation`是Java标准版(Java SE)的一部分,提供了标准的注解,...
描述中提到的“解决javax.xml jar包缺失的问题,引进javax.xml.rpc-api-1.1.1.jar”,意味着在开发或运行某个Java项目时,可能会遇到由于缺少`javax.xml.rpc`相关的jar包导致的编译或运行错误。为了解决这个问题,...