title: Struts 2 unable to load interceptor file
body: <p>I'm new to struts2 and I'm having problems loading the custom interceptor file into my demo Struts2 application.  I have tested and checked all my java, jsp and xml files and everything seems ok.  At run time I have the following error and I'm not sure how to fix it.  The application works but the interceptor is not invoked and the print line statements are not printed. </p>
  
  <pre><code>WARNING: Unable to load config class com.ao.businessobjects.interceptor at interceptor -     file:/Users/faraichirawu/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/AO/WEB-INF/classes/struts.xml:16:86 probably due to a missing jar, which might be fine if you never plan to use the LoginInterceptor interceptor
  Jan 05, 2014 4:27:20 PM com.opensymphony.xwork2.config.providers.InterceptorBuilder error
  SEVERE: Actual exception
  Caught Exception while registering Interceptor class com.ao.businessobjects.interceptor - interceptor - file:/Users/faraichirawu/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/AO/WEB-INF/classes/struts.xml:16:86
  at com.opensymphony.xwork2.factory.DefaultInterceptorFactory.buildInterceptor(DefaultInterceptorFactory.java:64)
  at com.opensymphony.xwork2.ObjectFactory.buildInterceptor(ObjectFactory.java:202)
  at com.opensymphony.xwork2.config.providers.InterceptorBuilder.constructInterceptorReference(InterceptorBuilder.java:70)
  at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.lookupInterceptorReference(XmlConfigurationProvider.java:1110)
  at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildInterceptorList(XmlConfigurationProvider.java:626)
  at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:440)
  at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:552)
  at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:292)
  at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
  at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:258)
  at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
  at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:445)
  at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:489)
  at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
  at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
  at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
  at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
  at org.apache.catalina.core.ApplicationFilterConfig.&lt;init&gt;(ApplicationFilterConfig.java:107)
  at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
  at java.util.concurrent.FutureTask.run(FutureTask.java:262)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  at java.lang.Thread.run(Thread.java:744)
  Caused by: java.lang.ClassNotFoundException: com.ao.businessobjects.interceptor
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
  at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
  at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:152)
  at com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:128)
  at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:181)
  at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:171)
  at com.opensymphony.xwork2.factory.DefaultInterceptorFactory.buildInterceptor(DefaultInterceptorFactory.java:42)
  ... 26 more
  </code></pre>
  
  <p>this is my struts.xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
  "http://struts.apache.org/dtds/struts-2.3.dtd"&gt;  
  &lt;struts&gt;
  
  &lt;!-- &lt;constant name="struts.convention.result.path" value="/WEB-INF/" /&gt; 
      &lt;constant name="struts.convention.action.suffix" value="Controller" /&gt; &lt;constant 
      name="struts.convention.package.locators" value="default" /&gt; &lt;constant name="struts.convention.default.parent.package" 
      value="default" /&gt; &lt;constant name="struts.enable.DynamicMethodInvocation" 
      value="false" /&gt; --&gt;
  
  &lt;package name="default" extends="struts-default" namespace="/admin/accounts"&gt;
        &lt;interceptors&gt;
          &lt;interceptor name="LoginInterceptor" class="com.ao.businessobjects.interceptor" /&gt;
          &lt;interceptor-stack name="loginStack"&gt;
              &lt;interceptor-ref name="LoginInterceptor" /&gt;
              &lt;interceptor-ref name="defaultStack" /&gt;
          &lt;/interceptor-stack&gt;
      &lt;/interceptors&gt; 
  
      &lt;global-results&gt;
          &lt;result name="login"&gt;/WEB-INF/login.jsp&lt;/result&gt;
      &lt;/global-results&gt;
  
      &lt;action name="login"&gt;
          &lt;result&gt;/WEB-INF/login.jsp&lt;/result&gt;
      &lt;/action&gt;
  
      &lt;action name="loginAction" class="com.ao.admin.administrator.accounts.LoginAction"&gt;
          &lt;result name="success" type="chain"&gt;welcomeAction&lt;/result&gt;
          &lt;result name="input"&gt;/WEB-INF/login.jsp&lt;/result&gt;
      &lt;/action&gt;
  
      &lt;action name="welcomeAction"&gt;
          &lt;interceptor-ref name="loginStack" /&gt;
          &lt;result name="success"&gt;/WEB-INF/welcome.jsp&lt;/result&gt;
      &lt;/action&gt;
  
      &lt;action name="logoutAction" class="com.ao.admin.administrator.accounts.LogoutAction"&gt;
          &lt;result name="success"&gt;/WEB-INF/login.jsp&lt;/result&gt;
      &lt;/action&gt;
  &lt;/package&gt;
  &lt;/struts&gt;   
  </code></pre>
  
  <p>The jar lib files have loaded are <br><br>
  commons-fileupload-1.3.jar <br>
  commons-io-2.2.jar <br>
  commons-lang-2.4.jar <br>
  commons-lang3-3.1.jar <br>
  commons-logging-1.1.3.jar <br>
  commons-logging-api-1.1.jar <br>
  freemarker-2.3.19.jar <br>
  javassist-3.11.0.GA.jar <br>
  ognl-3.0.6.jar <br>
  struts2-config-browser-plugin-2.3.16.jar <br>
  struts2-core-2.3.16.jar <br>
  xwork-core-2.3.16.jar <br> <br></p>
  
  <p>this is the custom interceptor class</p>
  
  <pre><code>package com.ao.businessobjects.interceptor;
  
  
  import com.opensymphony.xwork2.ActionInvocation;
  import com.opensymphony.xwork2.interceptor.Interceptor;
  
  public class LoginInterceptor implements Interceptor
  {
  
  private static final long serialVersionUID = 1L;
  
  public String intercept(ActionInvocation invocation) throws Exception {
  
      String className = invocation.getAction().getClass().getName();
      long startTime = System.currentTimeMillis();
      System.out.println("Before calling action: " + className);
  
      String result = invocation.invoke();
  
      long endTime = System.currentTimeMillis();
      System.out.println("After calling action: " + className
              + " Time taken: " + (endTime - startTime) + " ms");
  
      return result;
  }
  
  public void destroy() {
      System.out.println("Destroying MyLoggingInterceptor...");
  }
  public void init() {
      System.out.println("Initializing MyLoggingInterceptor...");
  }
  }
  </code></pre>