将以下代码保存为path.jsp,放于server的文件目录下:
<%@page pageEncoding="UTF-8"%><%@page import="java.net.URL" %><%@page import="java.io.*" %><%!String getClassPath(String className){ StringBuffer sb=new StringBuffer("className:"+className+""); try { Class z=Class.forName(className); String path = z.getName().replace(".", "/"); path ="/"+path+".class"; URL url=z.getResource(path); if(url!=null){ sb.append("class loader:"+z.getClassLoader()); sb.append("class path:"+url.getPath()); }else{ sb.append("class not loaded by any classLoader"); } } catch (Exception e) { e.printStackTrace(); StringWriter writer = new StringWriter(); PrintWriter pw = new PrintWriter(writer); e.printStackTrace(pw); pw.close(); sb.append("error:"+e); sb.append(""+writer.toString()+""); } return sb.toString(); }%>find class path
<%String className=request.getParameter("className");if(className!=null && !"".equals(className)){ out.println(getClassPath(className));}%> 然后访问此文件路径,得到页面,输入完整的classname, 可以得到如下信息:
className:com.ibatis.dao.client.DaoManagerclass loader: com.ibm.ws.classloader.CompoundClassLoader@22ed7bd4[war:Forums/forum.web.war] Local ClassPath: C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\classes;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\AjaxProxy.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\castor-1.0.5-xml.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\commons-fileupload-1.2.1.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\forum.api.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\forum.svc.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\forum.web.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\ibatis-dao-2.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\jtidy-r938.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lc.extdatamodel.impl.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lc.oauth.messages.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lc.oauth.platform.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lc.oauth.platform.mbeans.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lc.oauth.provider.web.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lc.proxy2.5.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lc.search.externalAPI.connections.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lc.search.seedlist.framework.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lc.search.seedlist.retriever.forums.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lc.util.share.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lc.util.web-3.0.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lc.widgets.core.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\lucene-core-1.9.1.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\mybatis-2.3.5.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\ognl-2.6.9.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\search.searchInterface.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\sn.av.admin.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\sn.av.api.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\sn.av.icap.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\spring.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\struts.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\struts2-core-2.0.14-noStaticNoFreemarker.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\struts2-tiles-plugin-2.0.14.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\tiles-api-2.0.4.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\tiles-core-2.0.4-minus-rbh.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\tiles-jsp-2.0.4.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\tk.rproxysvc.client.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war\WEB-INF\lib\xwork-2.0.4.jar;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WIN-H05L8ME1F0NCell01\Forums.ear\forum.web.war Parent: com.ibm.ws.classloader.CompoundClassLoader@22ed7a78[PL][app:Forums] Delegation Mode: PARENT_FIRSTclass path:file:/C:/Program%20Files%20(x86)/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/WIN-H05L8ME1F0NCell01/Forums.ear/forum.web.war/WEB-INF/lib/ibatis-dao-2.jar!/com/ibatis/dao/client/DaoManager.class