title: Spring Security, Refresh Token & NotSerializableException
body: <p>I have the following entities:</p>
  
  <pre><code>@Entity
  @Table(name = "ct_users")
  @JsonIgnoreProperties("password", "enabled", "driver", "reviews")
  open class User(
  
      @Id
      @Column(name = "id")
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      val id: Int = 0,
  
      @Column
      val phone: String = "",
  
      @Column
      val password: String = "",
  
      @Column
      val enabled: Boolean = false,
  
      @OneToOne(fetch = FetchType.LAZY, mappedBy="profile")
      var driver: Driver? = null,
  
      @ManyToMany(fetch = FetchType.LAZY)
      @JoinTable(
          name = "ct_reviews_rel",
          joinColumns = arrayOf(JoinColumn(name = "user_id")),
          inverseJoinColumns = arrayOf(JoinColumn(name = "review_id"))
      )
      @JsonManagedReference
      var reviews: List&lt;Review&gt;? = null
  
  ) : Serializable
  </code></pre>
  
  <p>And related drivers table:</p>
  
  <pre><code>@Entity
  @Table(name = "ct_drivers")
  @JsonIgnoreProperties("password", "profile")
  class Driver(
  
      @Id
      @Column(name = "id")
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      var id: Int = 0,
  
      @Column(name = "first_name")
      var firstName: String = "",
  
      @Column(name = "last_name")
      var lastName: String = "",
  
      @Column(name = "rating")
      var rating: Double = 5.0,
  
      @Column(name = "reviews")
      var reviewsCount: Int = 0,
  
      @Column(name = "invited_by")
      var invitedBy: Int? = 0,
  
      @Column(name = "position_prev", columnDefinition = "geometry(Point,4326)")
      var positionPrev: Point = Helpers.geometry(0.0, 0.0),
  
      @Column(columnDefinition = "geometry(Point,4326)")
      var position: Point = Helpers.geometry(0.0, 0.0),
  
      @OneToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "user_id")
      var profile: User? = null,
  
      @Transient
      var distance: Int = 0
  
  ) : Serializable
  </code></pre>
  
  <p>When i try to refresh token (/oauth/token?grant_type=refresh_token&amp;client_id=abc&amp;client_secret=abcd&amp;refresh_token=...), i got the following error message:</p>
  
  <pre><code>{
    "error": "server_error",
    "error_description": "java.io.NotSerializableException: org.geolatte.geom.jts.PointSequenceCoordinateSequenceFactory"
  }
  </code></pre>
  
  <p>How can i fix it? And what is the cause of this problem?</p>
  
  <p>Helpers.geometry func:</p>
  
  <pre><code>    fun geometry(lat: Double, lng: Double): Point {
          return GeometryFactory(PrecisionModel(), 4326).createPoint(Coordinate(lat, lng))
      }
  </code></pre>