Schokea Schokea - 6 months ago 53
Java Question

Spring Boot data-rest Jakson JSONSerializer empty

I've a Spring Boot project 1.3.3-Release that I've deployed on to a Web Logic 12c App Server. This code works fine on the embedded tomcat but not when I deploy on to Web Logic.

I've a Spring Data-Rest Repo

@RepositoryRestResource(collectionResourceRel = "car", path = "car")
public interface CarRepo extends PagingAndSortingRepository<Meter, Long>
{
List<Car> findall();
}


My Car POJO

@Table(name="car")
@Entity
public class Car
{
@Id
@Column(name="ID")
private Long id;

@Column(name="manufacturer")
private String manufacturer;

.......
}


Everything starts up and the web page loads and when I make the rest call I can see the from SQL output the SQL Query executing fine but I then get the below error in my server logs:


java.lang.AbstractMethodError: com.fasterxml.jackson.databind.JsonSerializer.isEmpty(Ljava/lang/Object;) at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:528)


I'm assuming the data-rest is trying to automatically map the JSON Response from the endpoint into the Car object but it's failing for some unknown reason.

I've seen from the below link that there was a problem with Spring-Hateoas which I know spring-data-rest uses but seems as I'm using the latest version of spring-data-rest this shouldn't be a problem.

spring-hateoas error

Any help would be greatly appreciated

Answer

Ok so the solution is I had to tell weblogic specifically in the weblogic.xml to load the com.fasterxml.jackson packages from the application and not from it's own container.

<wls:package-name>com.fasterxml.jackson.*</wls:package-name>

Full weblogic.xml below:

<?xml version="1.0" encoding="UTF-8"?>

<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" 
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                                          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd 
                                          http://xmlns.oracle.com/weblogic/weblogic-web-app 
                                          http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
    <wls:weblogic-version>12.2.1</wls:weblogic-version>
    <wls:context-root>/ws/car</wls:context-root>
    <wls:container-descriptor>
        <wls:prefer-application-packages>
            <wls:package-name>org.slf4j.*</wls:package-name>
            <wls:package-name>javax.persistence.*</wls:package-name>
            <wls:package-name>org.springframework.*</wls:package-name>
            <wls:package-name>com.fasterxml.jackson.*</wls:package-name>
        </wls:prefer-application-packages>
    </wls:container-descriptor> </wls:weblogic-web-app>

Hope this helps others.