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

Error while deserializing response (getUpdate) #1

Closed
Migsi opened this issue Feb 16, 2016 · 10 comments
Closed

Error while deserializing response (getUpdate) #1

Migsi opened this issue Feb 16, 2016 · 10 comments
Labels

Comments

@Migsi
Copy link

Migsi commented Feb 16, 2016

This issue doesn't belong to the Minegram itself, it seems to be an error of the used json-lib.
When trying to deserialize updates the following error appears:

[23:18:58 WARN]: com.cadiducho.minegram.api.exception.TelegramException: Could not deserialize response! (getUpdates)

[23:18:58 WARN]:        at com.cadiducho.minegram.TelegramBot.getUpdates(TelegramBot.java:466)

[23:18:58 WARN]:        at com.migsi.tgchat.Main$1.run(Main.java:47)

[23:18:58 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:59)

[23:18:58 WARN]:        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:349)

[23:18:58 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:781)

[23:18:58 WARN]:        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378)

[23:18:58 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713)

[23:18:58 WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616)

[23:18:58 WARN]:        at java.lang.Thread.run(Unknown Source)

[23:18:58 WARN]: Caused by: com.fasterxml.jackson.databind.JsonMappingException: Conflicting setter definitions for property "config": com.fasterxml.jackson.databind.ObjectMapper#setConfig(1 params) vs com.fasterxml.jackson.databind.ObjectMapper#setConfig(1 params)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:269)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:428)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.std.StdDeserializer.findDeserializer(StdDeserializer.java:947)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:439)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:296)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:428)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.std.StdDeserializer.findDeserializer(StdDeserializer.java:947)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:439)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:296)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:428)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.std.StdDeserializer.findDeserializer(StdDeserializer.java:947)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:439)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:296)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:428)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:164)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.createContextual(CollectionDeserializer.java:25)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.DeserializationContext.handleSecondaryContextualization(DeserializationContext.java:669)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:466)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:3833)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3727)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2743)

[23:18:58 WARN]:        at com.cadiducho.minegram.TelegramBot.getUpdates(TelegramBot.java:464)

[23:18:58 WARN]:        ... 8 more

[23:18:58 WARN]: Caused by: java.lang.IllegalArgumentException: Conflicting setter definitions for property "config": com.fasterxml.jackson.databind.ObjectMapper#setConfig(1 params) vs com.fasterxml.jackson.databind.ObjectMapper#setConfig(1 params)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder.getSetter(POJOPropertyBuilder.java:299)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.filterBeanProps(BeanDeserializerFactory.java:592)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:488)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:229)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:142)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:403)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:352)

[23:18:58 WARN]:        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264)

[23:18:58 WARN]:        ... 37 more
@Cadiducho
Copy link
Owner

Please, @Migsi, could you test your bot plugin with this version? Thanks!

@Migsi
Copy link
Author

Migsi commented Feb 18, 2016

Thank you for the update! I'll test it as soon as possible!

@Cadiducho
Copy link
Owner

Thank you for testing! I hope it will work and release new version with this fix and new inline bots to Spigot, in order to check about Gson later ;)

@Migsi
Copy link
Author

Migsi commented Feb 20, 2016

After testing it today, the issue remains the same :/ Could it be my fault?

This is the code I use to test it:

`
public void onEnable() {
telegramBot = new TelegramBot("xxxxxKEYxxxxx", this);
try {
telegramBot.sendMessage(xxxUserIDxxx, "Hi! This is a test onEnable");
} catch (TelegramException e) {
System.out.println("Couldn't send any message!");
}
new BukkitRunnable() {

        @Override
        public void run() {
            try {
                List<Update> updates = telegramBot.getUpdates(xxxUpdateNrxxx, 100, 0);
                if (!updates.isEmpty()) {
                    getLogger().info(updates.get(0).getMessage().getText());
                }
            } catch (TelegramException e) {
                e.printStackTrace();
                System.out.println("Could'nt get bot instance!");
            }
        }
    }.runTaskTimer(this, 0, 500);

    getLogger().info("Test plugin recieve enabled");
}

`

EDIT: Sorry for bad format, but the editor seems to not recognize the backticks -.-'

@Cadiducho
Copy link
Owner

No, is not your fault. Yesterday I reproduced the bug and i'm triying to fix it (it is still alive D:! ) but is really really annoying. I rewrited completly the getUpdates() method, not using jackson mapper at all, and I discover that the problem comes from ['Message' object.]

...
Update update = new Update();
                update.setUpdate_id(jsonUpdate.getInt("update_id"));
                if (jsonUpdate.getJSONObject("message") != null) 
             ------> update.setMessage(mapper.readValue(jsonUpdate.getJSONObject("message").toString(), Message.class));
                if (jsonUpdate.getJSONObject("inline_query") != null) 
                    update.setInline_query(mapper.readValue(jsonUpdate.getJSONObject("inline_query").toString(), InlineQuery.class));
...

(https://github.com/Cadiducho/Minegram/blob/master/src/com/cadiducho/minegram/api/Message.java)
The funny fact is that the logs said something about a conflict with 'config' property, and that class (and any other, by the way) have a config variable.It's really strange.

So I really don't know. I can't fix it (yet)... I'll try Gson's mapper... sorry for the inconvenience!

@Migsi
Copy link
Author

Migsi commented Feb 20, 2016

No problem, I'm in no hurry with my project. It's fine for me to see that you're trying to solve this! :) It's anyways a nice job you're doing, this API is pretty cool :)

What belongs to this problem, I must sincerly say that I don't have enough java skills to help you that much :/ And the fact I don't know anything about the Jackson lib doesn't make this better... I'll try to read your sources and, if I find anything helpful, give you advises as good as I can. :)

@Cadiducho
Copy link
Owner

Good news! Gson has simplified my code a lot and... getUpdates() method is working! All builders of objects have been changed, and I will test it before upload new version. In a few hours it will be uploaded in Spigot, Github and Maven repo

Cadiducho added a commit that referenced this issue Feb 20, 2016
- Removed old code
- Loving more Google
@Migsi
Copy link
Author

Migsi commented Feb 22, 2016

Thank you for fixing this! :)

@isac322
Copy link

isac322 commented Oct 6, 2016

Already late? :(
I have had same issue on my another Jackson based project. and I resolved it with this (
cause of this problem)
and answer.
It's because of Jackson's issue! 😢

@Cadiducho
Copy link
Owner

Yes, is too late, I use gson now :(
But thanks for the help! ^^

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

No branches or pull requests

3 participants