This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Struts and the fly likes interceptor problem in struts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "interceptor problem in struts2" Watch "interceptor problem in struts2" New topic

interceptor problem in struts2

sanjoy sa

Joined: Aug 19, 2009
Posts: 9
while using interceptors in struts 2 I got the following error. I used myeclipse8.5 IDE. Please advice

Aug 19, 2010 5:29:54 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
SEVERE: Dispatcher initialization failed
Caused by: Unable to find interceptor class referenced by ref-name model-driven - interceptor-ref - file:/D:/saaj/.metadata/.me_tcat/webapps/Struts2Application/WEB-INF/classes/struts.xml:49:43
at com.opensymphony.xwork2.config.providers.InterceptorBuilder.constructInterceptorReference(
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.lookupInterceptorReference(
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildInterceptorList(
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(
... 18 more
SEVERE: Exception starting filter struts2
Unable to load configuration. - interceptor-ref - file:/D:/saaj/.metadata/.me_tcat/webapps/Struts2Application/WEB-INF/classes/struts.xml:49:43
at org.apache.struts2.dispatcher.Dispatcher.init(

My struts.xml is as follows

<?xml version="1.0" encoding="UTF-8" ?>
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
<include file="struts-default.xml"></include>
<package name="default" extends="struts-default">
<exception-mapping exception="java.lang.Exception"
result="exception" />

<action name="modelAction" class="com.kogent.action.ModelAction">
<interceptor-ref name="exception" />
<interceptor-ref name="prepare" />
<interceptor-ref name="debugging" />
<interceptor-ref name="model-driven" />
<interceptor-ref name="params" />
<interceptor-ref name="conversionError" />
<interceptor-ref name="workflow" />
<result name="success">/student_info.jsp</result>
<result name="error">/model.jsp</result>
<result name="exception">/exception.jsp</result>
<result name="input">/model.jsp</result>

My web.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"


My is as follows

package com.kogent.action;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

public class ModelAction extends ActionSupport implements ModelDriven, Preparable {

private Student student;

public void prepare(){
student=new Student();
public Object getModel(){
return student;
public String execute() throws Exception {

return SUCCESS;
return ERROR;
David Newton

Joined: Sep 29, 2008
Posts: 12617

The name of the interceptor is "modelDriven"; the error message is telling you precisely what's wrong.
sanjoy sa

Joined: Aug 19, 2009
Posts: 9
Thanks David. Where exactly I will get the interceptors in the library
David Newton

Joined: Sep 29, 2008
Posts: 12617

I'm not sure what you're asking. The interceptors are defined in the struts-default.xml config file. Their names are also documented on the Struts 2 documentation site.
I agree. Here's the link:
subject: interceptor problem in struts2
It's not a secret anymore!