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

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

    Summary:
    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.

    Code:
    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(TypeConverterDelegate.java:241)
    Details:
    I created and enabled a very simple Spring AOP aspect for logging as described in this blog post.

    Code:
    <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:
    Code:
    <jaxrs:server id="flashCardsServer" address="/"  beanNames="flashCardsResource tagsResource usersResource">
        <jaxrs:providers>
            <bean class='com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider' >
                <property name="mapper" ref="objectMapper"></property>
            </bean>
            <ref bean="partialResponseFilter" />
        </jaxrs:providers>
    </jaxrs:server>
    
    <bean id="objectMapper" class="com.example.jackson.CustomObjectMapper" />
    Links:
    Here are links to the relevant files in my GitHub project:
    applicatonContext-webServices.xml
    applicatonContext-aop.xml
    ExecutionTimeLogger.java

    Versions:
    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.
Working...
X