/*
 * $Id: DefaultClassResolver.java 5771 2006-05-19 12:04:06 +0000 (Fri, 19 May
 * 2006) joco01 $ $Revision$ $Date: 2006-05-19 12:04:06 +0000 (Fri, 19
 * May 2006) $
 * 
 * ==============================================================================
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package wicket.application;

import java.util.concurrent.ConcurrentHashMap;

import wicket.WicketRuntimeException;

/**
 * Resolves a class by using the classloader that loaded this class.
 * 
 * @see wicket.settings.IApplicationSettings#getClassResolver()
 * 
 * @author Juergen Donnerstag
 * @author Jonathan Locke
 */
public final class DefaultClassResolver implements IClassResolver
{
	/**
	 * Usually class loaders implement more efficent caching strategies than we
	 * could possibly do, but we experienced synchronization issue resulting in
	 * stack traces like: java.lang.LinkageError: duplicate class definition:
	 * 
	 * <pre>
	 *      wicket/examples/repeater/RepeatingPage at java.lang.ClassLoader.defineClass1(Native Method) 
	 * </pre>
	 * 
	 * This problem has gone since we synchronize the access.
	 */
	private ConcurrentHashMap<String, Class> classes = new ConcurrentHashMap<String, Class>(64,
			0.75f, 1);

	/**
	 * @see wicket.application.IClassResolver#resolveClass(java.lang.String)
	 */
	public final Class resolveClass(final String classname)
	{
		try
		{
			Class clz = classes.get(classname);
			if (clz == null)
			{
				synchronized (classes)
				{
					clz = DefaultClassResolver.class.getClassLoader().loadClass(classname);
					classes.put(classname, clz);
				}
			}
			return clz;
		}
		catch (ClassNotFoundException ex)
		{
			throw new WicketRuntimeException("Unable to load class with name: " + classname);
		}
	}
}

@@ -2241,24 +2241,28 @@
  + classname
+, ex
 );%0A%09%09%7D%0A%09%7D%0A%7D%0A

give the cause exception