I managed to get this working in as far as implementing the before advice (using aop namespace - thanks Grzegorz!) for the servlet's service method. But, I got stuck while trying to test if the request was a ServletServiceRequest - instanceof fails as the arguments are passed as some sort of proxy object from Spring and I have no idea how to de-proxy them.

As I'm limited for time, I've just put the check within my servlet and made it configurable which works for me and doesn't require me to add the aspectj dependencies needed for Spring advice. I would prefer a more generic solution that would work with any servlet though, so if anyone has any ideas....

thanks,

Robin


On 25 Mar 2008, at 15:34, Robin Wyles wrote:

Hi Grzegorz,

I'm still getting to grips with Spring... I've taken a quick look at the aop namespace docs but can't see yet how to define a method advisor using an interceptor bean - I'll keep digging. In the meantime here is the stacktrace:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.jac.exist.cocoon-exist.service' defined in URL [file:/Users/robinwyles/Work/james/cocoon-exist/ target/classes/META-INF/cocoon/spring/blockServlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'contextPath' of bean class [org.springframework.aop.framework.ProxyFactoryBean]: No property 'contextPath' found at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.doCreateBean(AbstractAutowireCapableBeanFactory.java:445) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory$1.run(AbstractAutowireCapableBeanFactory.java:383)
        at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.createBean(AbstractAutowireCapableBeanFactory.java:353) at org.springframework.beans.factory.support.AbstractBeanFactory $1.getObject(AbstractBeanFactory.java:245) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry .getSingleton(DefaultSingletonBeanRegistry.java:169) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean( AbstractBeanFactory.java:242) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean( AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.p reInstantiateSingletons(DefaultListableBeanFactory.java:394) at org.springframework.context.support.AbstractApplicationContext.finishB eanFactoryInitialization(AbstractApplicationContext.java:736) at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:369) at org.apache.cocoon.tools.rcl.springreloader.SynchronizedConfigureableWe bApplicationContext.refresh (SynchronizedConfigureableWebApplicationContext.java:247) at org.springframework.web.context.ContextLoader.createWebApplicationCont ext(ContextLoader.java:261) at org.springframework.web.context.ContextLoader.initWebApplicationContex t(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitializ ed(ContextLoaderListener.java:45) at org.apache.cocoon.tools.rcl.wrapper.servlet.ReloadingListener.invoke (ReloadingListener.java:157) at org.apache.cocoon.tools.rcl.wrapper.servlet.ReloadingListener.contextI nitialized(ReloadingListener.java:213) at org.mortbay.jetty.servlet.WebApplicationContext.doStart (WebApplicationContext.java:495)
        at org.mortbay.util.Container.start(Container.java:72)
        at org.mortbay.http.HttpServer.doStart(HttpServer.java:708)
        at org.mortbay.util.Container.start(Container.java:72)
at com.iw.plugins.jettyrunner.PluginRunner.launch (PluginRunner.java:282) at com.iw.plugins.jettyrunner.PluginRunner.launch (PluginRunner.java:104)
        at com.iw.plugins.jettyrunner.PluginRunner.main(PluginRunner.java:75)
Caused by: org.springframework.beans.InvalidPropertyException: Invalid property 'contextPath' of bean class [org.springframework.aop.framework.ProxyFactoryBean]: No property 'contextPath' found at org.springframework.beans.BeanWrapperImpl.convertForProperty (BeanWrapperImpl.java:377) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.convertForProperty(AbstractAutowireCapableBeanFactory.java: 1211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java: 1177) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.populateBean(AbstractAutowireCapableBeanFactory.java:940) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.doCreateBean(AbstractAutowireCapableBeanFactory.java:437)
        ... 23 more
getRootCause():
org.springframework.beans.InvalidPropertyException: Invalid property 'contextPath' of bean class [org.springframework.aop.framework.ProxyFactoryBean]: No property 'contextPath' found at org.springframework.beans.BeanWrapperImpl.convertForProperty (BeanWrapperImpl.java:377) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.convertForProperty(AbstractAutowireCapableBeanFactory.java: 1211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java: 1177) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.populateBean(AbstractAutowireCapableBeanFactory.java:940) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.doCreateBean(AbstractAutowireCapableBeanFactory.java:437) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory$1.run(AbstractAutowireCapableBeanFactory.java:383)
        at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanF actory.createBean(AbstractAutowireCapableBeanFactory.java:353) at org.springframework.beans.factory.support.AbstractBeanFactory $1.getObject(AbstractBeanFactory.java:245) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry .getSingleton(DefaultSingletonBeanRegistry.java:169) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean( AbstractBeanFactory.java:242) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean( AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.p reInstantiateSingletons(DefaultListableBeanFactory.java:394) at org.springframework.context.support.AbstractApplicationContext.finishB eanFactoryInitialization(AbstractApplicationContext.java:736) at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:369) at org.apache.cocoon.tools.rcl.springreloader.SynchronizedConfigureableWe bApplicationContext.refresh (SynchronizedConfigureableWebApplicationContext.java:247) at org.springframework.web.context.ContextLoader.createWebApplicationCont ext(ContextLoader.java:261) at org.springframework.web.context.ContextLoader.initWebApplicationContex t(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitializ ed(ContextLoaderListener.java:45) at org.apache.cocoon.tools.rcl.wrapper.servlet.ReloadingListener.invoke (ReloadingListener.java:157) at org.apache.cocoon.tools.rcl.wrapper.servlet.ReloadingListener.contextI nitialized(ReloadingListener.java:213) at org.mortbay.jetty.servlet.WebApplicationContext.doStart (WebApplicationContext.java:495)
        at org.mortbay.util.Container.start(Container.java:72)
        at org.mortbay.http.HttpServer.doStart(HttpServer.java:708)
        at org.mortbay.util.Container.start(Container.java:72)
at com.iw.plugins.jettyrunner.PluginRunner.launch (PluginRunner.java:282) at com.iw.plugins.jettyrunner.PluginRunner.launch (PluginRunner.java:104)
        at com.iw.plugins.jettyrunner.PluginRunner.main(PluginRunner.java:75)


Thanks,

Robin

On 25 Mar 2008, at 15:43, Grzegorz Kossakowski wrote:

Robin Wyles pisze:
Hi,

I'm trying to follow Grzegorz's suggestion and have configured my method
servlet as follows:


  <bean name="com.jac.exist.cocoon-exist.service"
    class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="interceptorNames">
      <list>
        <value>service.pointcut.advisor</value>
        <value>com.jac.exist.cocoon-exist.serviceTarget</value>
      </list>
    </property>
  </bean>

May I ask why don't you use aop namespace that would increase readability of your configuration files?

This results in the following error:

Invalid property 'contextPath' of bean class
[org.springframework.aop.framework.ProxyFactoryBean]: No property
'contextPath' found

I can't see where I've misconfigured - The same sort of config works for
advice I have set on other beans.

Could you paste a stacktrace?

--
Grzegorz

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to