Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Dropwizard example #6

Closed
med1985 opened this issue Jul 9, 2015 · 5 comments
Closed

Issue with Dropwizard example #6

med1985 opened this issue Jul 9, 2015 · 5 comments

Comments

@med1985
Copy link

med1985 commented Jul 9, 2015

For some reason I keep getting the exception below when trying to use JSOG with dropwizard:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "@ref"

I've tried to debug why and can't figure it out, I'll continue this weekend. It stops throwing exceptions when you set:

environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

But that obviously doesn't solve the problem. I tried it with the current dropwizard example Master (and v0.8.0) and made the following amendments:

(object with reference to itself)
@JsonIdentityInfo(generator=JSOGGenerator.class)
public class Person {
@id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;

@Column(name = "fullName", nullable = false)
private String fullName;

@Column(name = "jobTitle", nullable = false)
private String jobTitle;
@JoinColumn @OneToOne
private Person brother;

...

Then in the test:

@Test
public void testHelloWorld() throws Exception {
    Client client = ClientBuilder.newClient().register(new LoggingFilter(java.util.logging.Logger.getLogger("test"), true));
    WebTarget target = client.target("http://localhost:8080/people");

    Person person = new Person();
    person.setFullName("blah");
    Person brother = new Person();
    person.setFullName("brother");
    brother.setBrother(person);
    person.setBrother(brother);

    target.request().post(Entity.entity(person, MediaType.APPLICATION_JSON_TYPE));

}

You can see it's sending the correct JSOG-ed JSON object but if you set logging to debug you can see the exception I'm talking about.

Let me know if you want me to send you a zip of the files or anything.

@med1985
Copy link
Author

med1985 commented Jul 11, 2015

The problem seems to be that the "else" in this if block is never reached for some reason, investigation continues...

@Override
public JSOGRef deserialize(JsonParser jp, DeserializationContext ctx) throws IOException, JsonProcessingException {
    JsonNode node = jp.readValueAsTree();
    if (node.isTextual()) {
        return new JSOGRef(node.asText());
    } else {
        return new JSOGRef(node.get(JSOGRef.REF_KEY).asText());
    }
}

@amondnet
Copy link

+1

@redben
Copy link

redben commented Sep 1, 2015

It might be good to include which version of dropwizard you are using.

@Janekdererste
Copy link

I am having the same Issue as of dropwizard 1.3.5. It seems to be an issue with the Jackson Afterburner Module used by Dropwizard. There already is an issue for that.

FasterXML/jackson-modules-base#54

@stickfigure
Copy link
Member

This seems to have been resolved in jackson.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants