문제

I'm trying to integration SAIF plugin to intercept my struts action. I learn from http://struts.sourceforge.net/saif/index.html

I've write configuration like this: struts-config.xml

<plug-in className="net.sf.struts.saif.SAIFPlugin">
    <set-property property="interceptor-config" value="/WEB-INF/interceptor-config.xml" />
</plug-in>

interceptor-config.xml

<interceptor-config>
 <interceptor name="componentInterceptor" type="net.sf.struts.saif.ComponentInterceptor"/>
 <interceptor name="testInterceptor" type="net.sf.struts.saif.TestInterceptor"/>

 <default-interceptors>
  <interceptor name="componentInterceptor"/>
 </default-interceptors>

 <action type="org.apache.struts.webapp.example.EditRegistrationAction">
  <interceptor name="testInterceptor"/>
 </action>
</interceptor-config> 

I got error like this:

javax.servlet.UnavailableException: Specified RequestProcessor not compatible with saif.
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:402)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3996)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4266)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:448)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)

can you help me to solve this problem ?

도움이 되었습니까?

해결책

Quoting this message from the struts users mailing list:

It's unlikely that SAIF would work with the default S1.3 config since the request processor is different--you could try using the old request processor if your application doesn't rely on it.

AFAICT SAIF wouldn't work with anything other than the standard (old) request processor, but it might be possible to hack it up so it would.

다른 팁

I haven't worked with the Struts Action Invocation Framework before but the exception message is familiar to me from Tiles. Tiles throws a message like this: Specified RequestProcessor not compatible with TilesRequestProcessor so I think that besides the familiarity of the message (in your case Specified RequestProcessor not compatible with saif) there is also a chance that the cause be the same.

Here is an article that fixes this on the Tiles plugin. Might help you.

When the Struts Servlet is initialized it does an init of all the plugins. The message should come from the init method of your plugin and if it is the same as Tiles then a test with Class.isAssignableFrom should be the cause.

EDIT: Looked up the source code for the SAIF plugin and found this in it:

protected void initRequestProcessorClass(ActionServlet servlet, ModuleConfig config) throws ServletException {
  .........
  .........
  ControllerConfig ctrlConfig = config.getControllerConfig();
  String configProcessorClassname = ctrlConfig.getProcessorClass();
  .........
  .........
  // Check if specified request processor is compatible with saif.
  try {
    Class saifProcessorClass = SAIFRequestProcessor.class;
    Class saifTilesProcessorClass = SAIFTilesRequestProcessor.class;
    Class configProcessorClass = Class.forName(configProcessorClassname);
    if (!saifProcessorClass.isAssignableFrom(configProcessorClass)
       && !saifTilesProcessorClass.isAssignableFrom(configProcessorClass)) {
      String msg = "Specified RequestProcessor not compatible with saif.";
      throw new ServletException(msg);
    }
  } catch (Exception ex) {
    throw new ServletException(ex);
  } 
  .........
  .........
}

It seems to be the same as with Tiles plugin so the article that I indicated contains the answer.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top