使用这个工具来检查classLoader的问题

将以下代码保存为path.jsp,放于server的文件目录下:

<%@page pageEncoding="UTF-8"%>
<%@page import="java.net.URL" %>
<%@page import="java.io.*" %>
<%!
String getClassPath(String className){
	StringBuffer sb=new StringBuffer("<b>className</b>:"+className+"<br>");
        try {
        	Class z=Class.forName(className);
            String path = z.getName().replace(".", "/");   
            path ="/"+path+".class";
            URL url=z.getResource(path);   
            if(url!=null){
            	sb.append("<b>class loader</b>:"+z.getClassLoader());
				sb.append("<br><b>class path</b>:"+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("<br><pre>"+writer.toString()+"</pre>");
        }   
        return sb.toString();   
    }
%>
<html>
<head><title>find class path</title>
<style>
*{font:14px;}
b{font-weight:bold;}
</style>
</head>
<body>
<form action="<%=request.getRequestURI()%>">
class full name:<input type=text name=className size=60 /><br>
<input type=submit value=submit />
</form>
<hr>
<%
String className=request.getParameter("className");
if(className!=null && !"".equals(className)){
	out.println(getClassPath(className));
}
%>
</body>
</html>
然后访问此文件路径,得到页面,输入完整的classname, 可以得到如下信息:
className:com.ibatis.dao.client.DaoManager
class 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_FIRST
class 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

转载于:https://my.oschina.net/xpbug/blog/84603

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值