Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6C662200CAF for ; Thu, 22 Jun 2017 11:20:46 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6B415160BE7; Thu, 22 Jun 2017 09:20:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id ABC3F160BE5 for ; Thu, 22 Jun 2017 11:20:45 +0200 (CEST) Received: (qmail 10270 invoked by uid 500); 22 Jun 2017 09:20:39 -0000 Mailing-List: contact user-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list user@flink.apache.org Received: (qmail 10259 invoked by uid 99); 22 Jun 2017 09:20:39 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jun 2017 09:20:39 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 30C8FC03C8 for ; Thu, 22 Jun 2017 09:20:39 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.999 X-Spam-Level: X-Spam-Status: No, score=-0.999 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=data-artisans-com.20150623.gappssmtp.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id VWKO2NSHKBMo for ; Thu, 22 Jun 2017 09:20:35 +0000 (UTC) Received: from mail-wr0-f178.google.com (mail-wr0-f178.google.com [209.85.128.178]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id E45455FC93 for ; Thu, 22 Jun 2017 09:20:34 +0000 (UTC) Received: by mail-wr0-f178.google.com with SMTP id k67so14744998wrc.2 for ; Thu, 22 Jun 2017 02:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=data-artisans-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=hmBcBWN0gElu4LtVHiPC3vsRuncshzyxZWLOhw0Zr24=; b=NxFv9CBuNzB+qVxbDhLoMHWefuNlHGge2v0p7jzS+MdamYX3Kruw8ACVay1cOD/ZPD xrtXSXWHTPX6EKPKph6rxQzrgV+l83zRodghoUVZf2XOToDSrVKh/PkYFK0iFHDq9ZKl rRIFHk22Aks0HfE5W84BCNbrJMimOIK8FZTwlLAjUOXhN9BYuuGaHRsronJsB99Y95sq s0JWVidCshoI77BNAddidLmWF57v/fIqJD/6btaXlfBiiMbFll19YuyGP4uon8BjbvWb Y0QRZMQAZGpwUkgFxYhs68q2SZJpSSGqkjytJ76TpoeyU2qEKDFX62pdyIyyt2yjnKP7 JHZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=hmBcBWN0gElu4LtVHiPC3vsRuncshzyxZWLOhw0Zr24=; b=uWqax3ou9rPAOhvQOxzS6BftElTCGVwK+d9z8iRVdSUX05P3FdBFHRvINXseSNu6JG vaXgRjPoWGlAd49rLkgiLbUmFfrysYEw+rWjRPiBSnpU0wIxPTgGL57ZpSHH5XwSXzZ9 pMOQNw3BLM9HBlcIu/ijYvNdubVvc/MKxXwOaibUg02mS4jYuznLFv4AB7JpP9vmbYRu lYRRY5NI9q9RW9m1P6ER78W8hQFjwefWd6brO6+264LXixjooJnNy4SjwC0ErzzjBwof PLay2lceiw1Q+dbAelBbmDJ/5XrOQLvdKqVJFIX3w0Wl0KIHMrT39bVm1w7QSyLYRYBo 6GMQ== X-Gm-Message-State: AKS2vOxaVKgYK/5Klq6L47w5+f9MOc7JH11xk3TlUNuVI9ZCun690Eco vqrws0M0XnNky7v7I7e0YAUo X-Received: by 10.223.155.222 with SMTP id e30mr1217258wrc.55.1498123233699; Thu, 22 Jun 2017 02:20:33 -0700 (PDT) Received: from skynet.fritz.box (ipservice-092-208-199-000.092.208.pools.vodafone-ip.de. [92.208.199.0]) by smtp.gmail.com with ESMTPSA id l127sm490354wml.26.2017.06.22.02.20.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 02:20:33 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: flink doesn't seem to serialize generated Avro pojo From: Stefan Richter In-Reply-To: <1498122582.900732.1017614808.781CE564@webmail.messagingengine.com> Date: Thu, 22 Jun 2017 11:20:31 +0200 Cc: user@flink.apache.org Content-Transfer-Encoding: quoted-printable Message-Id: <4F0F3964-D893-472E-8C8C-9BAAA227EB7A@data-artisans.com> References: <1498122582.900732.1017614808.781CE564@webmail.messagingengine.com> To: Bart van Deenen X-Mailer: Apple Mail (2.3273) archived-at: Thu, 22 Jun 2017 09:20:46 -0000 Hi, this =E2=80=9Eamazing error=E2=80=9C message typically means that the = class of the object instance you created was loaded by a different = classloader than the one that loaded the class in the code that tries to = cast it. A class in Java is fully identified by the canonical classname AND the classloader that = loaded it. This makes it possible that two classes with the same name = and bytecode are not instance of each other. Unfortunately, I have no = concrete idea why that happens in your case,=20 but maybe this info helps to track down the problem. Best, Stefan > Am 22.06.2017 um 11:09 schrieb Bart van Deenen = : >=20 > Hi All >=20 > I have a simple avro file=20 >=20 > {"namespace": "com.kpn.datalab.schemas.omnicrm.contact_history.v1", > "type": "record", > "name": "contactHistory", > "fields": [ > {"name": "events", "type": {"type":"array", =20 > "items": "bytes"}}, > {"name": "krn", "type": "string"} > ] > } >=20 > I generate a Java pojo (gist: https://goo.gl/FtM7T6) from this file = via >=20 > java -jar avro_tools.jar=20 > Version 1.7.7 of Apache Avro >=20 > java -jar bin/avro_tools.jar compile schema > generated/src/main/java >=20 > This pojo file doesn't seem to want to be serialized by Flink, when I > pack the compiled class file into a fat-jar job file. >=20 > When I pass a certain byte array into the avro deserializer, this = works > fine in a regular Scala application, but when I do the same in a Flink > job it bombs with a typecast exception. >=20 > Scala code: >=20 > val payload: AnyRef =3D kafkaEvent.payload() // this calls the > Avro deserializer: (gist: https://goo.gl/18UqJy) >=20 > println("canonical name: " + payload.getClass.getCanonicalName) > val chAvro =3D > try { > payload.asInstanceOf[contactHistory] > } catch { > case c:ClassCastException =3D> > println(c.getMessage) >=20 > I get the following amazing error: >=20 > "canonical name: " + > com.kpn.datalab.schemas.omnicrm.contact_history.v1.contactHistory = =20 > com.kpn.datalab.schemas.omnicrm.contact_history.v1.contactHistory = cannot > be cast to > com.kpn.datalab.schemas.omnicrm.contact_history.v1.contactHistory >=20 > I've verified the exact same code with the exact same byte-array input > (checked by printing a hexdump from the Flink job), and the code = itself > is not the problem. >=20 > If I put a jar containing the class file from the Pojo in the Flink = lib > directory, my Flink job works fine! >=20 > Any ideas how I can put my Pojo in the fat jar, because I don't want = to > restart my Flink when I add new Avro schemas? >=20 > Thanks >=20 > Bart