{"action":"created","issue":{"url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1046","labels_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1046/labels{/name}","comments_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1046/comments","events_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1046/events","html_url":"https://github.com/FasterXML/jackson-databind/issues/1046","id":121906596,"number":1046,"title":"JsonUnwrapped and JsonView don't work together","user":{"login":"fmerino-indra","id":16274617,"avatar_url":"https://avatars.githubusercontent.com/u/16274617?v=3","gravatar_id":"","url":"https://api.github.com/users/fmerino-indra","html_url":"https://github.com/fmerino-indra","followers_url":"https://api.github.com/users/fmerino-indra/followers","following_url":"https://api.github.com/users/fmerino-indra/following{/other_user}","gists_url":"https://api.github.com/users/fmerino-indra/gists{/gist_id}","starred_url":"https://api.github.com/users/fmerino-indra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fmerino-indra/subscriptions","organizations_url":"https://api.github.com/users/fmerino-indra/orgs","repos_url":"https://api.github.com/users/fmerino-indra/repos","events_url":"https://api.github.com/users/fmerino-indra/events{/privacy}","received_events_url":"https://api.github.com/users/fmerino-indra/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-12-13T08:15:30Z","updated_at":"2016-01-13T17:36:09Z","closed_at":null,"body":"Hi,\r\nI'm using 2.6.3 version of jackson-databind. I've made the next example:\r\n\r\n```\r\npublic enum NodeState implements Serializable {\r\n\tOPERATIONAL(0, \"OPERATIONAL\"),\r\n\tDEGRADED(1,\"DEGRADED\"),\r\n\tFAILED(2, \"CRITICAL\"),\r\n\tUNKNOWN(3,\"UNKNOWN\"),\r\n\tSTOPPED(4,\"STOPPED\"),\r\n\tUNREACHABLE(5, \"UNREACHABLE\"),\r\n\tPENDING(6,\"PENDING\")\t;\r\n\t\r\n\t@JsonView(View.Tree.class)\r\n\t@JsonProperty(\"stateId\")\r\n\tprivate final int state;\r\n\t\r\n\t@JsonView(View.Detail.class)\r\n\tprivate final String stateStr;\r\n\t\r\n\tNodeState(int type, String typeStr) {\r\n\t\tthis.state = type;\r\n\t\tthis.stateStr = typeStr;\r\n\t}\r\n\tpublic int getState() {\r\n\t\treturn state;\r\n\t}\r\n\tpublic String getStateStr() {\r\n\t\treturn stateStr;\r\n\t}\r\n}\r\npublic class BaseState implements Serializable {\r\n\t@JsonUnwrapped\r\n\t@JsonView(View.Tree.class)\r\n\tprivate NodeState nodeState;\r\n\t\r\n\t@JsonView(View.Tree.class)\t\r\n\tprivate int risk;\r\n    public BaseState(NodeState nodeState, int risk) {\r\n        this.nodeState = nodeState;\r\n        this.risk = risk;\r\n    }\r\n}\r\n```\r\nThe View class definition\r\n```\r\npublic class View {\r\n\tpublic static class Tree {}\r\n\tpublic static class Detail extends Tree {}\r\n}\r\n```\r\nI use this code in the next way:\r\n```\r\npublic static void main(String args[] {\r\n    BaseState state = new BaseState(NodeState.OPERATIONAL, 2);\r\n    ObjectMapper mapper = new ObjectMapper();\r\n    String json = null;\r\n    mapper.disable(MapperFeature.DEFAULT_VIEW_INCLUSION);\r\n    json = mapper.writeValueAsString(state);\r\n    java.lang.System.out.println(json);\r\n}\r\n```\r\nThe execution throws the next \r\n```\r\njava.lang.IllegalStateException: Can not override serializer\r\n\tat com.fasterxml.jackson.databind.ser.BeanPropertyWriter.assignSerializer(BeanPropertyWriter.java:402)\r\n\tat com.fasterxml.jackson.databind.ser.impl.UnwrappingBeanPropertyWriter.assignSerializer(UnwrappingBeanPropertyWriter.java:137)\r\n\tat com.fasterxml.jackson.databind.ser.impl.FilteredBeanPropertyWriter$SingleView.assignSerializer(FilteredBeanPropertyWriter.java:53)\r\n\tat com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.resolve(BeanSerializerBase.java:339)\r\n\tat com.fasterxml.jackson.databind.ser.SerializerCache.addAndResolveNonTypedSerializer(SerializerCache.java:177)\r\n\tat com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1166)\r\n\tat com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:481)\r\n\tat com.fasterxml.jackson.databind.SerializerProvider.findTypedValueSerializer(SerializerProvider.java:679)\r\n\tat com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:107)\r\n\tat com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:3559)\r\n\tat com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:2927)\r\n\tat es.fmm.json.Application.run(Application.java:42)\r\n```\r\n\r\nIf I remove the @JsonUnwrapped annotation from nodeState attribute of BaseState class, it work's with no problem. The output is:\r\n```\r\n{\"nodeState\":{\"stateStr\":\"OPERATIONAL\",\"stateId\":0},\"risk\":2}\r\n```\r\nOr, if I remove the @JsonView annotation from nodeState attribute of BaseState class, it work's too. The test invocation is:\r\n```\r\n    json = mapper.writerWithView(View.Tree.class).writeValueAsString(state);\r\n    java.lang.System.out.println(json);\r\n```\r\nThe output is:\r\n```\r\n{\"stateStr\":\"OPERATIONAL\",\"stateId\":0,\"risk\":2} // With first test\r\n{\"risk\":2} // With second test\r\n```\r\n\r\nThanks a lot for your help."},"comment":{"url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/comments/171374184","html_url":"https://github.com/FasterXML/jackson-databind/issues/1046#issuecomment-171374184","issue_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1046","id":171374184,"user":{"login":"cowtowncoder","id":55065,"avatar_url":"https://avatars.githubusercontent.com/u/55065?v=3","gravatar_id":"","url":"https://api.github.com/users/cowtowncoder","html_url":"https://github.com/cowtowncoder","followers_url":"https://api.github.com/users/cowtowncoder/followers","following_url":"https://api.github.com/users/cowtowncoder/following{/other_user}","gists_url":"https://api.github.com/users/cowtowncoder/gists{/gist_id}","starred_url":"https://api.github.com/users/cowtowncoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cowtowncoder/subscriptions","organizations_url":"https://api.github.com/users/cowtowncoder/orgs","repos_url":"https://api.github.com/users/cowtowncoder/repos","events_url":"https://api.github.com/users/cowtowncoder/events{/privacy}","received_events_url":"https://api.github.com/users/cowtowncoder/received_events","type":"User","site_admin":false},"created_at":"2016-01-13T17:36:09Z","updated_at":"2016-01-13T17:36:09Z","body":"@fmerino-indra Sorry, haven't had a chance to look into this yet. Will try to see what gives within day or two."}}