0

I have tried all the solutions provided on SO this and this and many others but nothing seems to solve my problem. I am getting below exception

com.fasterxml.jackson.databind.JsonMappingException: could not initialize proxy - no Session (through reference chain: java.util.ArrayList[0]-

I am not getting why spring using fasterxml.jackson while with previous version it was using it from codehaus

previous spring version 3.1.2.Release current spring version 4.1.6.Release

Community
  • 1
  • 1
ankit
  • 4,919
  • 7
  • 38
  • 63
  • besides the package name update, I guess this is related to transacitons (Hibernate, JPA etc.), would you provide the related stacktrace and code? – hsluo Apr 27 '15 at 09:15
  • @hsluo thanks for your reply, I have solved this problem by changing codehaus jackson to fasterxml jackson – ankit Apr 27 '15 at 09:51

2 Answers2

3

You should do quite the opposite to what is recommended in the links you've posted, so change the package of your Jackson classes from org.codehaus.jackson to com.fasterxml.jackson

As of Spring Framework 4.1, the minimum jackson version should be 2.1 (2.3 recommended). The relevent change, and the suspected cause of your issue is that with jackson 2.x there has been a package shift as well

  • Java package used is "com.fasterxml.jackson" (instead of "org.codehaus.jackson")
  • Maven group ids begin with"com.fasterxml.jackson" (instead of "org.codehaus.jackson")

If you're using maven just replace your current jackson dependencies with this single one

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.5.1</version>
    </dependency>
Alanight
  • 353
  • 2
  • 8
  • 23
Master Slave
  • 27,771
  • 4
  • 57
  • 55
0

Older versions of Spring used Jackson 1.9, which has classes in the org.codehaus.jackson package. Spring 4.1.6.Release uses Jackson 2.x, which has its classes in com.fasterxml.jackson package. Therefore old annotations are simply ignored.

pkalinow
  • 1,619
  • 1
  • 17
  • 43