Announcement Announcement Module
No announcement yet.
IllegalStateException during Context initialization using Spring AOP, CXF, Jackson Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • IllegalStateException during Context initialization using Spring AOP, CXF, Jackson

    I'm getting the following error after enabling Spring AOP. I'm not sure why it's choking at startup trying to wire Jackson's ObjectMapper.

    Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy63 implementing com.fasterxml.jackson.core.Versioned,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.fasterxml.jackson.databind.ObjectMapper] for property 'mapper': no matching editors or conversion strategy found at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(
    I created and enabled a very simple Spring AOP aspect for logging as described in this blog post.

    <aop:aspectj-autoproxy />
    <bean id="executionTimeLogger" class="com.example.aop.ExecutionTimeLogger" />
    The ExecutionTimeLogger class is annotated with @Aspect.

    I confirmed this aspect was working for my @Service classes in JUnit test cases and also when aop is enabled through an <import> outside of the context used by my CXF resource classes. However, that configuration only provides logging in my @Service classes and I want my jaxrs:server registered beans to also provide logging via the @Aspect

    I get the error after adding my applicatonContext-aop.xml to contextConfigLocation in the web.xml

    The CXF docs state: "CXF JAX-RS is capable of working with AOP interceptors applied to resource classes from Spring". My resource classes all implement an interface.

    My CXF config looks like this:
    <jaxrs:server id="flashCardsServer" address="/"  beanNames="flashCardsResource tagsResource usersResource">
            <bean class='com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider' >
                <property name="mapper" ref="objectMapper"></property>
            <ref bean="partialResponseFilter" />
    <bean id="objectMapper" class="com.example.jackson.CustomObjectMapper" />
    Here are links to the relevant files in my GitHub project:

    I'm using the following library versions
    spring-aop 3.1.1
    aspectjtools 1.7.2
    cxf 2.5.1
    jackson 2.0.2

    PS: I posted this same question to StackOverflow yesterday but haven't received any responses yet. I figured I'd try posting it here also in case any of the Spring AOP experts can provide some insight. Many thanks.