Giter Site home page Giter Site logo

Comments (18)

nmorel avatar nmorel commented on July 29, 2024 1

Your fields are private and your constructor isn't annotated with @JsonCreator nor the parameters with @JsonProperty. So it means, gwt-jackson uses the default constructor (even if private) and it does not find any property because there is no setter or accessible property (getters does not count in deserialization).

If you want to keep your object without setter, you can

  • add @JsonProperty to your fields. gwt-jackson will still use the private constructor and set the private fields with jsni.
  • add @JsonCreator to your constructor and @JsonProperty to all of the parameters. gwt-jckson will then use this constructor.
  • a third option is to change the detection of your fields with @JsonAutoDetect and put fieldVisibility to ANY and gwt-jackson will do the same as in solution 1.

from gwt-jackson.

nmorel avatar nmorel commented on July 29, 2024

np :) I could add a forum in google group but for now, I just watch stackoverflow and GWTP for questions. And of course, the issues here!

It is possible with jackson annotations. In order to deserialize an interface, you need to add informations about the implementation. It is done with @JsonTypeInfo. This annotation tell jackson to add the information about the implementation when serializing.

You should be able to find example on google. You can also check my tests here

from gwt-jackson.

BenDol avatar BenDol commented on July 29, 2024

So I added:
@JsonTypeInfo( use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY )
to my ProcessPageData interface and:
@JsonTypeInfo( use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class" )
to my classes implementing ProcessPageData, but now I get this error:
Cannot find the property @class containing the type information
was just using your tests as an example.

Just realized, your tests are on abstract classes not interfaces, that is probably the issue.

from gwt-jackson.

nmorel avatar nmorel commented on July 29, 2024

You should remove @JsonTypeInfo from the implementation class. It's only needed on top classes.
You are overriding the annotation from the interface.
Here you are telling jackson to add the class name for your implementation inside the property class.

But on deserialization, Jackson only sees the interface and read the @JsonTypeInfo from it. By default, the property used is @class.

from gwt-jackson.

BenDol avatar BenDol commented on July 29, 2024

Does this only work on abstract class? I can't find any examples of this on interfaces.

@JsonTypeInfo( use = JsonTypeInfo.Id.MINIMAL_CLASS )
public interface ProcessPageData extends Serializable {
}

This gives me Cannot find the property @c containing the type information

from gwt-jackson.

nmorel avatar nmorel commented on July 29, 2024

No, it should also work on interface. What is the json you are passing to gwt-jackson ? Does it contain the @c property ?

from gwt-jackson.

BenDol avatar BenDol commented on July 29, 2024

This is the result:

{"activities":[{"id":1,"name":"Product Loading - Road Vehicle","description":"Product Loading - Road Vehicle description here!","order":0,"removed":false},{"id":2,"name":"Site Administration","description":"Site Administration description here!","order":0,"removed":false},{"id":3,"name":"Bulk Storage","description":"Bulk Storage description here!","order":0,"removed":false},{"id":4,"name":"Marine Loading - Bunker","description":"Marine Loading - Bunker description here!","order":0,"removed":false},{"id":5,"name":"Receipt in Stock - Tank Ship","description":"Receipt in Stock - Tank Ship description here!","order":0,"removed":false},{"id":6,"name":"Maintenance and Calibration","description":"Maintenance and Calibration description here!","order":0,"removed":false},{"id":7,"name":"Product Receipting / Loading - Pipeline","description":"Product Receipting / Loading - Pipeline description here!","order":0,"removed":false},{"id":8,"name":"Engineering","description":"Engineering description here!","order":0,"removed":false},{"id":9,"name":"Central Office Administration","description":"Central Office Administration here!","order":0,"removed":false}],"authorities":[{"id":1,"name":"Ambulance & Hospital","description":"Ambulance description here!","notifiable":false,"groupName":"Emergency","order":0,"removed":false},{"id":2,"name":"Civil Aviation Authority","description":"Civil Aviation Authority description here!","notifiable":false,"groupName":"Authorities","order":0,"removed":false},{"id":3,"name":"Civil Defence","description":"Civil Defence description here!","notifiable":false,"groupName":"Emergency","order":0,"removed":false},{"id":4,"name":"Environmental Protection Authority (EPA)","description":"Environmental Protection Authority (EPA) description here!","notifiable":false,"groupName":"Authorities","order":0,"removed":false},{"id":5,"name":"NZ Fire Services","description":"NZ Fire Services description here!","notifiable":false,"groupName":"Emergency","order":0,"removed":false},{"id":6,"name":"NZ Police","description":"NZ Police description here!","notifiable":false,"groupName":"Emergency","order":0,"removed":false},{"id":7,"name":"CentrePort (Hutt City)","description":"CentrePort (Hutt City) description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"id":8,"name":"Lyttelton Port of Christchurch","description":"Lyttelton Port of Christchurch description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"id":9,"name":"Port Marlborough","description":"Port Marlborough description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"id":10,"name":"Port Nelson","description":"Port Nelson description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"id":11,"name":"Port of Napier","description":"Port of Napier description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"id":12,"name":"Port of Tauranga","description":"Port of Tauranga description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"id":13,"name":"Port Otago (Dunedin)","description":"Port Otago (Dunedin) description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"id":14,"name":"Port Taranaki (New Plymouth)","description":"Port Taranaki (New Plymouth) description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"id":15,"name":"Primeport (Timaru)","description":"Primeport (Timaru) description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"id":16,"name":"South Port (Bluff)","description":"South Port (Bluff) description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"id":17,"name":"Bay of Plenty Regional Council","description":"Bay of Plenty Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"id":18,"name":"Canterbury Regional Council","description":"Canterbury Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"id":19,"name":"Hawke's Bay Regional Council","description":"Hawke's Bay Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"id":20,"name":"Nelson City Council","description":"Nelson City Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"id":21,"name":"Otago Regional Council","description":"Otago Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"id":22,"name":"Southland Regional Council","description":"Southland Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"id":23,"name":"Taranaki Regional Council","description":"Taranaki Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"id":24,"name":"Wellington Regional Council","description":"Wellington Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"id":25,"name":"Worksafe NZ","description":"Worksafe NZ descriprion here!","notifiable":true,"groupName":"Authorities","order":0,"removed":false}],"severities":[{"id":1,"name":"No Harm","description":"No harm or impact to the business.","level":0,"orderValue":1,"removed":false,"displayName":"No Harm"},{"id":2,"name":"Minor","description":"Minor harm or impact. For example minor harm to individuals requiring first aid; small spill removed with the small spill kit; operational losses under $10k or local public awareness of reputation but no discernable media coverage.","level":1,"orderValue":2,"removed":false,"displayName":"Minor"},{"id":3,"name":"Moderate","description":"Moderate e.g. Minor injury or health effect – causingrestricted work injury or lost time where hospitalisation for more than 24 hours not required. Moderate environmental damage but no lasting effect. Examples: Small spill - less than 20 Litres, off-site. Or a brief disruption to operation.","level":2,"orderValue":3,"removed":false,"displayName":"Moderate"},{"id":4,"name":"Serious","description":"Serious e.g. Serious injury or health effect – causing loss of bodily function for more than 24 hours. Limited environmental damage that will persist or require cleaning up. Examples: Serious spill (>100 L and <= to 1000 L). Partial shut-down.","level":3,"orderValue":4,"removed":false,"displayName":"Serious"},{"id":5,"name":"Major","description":"Major e.g. Permanent total disability or a single fatality resulting from injury or occupational illness. And/or 10 or more injuries. Severe environmental damage that will require extensive measures to restore. Costs in excess of $ 1 million or up to two weeks shut down.","level":4,"orderValue":5,"removed":false,"displayName":"Major"},{"id":6,"name":"Catastrophic","description":"Multiple fatalities. Persistent sever environmental damage. Costs in excess of $ 10 million. Substantial or total loss of operation.","level":5,"orderValue":6,"removed":false,"displayName":"Catastrophic"}],"locations":[{"id":1,"name":"Mt Maunganui","description":"Mt Maunganui description here!","order":0,"removed":false,"sites":[],"displayName":"Mt Maunganui","orderValue":0},{"id":2,"name":"New Plymouth","description":"New Plymouth description here!","order":0,"removed":false,"sites":[],"displayName":"New Plymouth","orderValue":0},{"id":3,"name":"Napier","description":"Napier description here!","order":0,"removed":false,"sites":[],"displayName":"Napier","orderValue":0},{"id":4,"name":"Hutt City","description":"Hutt City description here!","order":0,"removed":false,"sites":[],"displayName":"Hutt City","orderValue":0},{"id":5,"name":"Wellington","description":"Wellington description here!","order":0,"removed":false,"sites":[],"displayName":"Wellington","orderValue":0},{"id":6,"name":"Nelson","description":"Nelson description here!","order":0,"removed":false,"sites":[],"displayName":"Nelson","orderValue":0},{"id":7,"name":"Lyttelton","description":"Lyttelton description here!","order":0,"removed":false,"sites":[],"displayName":"Lyttelton","orderValue":0},{"id":8,"name":"Timaru","description":"Timaru description here!","order":0,"removed":false,"sites":[],"displayName":"Timaru","orderValue":0},{"id":9,"name":"Dunedin","description":"Dunedin description here!","order":0,"removed":false,"sites":[],"displayName":"Dunedin","orderValue":0},{"id":10,"name":"Bluff","description":"Bluff description here!","order":0,"removed":false,"sites":[],"displayName":"Bluff","orderValue":0}]}

Think I know whats going on

from gwt-jackson.

nmorel avatar nmorel commented on July 29, 2024

The property is not present. If it's coming from a server, maybe it is not up to date ?

from gwt-jackson.

BenDol avatar BenDol commented on July 29, 2024

It works! Okay the server didn't resynchronize the changes haha

from gwt-jackson.

BenDol avatar BenDol commented on July 29, 2024

Its not throwing errors, but none of the data is being mapped. Any ideas why that might be?

from gwt-jackson.

nmorel avatar nmorel commented on July 29, 2024

Hmm no. Can you give me the json for one of your object and the definition of your interface and implementation ?

from gwt-jackson.

BenDol avatar BenDol commented on July 29, 2024

Interface:

@JsonTypeInfo( use = JsonTypeInfo.Id.CLASS )
public interface ProcessPageData extends Serializable {
}

Class:

/**
 * @author Ben Dol
 */
@SuppressWarnings({ "unused", "serial" })
public class OpenIncidentData implements ProcessPageData {
    private List<Activity> activities;
    private List<Authority> authorities;
    private List<Severity> severities;
    private List<Location> locations;

    private OpenIncidentData() {
        // For serialization only
    }

    public OpenIncidentData(List<Activity> activities, List<Authority> authorities,
                            List<Severity> severities, List<Location> locations) {
        this.activities = activities;
        this.authorities = authorities;
        this.severities = severities;
        this.locations = locations;
    }

    public List<Activity> getActivities() {
        return activities;
    }

    public List<Authority> getAuthorities() {
        return authorities;
    }

    public List<Severity> getSeverities() {
        return severities;
    }

    public List<Location> getLocations() {
        return locations;
    }
}

Json:

{"@class":"nz.co.doltech.ims.shared.core.OpenIncidentData","activities":[{"@class":"nz.co.doltech.ims.shared.domains.Activity","id":1,"name":"Product Loading - Road Vehicle","description":"Product Loading - Road Vehicle description here!","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Activity","id":2,"name":"Site Administration","description":"Site Administration description here!","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Activity","id":3,"name":"Bulk Storage","description":"Bulk Storage description here!","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Activity","id":4,"name":"Marine Loading - Bunker","description":"Marine Loading - Bunker description here!","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Activity","id":5,"name":"Receipt in Stock - Tank Ship","description":"Receipt in Stock - Tank Ship description here!","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Activity","id":6,"name":"Maintenance and Calibration","description":"Maintenance and Calibration description here!","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Activity","id":7,"name":"Product Receipting / Loading - Pipeline","description":"Product Receipting / Loading - Pipeline description here!","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Activity","id":8,"name":"Engineering","description":"Engineering description here!","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Activity","id":9,"name":"Central Office Administration","description":"Central Office Administration here!","order":0,"removed":false}],"authorities":[{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":1,"name":"Ambulance & Hospital","description":"Ambulance description here!","notifiable":false,"groupName":"Emergency","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":2,"name":"Civil Aviation Authority","description":"Civil Aviation Authority description here!","notifiable":false,"groupName":"Authorities","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":3,"name":"Civil Defence","description":"Civil Defence description here!","notifiable":false,"groupName":"Emergency","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":4,"name":"Environmental Protection Authority (EPA)","description":"Environmental Protection Authority (EPA) description here!","notifiable":false,"groupName":"Authorities","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":5,"name":"NZ Fire Services","description":"NZ Fire Services description here!","notifiable":false,"groupName":"Emergency","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":6,"name":"NZ Police","description":"NZ Police description here!","notifiable":false,"groupName":"Emergency","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":7,"name":"CentrePort (Hutt City)","description":"CentrePort (Hutt City) description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":8,"name":"Lyttelton Port of Christchurch","description":"Lyttelton Port of Christchurch description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":9,"name":"Port Marlborough","description":"Port Marlborough description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":10,"name":"Port Nelson","description":"Port Nelson description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":11,"name":"Port of Napier","description":"Port of Napier description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":12,"name":"Port of Tauranga","description":"Port of Tauranga description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":13,"name":"Port Otago (Dunedin)","description":"Port Otago (Dunedin) description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":14,"name":"Port Taranaki (New Plymouth)","description":"Port Taranaki (New Plymouth) description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":15,"name":"Primeport (Timaru)","description":"Primeport (Timaru) description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":16,"name":"South Port (Bluff)","description":"South Port (Bluff) description here!","notifiable":false,"groupName":"Port Company","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":17,"name":"Bay of Plenty Regional Council","description":"Bay of Plenty Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":18,"name":"Canterbury Regional Council","description":"Canterbury Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":19,"name":"Hawke's Bay Regional Council","description":"Hawke's Bay Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":20,"name":"Nelson City Council","description":"Nelson City Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":21,"name":"Otago Regional Council","description":"Otago Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":22,"name":"Southland Regional Council","description":"Southland Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":23,"name":"Taranaki Regional Council","description":"Taranaki Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":24,"name":"Wellington Regional Council","description":"Wellington Regional Council description here!","notifiable":false,"groupName":"Regional or City Council","order":0,"removed":false},{"@class":"nz.co.doltech.ims.shared.domains.Authority","id":25,"name":"Worksafe NZ","description":"Worksafe NZ descriprion here!","notifiable":true,"groupName":"Authorities","order":0,"removed":false}],"severities":[{"@class":"nz.co.doltech.ims.shared.domains.Severity","id":1,"name":"No Harm","description":"No harm or impact to the business.","level":0,"orderValue":1,"removed":false,"displayName":"No Harm"},{"@class":"nz.co.doltech.ims.shared.domains.Severity","id":2,"name":"Minor","description":"Minor harm or impact. For example minor harm to individuals requiring first aid; small spill removed with the small spill kit; operational losses under $10k or local public awareness of reputation but no discernable media coverage.","level":1,"orderValue":2,"removed":false,"displayName":"Minor"},{"@class":"nz.co.doltech.ims.shared.domains.Severity","id":3,"name":"Moderate","description":"Moderate e.g. Minor injury or health effect – causingrestricted work injury or lost time where hospitalisation for more than 24 hours not required. Moderate environmental damage but no lasting effect. Examples: Small spill - less than 20 Litres, off-site. Or a brief disruption to operation.","level":2,"orderValue":3,"removed":false,"displayName":"Moderate"},{"@class":"nz.co.doltech.ims.shared.domains.Severity","id":4,"name":"Serious","description":"Serious e.g. Serious injury or health effect – causing loss of bodily function for more than 24 hours. Limited environmental damage that will persist or require cleaning up. Examples: Serious spill (>100 L and <= to 1000 L). Partial shut-down.","level":3,"orderValue":4,"removed":false,"displayName":"Serious"},{"@class":"nz.co.doltech.ims.shared.domains.Severity","id":5,"name":"Major","description":"Major e.g. Permanent total disability or a single fatality resulting from injury or occupational illness. And/or 10 or more injuries. Severe environmental damage that will require extensive measures to restore. Costs in excess of $ 1 million or up to two weeks shut down.","level":4,"orderValue":5,"removed":false,"displayName":"Major"},{"@class":"nz.co.doltech.ims.shared.domains.Severity","id":6,"name":"Catastrophic","description":"Multiple fatalities. Persistent sever environmental damage. Costs in excess of $ 10 million. Substantial or total loss of operation.","level":5,"orderValue":6,"removed":false,"displayName":"Catastrophic"}],"locations":[{"@class":"nz.co.doltech.ims.shared.domains.Location","id":1,"name":"Mt Maunganui","description":"Mt Maunganui description here!","order":0,"removed":false,"sites":[],"displayName":"Mt Maunganui","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Location","id":2,"name":"New Plymouth","description":"New Plymouth description here!","order":0,"removed":false,"sites":[],"displayName":"New Plymouth","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Location","id":3,"name":"Napier","description":"Napier description here!","order":0,"removed":false,"sites":[],"displayName":"Napier","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Location","id":4,"name":"Hutt City","description":"Hutt City description here!","order":0,"removed":false,"sites":[],"displayName":"Hutt City","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Location","id":5,"name":"Wellington","description":"Wellington description here!","order":0,"removed":false,"sites":[],"displayName":"Wellington","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Location","id":6,"name":"Nelson","description":"Nelson description here!","order":0,"removed":false,"sites":[],"displayName":"Nelson","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Location","id":7,"name":"Lyttelton","description":"Lyttelton description here!","order":0,"removed":false,"sites":[],"displayName":"Lyttelton","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Location","id":8,"name":"Timaru","description":"Timaru description here!","order":0,"removed":false,"sites":[],"displayName":"Timaru","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Location","id":9,"name":"Dunedin","description":"Dunedin description here!","order":0,"removed":false,"sites":[],"displayName":"Dunedin","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Location","id":10,"name":"Bluff","description":"Bluff description here!","order":0,"removed":false,"sites":[],"displayName":"Bluff","orderValue":0}]}

The GWTP Rest Service:

@Path(PROCESSES)
public interface ProcessesService extends EntitiesService<Process> {
    @GET
    @Path(PATH_ID + PATH_DATA)
    RestAction<ProcessPageData> loadData(@PathParam(ID) int id, @HeaderParam(CACHE_CONTROL) String caching);
}

from gwt-jackson.

BenDol avatar BenDol commented on July 29, 2024

Thanks for all the help man, really appreciate it!

from gwt-jackson.

nmorel avatar nmorel commented on July 29, 2024

You're welcome :)

from gwt-jackson.

BenDol avatar BenDol commented on July 29, 2024

Sooooo, almost getting it sorted! Haha can't figure out why this isn't deserializing:

This is my GWTP rest service:

@Path(LOCATIONS)
public interface LocationsService extends EntitiesService<Location> {
    @GET
    @Path(PATH_ID + SITES + PATH_ID + AREAS)
    RestAction<SiteAreaData> getSiteAreaChain(@PathParam(ID) int id, @PathParam(ID) int siteId, @HeaderParam(CACHE_CONTROL) String caching);
}
public interface EntitiesService<T extends DomainObject> {
    @GET
    RestAction<ArrayList<T>> getAll(@QueryParam(FETCH) boolean fetch,
        @HeaderParam(CACHE_CONTROL) String caching);
}

It returns this Json:

[{"id":1,"name":"Mt Maunganui","description":"Mt Maunganui description here!","order":0,"removed":false,"sites":[{"@class":"nz.co.doltech.ims.shared.domains.Site","id":1,"name":"Mt Maunganui Terminal","description":"Mt Maunganui Terminal description here!","order":0,"removed":false,"location":1,"areas":[],"displayName":"Mt Maunganui Terminal","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":2,"name":"Mt Maunganui Offsite","description":"Mt Maunganui Offsite description here!","order":0,"removed":false,"location":1,"areas":[],"displayName":"Mt Maunganui Offsite","orderValue":0}],"displayName":"Mt Maunganui","orderValue":0},{"id":2,"name":"New Plymouth","description":"New Plymouth description here!","order":0,"removed":false,"sites":[{"@class":"nz.co.doltech.ims.shared.domains.Site","id":5,"name":"New Plymouth Offsite","description":"New Plymouth Offsite description here!","order":0,"removed":false,"location":2,"areas":[],"displayName":"New Plymouth Offsite","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":4,"name":"New Plymouth Z Energy Terminal","description":"New Plymouth Z Energy Terminal description here!","order":0,"removed":false,"location":2,"areas":[],"displayName":"New Plymouth Z Energy Terminal","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":3,"name":"New Plymouth BP Terminal","description":"New Plymouth BP Terminal description here!","order":0,"removed":false,"location":2,"areas":[],"displayName":"New Plymouth BP Terminal","orderValue":0}],"displayName":"New Plymouth","orderValue":0},{"id":3,"name":"Napier","description":"Napier description here!","order":0,"removed":false,"sites":[{"@class":"nz.co.doltech.ims.shared.domains.Site","id":7,"name":"Napier Offsite","description":"Napier Offsite description here!","order":0,"removed":false,"location":3,"areas":[],"displayName":"Napier Offsite","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":6,"name":"Napier Terminal","description":"Napier Terminal description here!","order":0,"removed":false,"location":3,"areas":[],"displayName":"Napier Terminal","orderValue":0}],"displayName":"Napier","orderValue":0},{"id":4,"name":"Hutt City","description":"Hutt City description here!","order":0,"removed":false,"sites":[{"@class":"nz.co.doltech.ims.shared.domains.Site","id":9,"name":"Hutt City Offsite","description":"Hutt City Offsite description here!","order":0,"removed":false,"location":4,"areas":[],"displayName":"Hutt City Offsite","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":8,"name":"Hutt City Terminal","description":"Hutt City Terminal description here!","order":0,"removed":false,"location":4,"areas":[],"displayName":"Hutt City Terminal","orderValue":0}],"displayName":"Hutt City","orderValue":0},{"id":5,"name":"Wellington","description":"Wellington description here!","order":0,"removed":false,"sites":[{"@class":"nz.co.doltech.ims.shared.domains.Site","id":10,"name":"Central Office","description":"Central Office description here!","order":0,"removed":false,"location":5,"areas":[],"displayName":"Central Office","orderValue":0}],"displayName":"Wellington","orderValue":0},{"id":6,"name":"Nelson","description":"Nelson description here!","order":0,"removed":false,"sites":[{"@class":"nz.co.doltech.ims.shared.domains.Site","id":13,"name":"Nelson Offsite","description":"Nelson Offsite description here!","order":0,"removed":false,"location":6,"areas":[],"displayName":"Nelson Offsite","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":12,"name":"Nelson BP Terminal","description":"Nelson BP Terminal description here!","order":0,"removed":false,"location":6,"areas":[],"displayName":"Nelson BP Terminal","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":11,"name":"Nelson Z Energy Terminal","description":"Nelson Z Energy Terminal description here!","order":0,"removed":false,"location":6,"areas":[],"displayName":"Nelson Z Energy Terminal","orderValue":0}],"displayName":"Nelson","orderValue":0},{"id":7,"name":"Lyttelton","description":"Lyttelton description here!","order":0,"removed":false,"sites":[{"@class":"nz.co.doltech.ims.shared.domains.Site","id":15,"name":"Lyttelton Z Energy Site 2","description":"Lyttelton Z Energy Site 2 description here!","order":0,"removed":false,"location":7,"areas":[],"displayName":"Lyttelton Z Energy Site 2","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":14,"name":"Lyttelton Z Energy Site 1","description":"Lyttelton Z Energy Site 1 description here!","order":0,"removed":false,"location":7,"areas":[],"displayName":"Lyttelton Z Energy Site 1","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":18,"name":"Lyttelton Offsite","description":"Lyttelton Offsite description here!","order":0,"removed":false,"location":7,"areas":[],"displayName":"Lyttelton Offsite","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":16,"name":"Lyttelton Z Energy Site 3","description":"Lyttelton Z Energy Site 3 description here!","order":0,"removed":false,"location":7,"areas":[],"displayName":"Lyttelton Z Energy Site 3","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":17,"name":"Lyttelton BP Terminal","description":"Lyttelton BP Terminal description here!","order":0,"removed":false,"location":7,"areas":[],"displayName":"Lyttelton BP Terminal","orderValue":0}],"displayName":"Lyttelton","orderValue":0},{"id":8,"name":"Timaru","description":"Timaru description here!","order":0,"removed":false,"sites":[{"@class":"nz.co.doltech.ims.shared.domains.Site","id":20,"name":"Timaru Offsite","description":"Timaru Offsite description here!","order":0,"removed":false,"location":8,"areas":[],"displayName":"Timaru Offsite","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":19,"name":"Timaru Terminal","description":"Timaru Terminal description here!","order":0,"removed":false,"location":8,"areas":[],"displayName":"Timaru Terminal","orderValue":0}],"displayName":"Timaru","orderValue":0},{"id":9,"name":"Dunedin","description":"Dunedin description here!","order":0,"removed":false,"sites":[{"@class":"nz.co.doltech.ims.shared.domains.Site","id":22,"name":"Dunedin Z Energy Terminal","description":"Dunedin Z Energy Terminal description here!","order":0,"removed":false,"location":9,"areas":[],"displayName":"Dunedin Z Energy Terminal","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":23,"name":"Dunedin Offsite","description":"Dunedin Offsite description here!","order":0,"removed":false,"location":9,"areas":[],"displayName":"Dunedin Offsite","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":21,"name":"Dunedin BP Terminal","description":"Dunedin BP Terminal description here!","order":0,"removed":false,"location":9,"areas":[],"displayName":"Dunedin BP Terminal","orderValue":0}],"displayName":"Dunedin","orderValue":0},{"id":10,"name":"Bluff","description":"Bluff description here!","order":0,"removed":false,"sites":[{"@class":"nz.co.doltech.ims.shared.domains.Site","id":24,"name":"Bluff Terminal","description":"Bluff Terminal description here!","order":0,"removed":false,"location":10,"areas":[],"displayName":"Bluff Terminal","orderValue":0},{"@class":"nz.co.doltech.ims.shared.domains.Site","id":25,"name":"Bluff Offsite","description":"Bluff Offsite description here!","order":0,"removed":false,"location":10,"areas":[],"displayName":"Bluff Offsite","orderValue":0}],"displayName":"Bluff","orderValue":0}]

But throws the same exception as before:

com.github.nmorel.gwtjackson.client.exception.JsonDeserializationException: Cannot find the property @class containing the type information

The location domain:

@SuppressWarnings("serial")
@MapsTo(LocationEntity.class)
public class Location extends DomainObject implements Comparable<Location>,
        IsConstant<Location> {

    int id;

    ...

    Set<Site> sites = new HashSet<Site>();

    public Location() { }

    public Location(int id) {
        this.id = id;
    }

    @Override
    public int getId() {
        return id;
    }
    @Override
    public void setId(int id) {
        this.id = id;
    }

    ...

    public Set<Site> getSites() {
        return sites;
    }
    public void setSites(Set<Site> sites) {
        this.sites = sites;
    }
    ...
}
@SuppressWarnings("serial")
@JsonTypeInfo( use = JsonTypeInfo.Id.CLASS )
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public abstract class DomainObject implements Serializable, IsSerializable {

    public abstract int getId();

    public abstract void setId(int id);

    @Override
    public int hashCode() {
        return 31 * 1 + getId() + StringUtils.squish(getClass().getName());
    }
}

For some reason the Location class isn't being provided. Any ideas?

from gwt-jackson.

nmorel avatar nmorel commented on July 29, 2024

Can you try to put your list into a wrapper bean ? Or use an array instead of list ?
I think I already see this behaviour when testing and I used array instead of List.

from gwt-jackson.

BenDol avatar BenDol commented on July 29, 2024

I changed it to Location[] and now I'm getting a compile error:

Errors in 'H:\Global\Java\Workspace\ims-project\ims\target\.generated\com\gwtplatform\dispatch\rest\client\serialization\JacksonMapperProviderImpl.java'
[INFO]             Line 29: Syntax error on token ",", invalid BlockStatements
[INFO]             Line 30: Syntax error on token "Mapper", delete this token
[INFO]             Line 30: Syntax error on token "Mapper", delete this token
[INFO]             Line 30: Syntax error on token "MapperProvider", delete this token
[INFO]             Line 30: Syntax error on token "MapperProvider", delete this token
[INFO]             Line 30: Syntax error on token ",", ; expected
[INFO]             Line 31: Syntax error on token ",", ; expected
[INFO]             Line 32: Syntax error on token ",", ; expected
[INFO]             Line 33: Syntax error on token ",", ; expected
[INFO]             Line 34: Syntax error on token ",", ; expected
[INFO]             Line 35: Syntax error on token ",", ; expected
[INFO]             Line 36: Syntax error on token ",", ; expected
[INFO]             Line 37: Syntax error on token ",", ; expected
[INFO]             Line 38: Syntax error on token ",", ; expected
[INFO]             Line 39: Syntax error on token ",", ; expected
[INFO]             Line 40: Syntax error on token ",", ; expected
[INFO]             Line 41: Syntax error on token ",", ; expected
[INFO]             Line 42: Syntax error on token ",", ; expected
[INFO]             Line 43: Syntax error on token ",", ; expected
[INFO]             Line 44: Syntax error on token ",", ; expected
[INFO]             Line 45: Syntax error on token ",", ; expected
[INFO]             Line 46: Syntax error on token ",", ; expected
[INFO]             Line 47: Syntax error on token ",", ; expected
[INFO]             Line 48: Syntax error on token ",", ; expected
[INFO]             Line 49: Syntax error on token ",", ; expected
[INFO]             Line 50: Syntax error on token ",", ; expected
[INFO]             Line 51: Syntax error on token ",", ; expected
[INFO]             Line 52: Syntax error on token ",", ; expected
[INFO]             Line 53: Syntax error on token ",", ; expected
[INFO]             Line 54: Syntax error on token ",", ; expected
[INFO]             Line 55: Syntax error on token ",", ; expected
[INFO]             Line 56: Syntax error on token ",", ; expected
[INFO]             Line 57: Syntax error on token ",", ; expected
[INFO]             Line 58: Syntax error on token ",", ; expected
[INFO]             Line 59: Syntax error on token ",", ; expected
[INFO]             Line 60: Syntax error on token ",", ; expected
[INFO]             Line 61: Syntax error on token ",", ; expected
[INFO]             Line 62: Syntax error on token ",", ; expected
[INFO]             Line 63: Syntax error on token ",", ; expected
[INFO]             Line 64: Syntax error on token ",", ; expected
[INFO]             Line 65: Syntax error on token ",", ; expected
[INFO]             Line 66: Syntax error on token ",", ; expected
[INFO]             Line 68: Syntax error on token ")", ; expected
[INFO]             Line 88: Syntax error on token(s), misplaced construct(s)
[INFO]             Line 88: Syntax error on token(s), misplaced construct(s)
[INFO]             See snapshot: C:\Users\Ben\AppData\Local\Temp\com.gwtplatform.dispatch.rest.client.serialization.JacksonMapperProviderImpl3799909198364781028.java
Errors in 'H:\Global\Java\Workspace\ims-project\ims\target\.generated\com\gwtplatform\dispatch\rest\client\serialization\mappers\nz_co_doltech_ims_shared_domains_Location[]Mapper.java'
[INFO]             Line 7: Syntax error on tokens, delete these tokens
[INFO]             Line 10: The public type nz_co_doltech_ims_shared_domains_Location must be defined in its own file
[INFO]             Line 10: Syntax error on tokens, delete these tokens
[INFO]             See snapshot: C:\Users\Ben\AppData\Local\Temp\com.gwtplatform.dispatch.rest.client.serialization.mappers.nz_co_doltech_ims_shared_domains_Location[]Mapper2482711428872545242.java

from gwt-jackson.

nmorel avatar nmorel commented on July 29, 2024

I found this : FasterXML/jackson-databind#23

from gwt-jackson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.