Thank you! That makes perfect sense now.


On Apr 9, 2009, at 3:48 PM, "Musachy Barroso" <musa...@gmail.com> wrote:

Hi Ryan

In Convention, as well as in XML, if you try to use an interceptor or
result outside the package where it is defined, you will get an error.
You interceptor is defined in your package, and your actions are
getting mapped in Convention into another package. To fix this you
need to either: make convention put your actions in the package where
the interceptor stack is defined (using @ParentPackage, or setting
"struts.convention.default.parent.package"), or if you really need
your actions to be on a different package, you can create a new one in
xml, that extends the one that contains the interceptor, and use
@ParentPackage to point to it.

does that make some sense?

musachy

On Thu, Apr 9, 2009 at 5:39 PM, Ryan Chichirico <r...@buzzwire.com> wrote:
Can someone help me understand how to use custom interceptors with the
convention plugin?

In my struts.xml I have:

          <interceptor-stack name="defaultAuthenticationStack">
              <interceptor-ref name="initialStack"/>
              <interceptor-ref name="autoLoginStack"/>
              <!-- now check for authentication -->
              <interceptor-ref name="authenticationRequired"/>
              <interceptor-ref name="endingStack"/>
          </interceptor-stack>



Currently, we use a package via XML config and it works as expected:

  <package name="account" namespace="/account" extends="default">
      <default-interceptor-ref name="defaultAuthenticationStack"/>
  </package>

But ideally we could use the convention plugin like this:

@InterceptorRef("defaultAuthenticationStack")
@Namespace("/account" )
public class UserAccount extends ActionSupport
{
....
}

When trying to init the framework I see my struts.xml file get loaded but when the convention plugin tries to process the actions I get the following
error:
2009-04-09 14:13:52,358 INFO iders.XmlConfigurationProvider - Parsing
configuration file [struts-default.xml]
2009-04-09 14:13:52,600 INFO iders.XmlConfigurationProvider - Parsing
configuration file [struts-plugin.xml]
2009-04-09 14:13:52,972 INFO iders.XmlConfigurationProvider - Parsing
configuration file [struts.xml]
2009-04-09 14:13:53,174 INFO spring.SpringObjectFactory - Setting
autowire strategy to name
Caused by: Unable to find interceptor class referenced by ref-name
defaultAuthenticationStack - [unknown location]
  at
com. opensymphony. xwork2. config. providers. InterceptorBuilder. constructInterceptorReference(InterceptorBuilder.java:52)
  at
org. apache. struts2. convention. DefaultInterceptorMapBuilder. buildInterceptorList(DefaultInterceptorMapBuilder.java:99)
  at
org. apache. struts2. convention. DefaultInterceptorMapBuilder. build(DefaultInterceptorMapBuilder.java:90)
  at
org. apache. struts2. convention. DefaultInterceptorMapBuilder. build(DefaultInterceptorMapBuilder.java:68)
  at
org. apache. struts2. convention. PackageBasedActionConfigBuilder. createActionConfig(PackageBasedActionConfigBuilder.java:676)
  at
org. apache. struts2. convention. PackageBasedActionConfigBuilder. buildConfiguration(PackageBasedActionConfigBuilder.java:479)
  at
org. apache. struts2. convention. PackageBasedActionConfigBuilder. buildActionConfigs(PackageBasedActionConfigBuilder.java:278)
  at
org. apache. struts2. convention. ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java: 52)
  at
com. opensymphony. xwork2. config. impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java: 200)
  at
com. opensymphony. xwork2. config. ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
  ... 15 more

I noticed on the convention-plugin page that there is a reference to using a
default interceptor stack and a  custom interceptor but not a custom
interceptor stack.  I assumed you could use either.
@InterceptorRefs({
@InterceptorRef("interceptor-1"),
@InterceptorRef("defaultStack")
})
public class HelloWorld extends ActionSupport
{}


Ideas?

Thanks
-Ryan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org





--
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to