简体   繁体   中英

Where can I find com.ibm.ws.logging.object.hpel.WsLogRecord

One of my interns today came to me and asked where he could find the following class

com.ibm.ws.logging.object.hpel.WsLogRecord

Typically something like findjar.com would find it, but in this case it couldn't. I ended up using Jar Explorer to find it in the WAS 8 libraries within the following location, but that process was inefficient:

{server root}\plugins\com.ibm.hpel.logging.jar

The purpose of this post is to provide insight into where it can be found, but also to ask what are the best ways to find classes when utilities online don't provide the insight you need.

Thanks, Jeremy

What I do to find it under a running instance of WebSphere is to deploy a JSP that uses a technique described in a DeveloperWorks article to locate the jar which provided a particular class.

For posterity, here's the source of that JSP :

<?xml version="1.0" encoding="ISO-8859-1" ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Servlet Container Class Finder</title>
</head>
<body>
<h2>Servlet Container Class Finder</h2>
<p>Enter the fully-qualified name of a Java class
(e.g. org.apache.oro.text.regex.Perl5Compiler) in the field below. The
servlet will attempt to load the class and, if successful, query the
class' <em>java.security.CodeSource</em> for the location of the class
using the following methods:
    <pre>
    Class.forName(className).getProtectionDomain().getCodeSource()
    </pre>
</p>
<p>
<%
    String className = request.getParameter("className");
    String prefill = "";
    if (className != null)
    {
        prefill = className;
        if (className.trim().length() != 0)
        {
            try
            {
                java.security.ProtectionDomain pd = Class.forName(className).getProtectionDomain();
                if (pd != null)
                {
                    java.security.CodeSource cs = pd.getCodeSource();
                    if (cs != null)
                    {
                        out.println(cs);
                    }
                    else
                    {
                        out.println("No CodeSource found");
                    }
                }
                else
                {
                    out.println("No ProtectionDomain found");
                }
            }
            catch (Throwable t)
            {
                out.println(t);
            }
        }
    }
%>
</p>
<form method="post" action="<%= request.getRequestURI()%>">
    <p>
    Class Name: <input type="text" name="className" value="<%= prefill %>" size="40"/>
    <input type="submit" value="Submit"/>
    </p>
</form>
<p>
    Code taken from 
    <a href="http://www.ibm.com/developerworks/websphere/techjournal/0406_brown/0406_brown.html">
    this DeveloperWorks article</a>.
</p>
</body>
</html>

I was able to find WsLogRecord under com.ibm.ws.logging.object.WsLogRecord (minus the hpel). I used eclipse to look under com.ibm.ws.logging.object and could not find hpel, but found WsLogRecord. I was able to view the actual class with jd-eclipse. Comments in the .class gave a file location (C:\\IBM\\SDP\\runtimes\\base_v7\\plugins\\com.ibm.ws.runtime.jar). Looks like I could not find it on findjar.com either and the .jar came as IBM's out-of-the-box code. I suppose this doesn't answer of how to find it online, but I was able to find it and then view the class with the above steps.

If all else fails and I am not able to find the class using Eclipse Quick Type Hierarchy, which shows in which jar the class lives, I would use a shell script along the following lines:

for f in `find /path/to/websphere/lib -name "*.jar"` 
do    
   FOUND=`jar tvf $f | grep WsLogRecord`
   if [[ -n $FOUND ]]
   then
       echo "Found in $f:"
       echo $FOUND
   fi
done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM