无法在 Eclipse 中使用 Tomcat 设置 jdbc 领域
我一整天都在尝试为在 tomcat 上运行的 Web 应用程序设置一个 jdbc 领域,但我却束手无策。
在此配置中,当我尝试使用有效凭据访问安全元素时。它不让我登录。以下是详细信息
server.xml
<Realm debug="99"
className="org.apache.catalina.realm.JDBCRealm"
driverName="com.jdbc.mysql.Driver"
connectionURL="jdbc:mysql://localhost/HireZilla"
digest="MD5"
connectionName="realm_access" connectionPassword="realmpass"
userTable="user_details" userNameCol="user_name" userCredCol="password"
userRoleTable="user_roles" roleNameCol="role_name"/>
web.xml
<web-app>
----
<security-constraint>
<web-resource-collection>
<web-resource-name>ReqCreation</web-resource-name>
<url-pattern>/jsp/reqs/new_rec.jsp</url-pattern>
<url-pattern>/jsp/reqs/reqcreate</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Director</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
-----
</web-app>
mysql-table
CREATE TABLE user_details (
user_name varchar(20) NOT NULL PRIMARY KEY,
password varchar(32) NOT NULL
user_access_level tinyint(3) unsigned NOT NULL DEFAULT '0',
user_login_state tinyint(1) NOT NULL DEFAULT '0',
);
CREATE TABLE `role_types` (
`role_name` varchar(20) NOT NULL,
`description` varchar(100) DEFAULT NULL,
PRIMARY KEY (`role_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `user_roles` (
`user_name` varchar(30) NOT NULL,
`role_name` varchar(20) NOT NULL,
KEY `user_name_constraint` (`user_name`),
KEY `role_name_constraint` (`role_name`),
CONSTRAINT `user_name_constraint` FOREIGN KEY (`user_name`) REFERENCES `user_details`
(`user_name`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `role_name_constraint` FOREIGN KEY (`role_name`) REFERENCES `role_types`
(`role_name`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `role_types` VALUES ('Director','text 1'),('Manager','text 2'),
('Recruiters','text 3');
INSERT INTO `user_details` VALUES
('admin','5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8',3,1);
INSERT INTO `user_roles` VALUES ('admin','Director');
这是 tomcat 日志信息
16 Jul, 2011 9:03:30 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in
production environments was not found on the java.library.path: /usr/lib/jvm/java-6-
openjdk/jre/lib/i386/client:/usr/lib/jvm/java-6-openjdk/jre/lib/i386:/usr/lib/jvm/java-
6-openjdk/jre/../lib/i386:/usr/lib/jvm/java-6-
openjdk/jre/lib/i386/client:/usr/lib/jvm/java-6-openjdk/jre/lib/i386:/usr/lib/xulrunner-
1.9.2.17:/usr/lib/xulrunner-1.9.2.17:/usr/java/packages/lib/i386:/usr/lib/i386-linux-
gnu/jni:/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu:/usr/lib/jni:/lib:/usr/lib
16 Jul, 2011 9:03:30 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property
'source' to 'org.eclipse.jst.jee.server:HireZilla-SVN' did not find a matching property.
16 Jul, 2011 9:03:31 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
16 Jul, 2011 9:03:31 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1177 ms
16 Jul, 2011 9:03:31 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
16 Jul, 2011 9:03:31 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
16 Jul, 2011 9:03:31 PM org.apache.catalina.startup.ContextConfig validateSecurityRoles
INFO: WARNING: Security role name Director used in an <auth-constraint> without being
defined in a <security-role>
16 Jul, 2011 9:03:32 PM com.model.dbchecks.DatabaseConnectHandler get_db_connection
INFO: Database connection established
16 Jul, 2011 9:03:32 PM com.web.listener.LoginListener contextInitialized
INFO: Set the dbconnection in the listener
16 Jul, 2011 9:03:32 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
16 Jul, 2011 9:03:33 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
16 Jul, 2011 9:03:33 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/40 config=null
16 Jul, 2011 9:03:33 PM org.apache.catalina.startup.Catalina start
我真的希望有人能对这个问题有所了解。那就真的很感激了。提前致谢。如果需要,我可以提供更多详细信息。
斯里纳斯
I have been trying all day to set up a jdbc realm for my web application that runs on tomcat and I am at my wits end.
In this configuration, When I try to access a secure element even with valid credentials. Its not letting me log-in. Following are the details
server.xml
<Realm debug="99"
className="org.apache.catalina.realm.JDBCRealm"
driverName="com.jdbc.mysql.Driver"
connectionURL="jdbc:mysql://localhost/HireZilla"
digest="MD5"
connectionName="realm_access" connectionPassword="realmpass"
userTable="user_details" userNameCol="user_name" userCredCol="password"
userRoleTable="user_roles" roleNameCol="role_name"/>
web.xml
<web-app>
----
<security-constraint>
<web-resource-collection>
<web-resource-name>ReqCreation</web-resource-name>
<url-pattern>/jsp/reqs/new_rec.jsp</url-pattern>
<url-pattern>/jsp/reqs/reqcreate</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Director</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
-----
</web-app>
mysql-table
CREATE TABLE user_details (
user_name varchar(20) NOT NULL PRIMARY KEY,
password varchar(32) NOT NULL
user_access_level tinyint(3) unsigned NOT NULL DEFAULT '0',
user_login_state tinyint(1) NOT NULL DEFAULT '0',
);
CREATE TABLE `role_types` (
`role_name` varchar(20) NOT NULL,
`description` varchar(100) DEFAULT NULL,
PRIMARY KEY (`role_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `user_roles` (
`user_name` varchar(30) NOT NULL,
`role_name` varchar(20) NOT NULL,
KEY `user_name_constraint` (`user_name`),
KEY `role_name_constraint` (`role_name`),
CONSTRAINT `user_name_constraint` FOREIGN KEY (`user_name`) REFERENCES `user_details`
(`user_name`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `role_name_constraint` FOREIGN KEY (`role_name`) REFERENCES `role_types`
(`role_name`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `role_types` VALUES ('Director','text 1'),('Manager','text 2'),
('Recruiters','text 3');
INSERT INTO `user_details` VALUES
('admin','5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8',3,1);
INSERT INTO `user_roles` VALUES ('admin','Director');
This is the tomcat log information
16 Jul, 2011 9:03:30 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in
production environments was not found on the java.library.path: /usr/lib/jvm/java-6-
openjdk/jre/lib/i386/client:/usr/lib/jvm/java-6-openjdk/jre/lib/i386:/usr/lib/jvm/java-
6-openjdk/jre/../lib/i386:/usr/lib/jvm/java-6-
openjdk/jre/lib/i386/client:/usr/lib/jvm/java-6-openjdk/jre/lib/i386:/usr/lib/xulrunner-
1.9.2.17:/usr/lib/xulrunner-1.9.2.17:/usr/java/packages/lib/i386:/usr/lib/i386-linux-
gnu/jni:/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu:/usr/lib/jni:/lib:/usr/lib
16 Jul, 2011 9:03:30 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property
'source' to 'org.eclipse.jst.jee.server:HireZilla-SVN' did not find a matching property.
16 Jul, 2011 9:03:31 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
16 Jul, 2011 9:03:31 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1177 ms
16 Jul, 2011 9:03:31 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
16 Jul, 2011 9:03:31 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
16 Jul, 2011 9:03:31 PM org.apache.catalina.startup.ContextConfig validateSecurityRoles
INFO: WARNING: Security role name Director used in an <auth-constraint> without being
defined in a <security-role>
16 Jul, 2011 9:03:32 PM com.model.dbchecks.DatabaseConnectHandler get_db_connection
INFO: Database connection established
16 Jul, 2011 9:03:32 PM com.web.listener.LoginListener contextInitialized
INFO: Set the dbconnection in the listener
16 Jul, 2011 9:03:32 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
16 Jul, 2011 9:03:33 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
16 Jul, 2011 9:03:33 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/40 config=null
16 Jul, 2011 9:03:33 PM org.apache.catalina.startup.Catalina start
I really hope somebody can throw some light on this issue. It would be really grateful. Thanks in Advance. I can provide some more details if needed.
Sreenath
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论