Configuring jdbcRealm in .xml context

<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> 

Now all database connections work fine, but after I added the scope, the following errors were thrown. I already added sqljdbc4.jar to the 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 

What could be the problem?

+4
source share
1 answer
 Caused by: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver 

reports that the sql library cannot be found in your classpath.
It should be in the tomcat / lib folder.

From doc :

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

  • If you have not already done so, create tables and columns in your database that meet the requirements described above.
  • Configure the database username and password to use Tomcat, which has at least access only to the tables described above. (Tomcat will never try to write to these tables.)
  • Place the copy of the JDBC driver that you will use in the $ CATALINA_HOME / lib directory. Please note that only JAR files are recognized!
  • Configure the item as described below in the $ CATALINA_BASE / conf / server.xml file.
  • Restart Tomcat 6 if it is already running.
+3
source

Source: https://habr.com/ru/post/1393905/


All Articles