# [已解决]无法找到 ref-name 引用的拦截器类 > 原文: [https://howtodoinjava.com/struts2/solved-unable-to-find-interceptor-class-referenced-by-ref-name/](https://howtodoinjava.com/struts2/solved-unable-to-find-interceptor-class-referenced-by-ref-name/) 在为 [**@InterceptorRef 示例**](//howtodoinjava.com/struts-2/struts-2-custom-interceptor-with-interceptorref-example/ "Struts 2 custom interceptor with @InterceptorRef example") 编写代码时,我才知道此功能。 我必须在 struts.xml 文件中声明拦截器定义,而我想通过注释使用拦截器。 第一次尝试时,失败并显示以下错误: ```java Unable to load configuration. - [unknown location] at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490) Caused by: Unable to find interceptor class referenced by ref-name customStack - [unknown location] at com.opensymphony.xwork2.config.providers.InterceptorBuilder.constructInterceptorReference(InterceptorBuilder.java:63) at org.apache.struts2.convention.DefaultInterceptorMapBuilder.buildInterceptorList(DefaultInterceptorMapBuilder.java:95) at org.apache.struts2.convention.DefaultInterceptorMapBuilder.build(DefaultInterceptorMapBuilder.java:86) at org.apache.struts2.convention.DefaultInterceptorMapBuilder.build(DefaultInterceptorMapBuilder.java:64) ``` ## 原因: 默认情况下,Convention 插件使用其自己的包 Convention-default,其中不包含您在 struts.xml 中定义的包。 这意味着 Convention 将在其中放置您的操作的包不会扩展定义拦截器的包。 ![Random exceptions](img/bfcee52d8f51b09dd5024f261008e635.png) Random exceptions ## 解: 要更改,您有两个选择: 1) Use of `@ParentPackage` annotation 2) Define in struts.xml 例如: ```java ``` 这样可以解决问题。 **祝您学习愉快!**