<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MyArch &#187; Troubleshooting</title>
	<atom:link href="http://myarch.com/category/troubleshooting/feed" rel="self" type="application/rss+xml" />
	<link>http://myarch.com</link>
	<description>Builds and bytes</description>
	<lastBuildDate>Mon, 30 Jan 2012 01:22:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ClassNotFoundException: A List of Dumb Things to Check</title>
		<link>http://myarch.com/classnotfound</link>
		<comments>http://myarch.com/classnotfound#comments</comments>
		<pubDate>Thu, 14 Jan 2010 05:12:50 +0000</pubDate>
		<dc:creator>Alexander Ananiev</dc:creator>
				<category><![CDATA[Building software]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[WebSphere]]></category>
		<category><![CDATA[WebSphere Application Server Administration]]></category>

		<guid isPermaLink="false">http://myarch.com/?p=549</guid>
		<description><![CDATA[	You deploy a new version of your application into production environment, hit the application&#8217;s URL  and get a 500 error with a long error stack and nasty &#8220;java.lang.ClassNotFoundException&#8221; in bold at the top.

	&#8220;Class Not Found&#8221; exceptions could be quite tricky to troubleshoot because of the complexity of Java Web applications and application servers they [...]]]></description>
			<content:encoded><![CDATA[	<p>You deploy a new version of your application into production environment, hit the application&#8217;s <span class="caps">URL </span> and get a 500 error with a long error stack and nasty &#8220;java.lang.ClassNotFoundException&#8221; in bold at the top.</p>

	<p>&#8220;Class Not Found&#8221; exceptions could be quite tricky to troubleshoot because of the complexity of Java Web applications and application servers they run on.  An average web application nowadays comes bundled with dozens of jar file (and probably thousands of classes). An average application server&#8217;s classpath is many pages long. Not to mention separately deployed libraries containing jar files shared by a group of applications. There should be little surprise that it is quite common for all these different jars and classloaders to clash with each other, get out of sync or become otherwise corrupt and mis-configured.</p>

	<p>The list below represents a subset of all the possible causes of &#8220;ClassNotFoundException&#8221;.  Hopefully this list could serve as a starting point for attacking the problem. The list was inspired by <a href="http://everythingsysadmin.com/dumb-things-to-check.html" title="">A List of Dumb Things to Check</a>.</p>

	<ul>
		<li>To start, determine a type of the offending class. Is it a an application class, a third-party library class, a class provided by the application server or a <span class="caps">JDK</span> class?  Determine the jar file that should contain the class. Determine where that jar should be located on the file system. Is it part of application installation, application server installation or some shared library installation? You may need to search for the class within multiple jars. Here is the command to do it (<a href="http://www.unix.com/shell-programming-scripting/21551-jar-file-search.html">source</a>): <code>  find . &lt;del&gt;name *.jar -print -exec jar -tvf {} ; | awk '/YOURSEARCHSTRING/ || /jar/ {print} ' </code> (note</del>-it won&#8217;t search within <span class="caps">EAR</span> and <span class="caps">WAR</span> files)</li>
		<li> Does the jar that&#8217;s supposed to contain the class exist on the file system?</li>
		<li> Are you able to &#8220;unjar&#8221; the jar using <code>jar -xvf</code>?  Does the jar indeed contain the package and class in question?</li>
		<li>Check the version of the jar if you can&#8217;t find the class there. To determine the version, look at the jar&#8217;s <span class="caps">MANIFEST</span>.MF. Usually (but, unfortunately, not  always) you will find some version information there. You can also compare the file size with the &#8220;baseline&#8221;.</li>
		<li>Does the account that the application server&#8217;s <span class="caps">JVM</span> was started with have read access to the jar? An application server usually runs under some sort of a system account. The jar might have been copied to the file system using a personal account from a different group.</li>
		<li>Have all application jars been updated during deployment? Are all the jars (including shared libraries) at the right version? Manual deployment process is quite common, so missing to update a jar is always a possibility.</li>
		<li>Is the class in question packaged with the application (e.g., under <span class="caps">WEB</span>-INF/lib) and being loaded by one of the parent classloaders? Most application servers utilize a classloader hierarchy where <span class="caps">WAR</span> file&#8217;s classloader is a child of <span class="caps">EAR</span> classloader which in turn is a child of the system (JVM) classloader. Parent classloaders can&#8217;t go down to request a class from a child classloader. The problem occurs if, for example, some jars were moved to a shared library but they still depend on classes packaged with the application.<br />
In order to diagnose this situation, you&#8217;ll need to have a good understanding of your application server&#8217;s classloader hierarchy.  <a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/crun_classload.html" title="">Here</a> is the information for WebSphere and  <a href="http://download.oracle.com/docs/cd/E15523_01/web.1111/e13706/classloading.htm" title="">here</a> is the WebLogic documentation on classloaders. <a href="http://josephamrithraj.wordpress.com/2010/02/24/class-loader-classnotfound-exception-in-websphere/" title="">Here</a> is another article covering WebSphere classloaders in depth.</li>
		<li>Is any of the jars packaged with the application also present on any of the parent classloader&#8217;s classpath? Running different versions of the same jar or library can cause all kinds of issues, including ClassNotFoundException.  Some app servers allow overriding default classloader behavior so that the jars packaged with the application are loaded first. This could fix the problem.</li>
		<li> If the jar with the class in question is part of a shared library (as opposed to packaged with the application), check if this library was made available to the application via the classloader configuration. For example, WebSphere configuration involves setting up a separate classloader for the library and explicitly associating it with the application.</li>
		<li>Is the version and patch level of the application server correct? Does it match your development environment? Look at the detailed version information for all the different components of your app servers and also get a list of installed patches. E.g., for WebSphere run <code>versionInfo -long</code> command.</li>
		<li> Is the application server running  under the right <span class="caps">JDK</span>? E.g., check if the server startup script relies on <span class="caps">JAVA</span>_HOME and see which <span class="caps">JDK</span> the <span class="caps">JAVA</span>_HOME points to.</li>
		<li>If the application runs in a cluster, does the problem occur on all nodes or just on some? Are you trying to troubleshoot the problem on the right node?</li>
		<li>If the classname is driven from a string, either in java source or some other file, have you spelled the class name correctly? (<a href="http://www.1060.org/blogxter/publish/5" title="">Steve Loughran</a>)</li>
	</ul>

	<p>Once again, this is by no means a complete list.  If anybody wants to contribute, please add a comment below and I&#8217;ll update the post.</p>


 ]]></content:encoded>
			<wfw:commentRss>http://myarch.com/classnotfound/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

