apache tomcat 7.0.30 datasourcerealm javax.naming.NameNotFoundException:名称[jdbc / proto]未绑定在此Context中。找不到[jdbc] [英] apache tomcat 7.0.30 datasourcerealm javax.naming.NameNotFoundException: Name [jdbc/proto] is not bound in this Context. Unable to find [jdbc]

查看:262
本文介绍了apache tomcat 7.0.30 datasourcerealm javax.naming.NameNotFoundException:名称[jdbc / proto]未绑定在此Context中。找不到[jdbc]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我先描述一下环境:

环境:
- mac os x(java build 1.6.0_35-b10 -428-11M3811)
- apache tomcat 7.0.30
- mysql 5.5.27
- tomcat / lib - > mysql-connector-java-5.1.22-bin.jar

environment: - mac os x (java build 1.6.0_35-b10-428-11M3811) - apache tomcat 7.0.30 - mysql 5.5.27 - tomcat/lib --> mysql-connector-java-5.1.22-bin.jar

我已成功实施了JDBCRealm ,并希望切换到DataSourceRealm,因为建议用于生产环境。我使用基于表单的身份验证。

i've implemented successfully a JDBCRealm and want to switch to a DataSourceRealm because it is recommended for production environments. i use form-based authentication.

我做了这里描述的所有事情:
http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html#DataSourceRealm
和这里:
http://tomcat.apache.org/tomcat-7.0-doc/ jndi-datasource-examples-howto.html #MySQL_DBCP_Example

I did everything described here: http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html#DataSourceRealm and here: http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example

server.xml

<Realm className="org.apache.catalina.realm.LockOutRealm">
     <Realm className="org.apache.catalina.realm.DataSourceRealm" 
            dataSourceName="jdbc/proto" digest="SHA-256" roleNameCol="role" 
            userCredCol="password" userNameCol="name" userRoleTable="roles" 
            userTable="users"/>
</Realm>

context.xml

<Resource auth="Container" 
          driverClassName="com.mysql.jdbc.Driver" 
          maxActive="100" maxIdle="30" maxWait="10000" 
          name="jdbc/proto" password="proto" type="javax.sql.DataSource" 
          url="jdbc:mysql://localhost:3306/proto" username="proto"/>

WEB-INF / web.xml

<resource-ref>
    <description>DB Connection</description>
    <res-ref-name>jdbc/proto</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

当我提交用户名和密码时,我得到以下例外:

when i submit the username and password i get the following exception:

Sep 18, 2012 9:38:32 PM org.apache.catalina.realm.DataSourceRealm open
SEVERE: Exception performing authentication
javax.naming.NameNotFoundException: Name [jdbc/proto] is not bound in this Context. Unable to find [jdbc].
at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at org.apache.catalina.realm.DataSourceRealm.open(DataSourceRealm.java:394)
at org.apache.catalina.realm.DataSourceRealm.authenticate(DataSourceRealm.java:285)
at org.apache.catalina.realm.CombinedRealm.authenticate(CombinedRealm.java:146)
at org.apache.catalina.realm.LockOutRealm.authenticate(LockOutRealm.java:180)
at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:295)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:450)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
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:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)

我还没有试图在不同的操作系统上设置环境以测试它是否是特定于mac的问题。

i haven't tried to setup the environment on a different os to test if it's a mac specific issue.

我错过了什么建议?我感谢您的帮助!谢谢。

any suggestions what i missed? i appreciate your help! thank you.

推荐答案

为避免在GlobalNamingResources中声明ressource,请在Realm中放置localDataSource =true

To avoid declaring the ressource in GlobalNamingResources, put localDataSource="true" in the Realm

这篇关于apache tomcat 7.0.30 datasourcerealm javax.naming.NameNotFoundException:名称[jdbc / proto]未绑定在此Context中。找不到[jdbc]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆