在context.xml中配置jdbcRealm [英] Configuring jdbcRealm in context.xml

查看:133
本文介绍了在context.xml中配置jdbcRealm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<Context antiJARLocking="true" path="/NCellLive">
<Resource 
    name="jdbc/Gis_WebApp" 
    auth="Container"
    type="javax.sql.DataSource" 
    username="uname" 
    password="pword"
    driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" 
    url="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=Gis_WebApp;SelectMethod=cursor;"
    maxActive="8" 
/>
    <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
    driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
    connectionURL="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=Gis_WebApp;"
    connectionName="uname" connectionPassword="pword"
    userTable="app_user" userNameCol="username" userCredCol="password"
    userRoleTable="app_user_group" roleNameCol="groupname"/>  

</Context>

现在所有数据库连接都可以正常工作,但是在我添加了领域之后,引发了以下错误,我已经在库中添加了sqljdbc4.jar.

Now all data base connection is working fine but after I added realm following errors are thrown I already have sqljdbc4.jar added in library.

Jan 31, 2012 11:28:24 AM org.apache.catalina.realm.JDBCRealm authenticate
SEVERE: Exception performing authentication
java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:701)
    at org.apache.catalina.realm.JDBCRealm.authenticate(JDBCRealm.java:352)
    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:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    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:987)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1805)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

可能是什么问题?

推荐答案

Caused by: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

告诉您在类路径中找不到sql库.
它必须位于您的tomcat/lib文件夹中.

tells you that the sql library cannot be found in your classpath.
It needs to be in your tomcat/lib folder.

doc :

要设置Tomcat以使用JDBCRealm,您需要遵循以下步骤 步骤:

To set up Tomcat to use JDBCRealm, you will need to follow these steps:

  1. 如果尚未这样做,请在数据库中创建符合上述要求的表和列.
  2. 配置供Tomcat使用的数据库用户名和密码,该用户名和密码至少具有对上述表的只读访问权限. (Tomcat绝不会尝试写入这些表.)
  3. 在$ CATALINA_HOME/lib目录中放置将要使用的JDBC驱动程序的副本.请注意,只能识别JAR文件!
  4. 如下所述,在$ CATALINA_BASE/conf/server.xml文件中设置一个元素.
  5. 如果已在运行Tomcat 6,请重新启动它.
  1. If you have not yet done so, create tables and columns in your database that conform to the requirements described above.
  2. Configure a database username and password for use by Tomcat, that has at least read only access to the tables described above. (Tomcat will never attempt to write to these tables.)
  3. Place a copy of the JDBC driver you will be using inside the $CATALINA_HOME/lib directory. Note that only JAR files are recognized!
  4. Set up a element, as described below, in your $CATALINA_BASE/conf/server.xml file.
  5. Restart Tomcat 6 if it is already running.

这篇关于在context.xml中配置jdbcRealm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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