接下来,我们将看一些实际的场景,将在其中使用跟踪输出帮助调试问题。阅读 WebSphere Application Server 跟踪文件时的非常好的实践是,跟踪所涉及的线程 ID,以了解事件流。(下载部分提供了用于拉取特定线程的脚本。)因此,您需要在 trace.log 文件中查找异常,然后再回到对应的线程 (00000033)。
示例 1
在此场景中,已经启用了 LDAP 服务器的全局安全性,无法登录到管理控制台。为了调试此问题,请遵循 Global Security problems for WebSphere Application Server(其中请求对复现的问题进行安全性跟踪)的 WebSphere Application Server MustGather 说明进行操作。
在问题服务器的 SystemOut.log 文件中找到问题期间发生的与您的情况相关的异常(例如,安全性或管理控制台)。对于本例,会发现以下异常:
步骤 1 中收集的信息非常重要,因为这提供了所涉及的线程 ID,即 00000033。这很有用,因为如果遇到具有不同线程 ID 的其他异常,就会知道这些异常很可能与此不相关,如以下片段中的情况:[2/6/07 11:25:43:802 EST] 00000033 LTPAServerObj E SECJ0369E: Authentication failed when using LTPA. The exception is [LDAP: error code 49 - Invalid Credentials]. [2/6/07 11:25:44:583 EST] 00000033 FormLoginExte E SECJ0118E: Authentication error during authentication for user joeuser@us.ibm.com
在 trace.log 文件中找到与步骤 1 中找到的错误的发生时间相近的具有相同线程 ID 的异常。[2/6/07 11:26:11:972 EST] 00000038 wsMapDefaultI < Exception creating SAP tokens from WSCredential. Exit com.ibm.websphere.security.auth.WSLoginFailedException: Invalid authentication data.
返回对应的线程查找关于为何生成此错误消息的更多信息。按照上面的说明操作,会发现此示例的 trace.log 中发生的情况如下:
从上面的跟踪输出中可以看到,在 LdapRegistryI* 类的 checkPassword 方法退出时发生了异常。继续到 00000033 线程,可以看到对用户 ID joeuser@us.ibm.com(执行登录尝试的 ID)调用了 checkPassword 方法。如果进一步回溯线程,会发现所使用的用户注册中心是 LDAP 注册中心 myldap.raleigh.ibm.com:389。这清楚地表明登录时输入的密码与 LDAP 注册中心中的用户 ID 对应密码不匹配。[2/6/07 11:25:43:151 EST] 00000033 ltpaLoginModu 3 Using uid and password for authentication [2/6/07 11:25:43:151 EST] 00000033 ltpaLoginModu 3 Authenticating "myldap.raleigh.ibm.com:389/joeuser@us.ibm.com" [2/6/07 11:25:43:151 EST] 00000033 LTPAServerObj > authenticate Entry [2/6/07 11:25:43:151 EST] 00000033 UserRegistryI > checkPassword Entry joeuser@us.ibm.com **** [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI > checkPassword Entry joeuser@us.ibm.com [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI 3 Authenticating joeuser@us.ibm.com [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI 3 Searching for users [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI > getUsers Entry joeuser@us.ibm.com 2 [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI > search Entry [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI 3 DN: o=ibm.com [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI 3 Search scope: 2 [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI 3 Filter: (&(mail=joeuser@us.ibm.com)(objectclass=person)) [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI 3 Time limit: 3 [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI 3 Attr[0]: 1.1 [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI > getDirContext Entry [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI < getDirContext Exit [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI < getDirContext Exit [2/6/07 11:25:43:151 EST] 00000033 LdapRegistryI 3 enterJNDI:WebContainer : 1 [2/6/07 11:25:43:231 EST] 00000033 LdapRegistryI 3 exitJNDI:WebContainer : 1 [2/6/07 11:25:43:231 EST] 00000033 LdapRegistryI 3 Time elapsed: 80 [2/6/07 11:25:43:231 EST] 00000033 LdapRegistryI < search Exit [2/6/07 11:25:43:231 EST] 00000033 LdapRegistryI 3 Number of users returned = 1 [2/6/07 11:25:43:231 EST] 00000033 LdapRegistryI < getUsers Exit joeuser@us.ibm.com 2 [2/6/07 11:25:43:231 EST] 00000033 LdapRegistryI 3 Found user uid=joeuser,c=person,o=ibm.com [2/6/07 11:25:43:231 EST] 00000033 LdapRegistryI 3 enterJNDI:WebContainer : 1 [2/6/07 11:25:43:562 EST] 00000033 LdapRegistryI 3 exitJNDI:WebContainer : 1 [2/6/07 11:25:43:662 EST] 00000033 LdapRegistryI < checkPassword Exit javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials] at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3005) at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2951) at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2752) at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2666) at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:307) at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:190) at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:208) at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java :151) at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java: 81) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:675) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:257) at javax.naming.InitialContext.init(InitialContext.java:233) at javax.naming.InitialContext.<init>(InitialContext.java:209) at javax.naming.directory.InitialDirContext.<init>(InitialDirContext .java:94) at com.ibm.ws.security.registry.ldap.LdapRegistryImpl.authenticate(LdapReg istryImpl.java:370) at com.ibm.ws.security.registry.ldap.LdapRegistryImpl.checkPassword(LdapReg istryImpl.java:312) at com.ibm.ws.security.registry.UserRegistryImpl.checkPassword(UserRegistr yImpl.java:296) at com.ibm.ws.security.ltpa.LTPAServerObject.authenticate(LTPAServerObject .java:573) at com.ibm.ws.security.server.lm.ltpaLoginModule.login(ltpaLoginModule.jav a:437) ... [2/6/07 11:25:43:802 EST] 00000033 LTPAServerObj E SECJ0369E: Authentication failed when using LTPA. The exception is [LDAP: error code 49 - Invalid Credentials].