Return-Path: X-Original-To: apmail-flink-dev-archive@www.apache.org Delivered-To: apmail-flink-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B20BD18BEB for ; Fri, 11 Dec 2015 17:27:22 +0000 (UTC) Received: (qmail 33990 invoked by uid 500); 11 Dec 2015 17:27:17 -0000 Delivered-To: apmail-flink-dev-archive@flink.apache.org Received: (qmail 33926 invoked by uid 500); 11 Dec 2015 17:27:17 -0000 Mailing-List: contact dev-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list dev@flink.apache.org Received: (qmail 33915 invoked by uid 99); 11 Dec 2015 17:27:17 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Dec 2015 17:27:17 +0000 Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id ED6871A03BB for ; Fri, 11 Dec 2015 17:27:16 +0000 (UTC) Received: by wmec201 with SMTP id c201so79776320wme.1 for ; Fri, 11 Dec 2015 09:27:15 -0800 (PST) X-Received: by 10.194.87.39 with SMTP id u7mr21284986wjz.11.1449854835714; Fri, 11 Dec 2015 09:27:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.88.206 with HTTP; Fri, 11 Dec 2015 09:26:56 -0800 (PST) In-Reply-To: References: <5669A2AD.5010600@apache.org> <0EF1168A-78D8-499E-A45A-811A0E599DC8@apache.org> <5669A509.3080509@apache.org> <566A0918.6060408@apache.org> From: Nick Dimiduk Date: Fri, 11 Dec 2015 09:26:56 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Flink and Clojure To: dev@flink.apache.org Content-Type: multipart/alternative; boundary=089e0102def47578e20526a2a239 --089e0102def47578e20526a2a239 Content-Type: text/plain; charset=UTF-8 Ah I see. This explains the issues I had with submitting streaming jobs that package JDBC drivers. Is there a second in the guide/docs about classloader considerations with Flink? On Thu, Dec 10, 2015 at 11:53 PM, Stephan Ewen wrote: > Flink's classloading is different from Hadoop's. > > In Hadoop, the entire JVM is started with all classes (including the user > jar) in the classpath already. In Flink, jars are added dymanically, to > running JVMs with custom class loaders. That way, running worker/master > processes can accept new jars without restarts. Important for low-latency, > shells, etc > > Flink itself respects these classloaders whenever dynamically looking up a > class. It may be that Closure is written such that it can only dynamically > instantiate what is the original classpath. > > > > On Fri, Dec 11, 2015 at 1:31 AM, Nick Dimiduk wrote: > > > As far as the jvm is concerned, clojure is just another library. You > should > > be able to package it up like any other dependency and submit the job. > > That's always how it worked in Hadoop/MR anyway... > > > > On Thu, Dec 10, 2015 at 3:22 PM, Matthias J. Sax > wrote: > > > > > Thanks for this idea. > > > > > > I extended my pom to include clojure-1.5.1.jar in my program jar. > > > However, the problem is still there... I did some research on the > > > Internet, and it seems I need to mess around with Clojure's class > > > loading strategy... > > > > > > -Matthias > > > > > > On 12/10/2015 06:47 PM, Nick Dimiduk wrote: > > > > I think Mattias's project is using maven though -- there's a pom in > the > > > > project that doesn't look generated. If you want to do it from lein, > > > maybe > > > > my old lein-hadoop [0] plugin can help? > > > > > > > > [0]: https://github.com/ndimiduk/lein-hadoop > > > > > > > > On Thu, Dec 10, 2015 at 8:54 AM, Robert Metzger > > > > wrote: > > > > > > > >> I had the same though as Nick. Maybe Leiningen allows to somehow > > build a > > > >> fat-jar containing the clojure standard library. > > > >> > > > >> On Thu, Dec 10, 2015 at 5:51 PM, Nick Dimiduk > > > wrote: > > > >> > > > >>> What happens when you follow the packaging examples provided in the > > > flink > > > >>> quick start archetypes? These have the maven-foo required to > package > > an > > > >>> uberjar suitable for flink submission. Can you try adding that step > > to > > > >> your > > > >>> pom.xml? > > > >>> > > > >>> On Thursday, December 10, 2015, Stephan Ewen > > wrote: > > > >>> > > > >>>> This is a problem in Java. > > > >>>> I think you cannot dynamically modify the initial system class > > loader. > > > >>>> > > > >>>> What most apps do is check for the thread context class loader > when > > > >>>> dynamically loading classes. We can check and make sure that one > is > > > >> set, > > > >>>> but if Closure does not respect that, we have a problem. > > > >>>> Then Closure is not built for dynamic class loading. > > > >>>> > > > >>>> > > > >>>> > > > >>>> On Thu, Dec 10, 2015 at 5:15 PM, Matthias J. Sax < > mjsax@apache.org > > > >>>> > wrote: > > > >>>> > > > >>>>> Would it make sense (if possible?) for Flink to add the user jar > > > >>>>> dynamically to it's own classpath so Clojure can find it? Or > > somehow > > > >>>>> modify Clojure's class loader? > > > >>>>> > > > >>>>> The jars in lib are added to the classpath at startup. This makes > > it > > > >>>>> practically impossible to execute a Flink program that is written > > in > > > >>>>> Clojure right now... > > > >>>>> > > > >>>>> > > > >>>>> On 12/10/2015 05:09 PM, Aljoscha Krettek wrote: > > > >>>>>> Clojure is not considering the user-jar when trying to load the > > > >>> class. > > > >>>>>> > > > >>>>>>> On 10 Dec 2015, at 17:05, Matthias J. Sax > > >>>> > wrote: > > > >>>>>>> > > > >>>>>>> Hi Squirrels, > > > >>>>>>> > > > >>>>>>> I was playing with a Flink Clojure WordCount example today. > > > >>>>>>> > > https://github.com/mjsax/flink-external/tree/master/flink-clojure > > > >>>>>>> > > > >>>>>>> After building the project with "mvn package" I tried to submit > > it > > > >>> to > > > >>>> a > > > >>>>>>> local cluster. Before I started the cluster, I manually copied > > > >>>>>>> "clojure-1.5.1.jar" into Flink's lib folder. > > > >>>>>>> > > > >>>>>>>> cp > ~/.m2/repository/org/clojure/clojure/1.5.1/clojure-1.5.1.jar > > > >>> lib/ > > > >>>>>>>> bin/start-local.sh > > > >>>>>>> > > > >>>>>>> However, when submitting the jar, I get an exception: > > > >>>>>>> > > > >>>>>>>> bin/flink run -c org.apache.flink.clojure.WordCount > > > >>>>>>> > > > >>>>> > > > >>>> > > > >>> > > > >> > > > > > > ~/workspace_flink/flink-external/flink-clojure/target/flink-clojure-0.10.0.jar > > > >>>>>>> > > > >>>>>>> > > > >>>>>>>> ------------------------------------------------------------ > > > >>>>>>>> The program finished with the following exception: > > > >>>>>>>> > > > >>>>>>>> org.apache.flink.client.program.ProgramInvocationException: > The > > > >>>>> program's entry point class 'org.apache.flink.clojure.WordCount' > > > >> threw > > > >>> an > > > >>>>> error during initialization. > > > >>>>>>>> at > > > >>>>> > > > >>>> > > > >>> > > > >> > > > > > > org.apache.flink.client.program.PackagedProgram.loadMainClass(PackagedProgram.java:585) > > > >>>>>>>> at > > > >>>>> > > > >>>> > > > >>> > > > >> > > > > > > org.apache.flink.client.program.PackagedProgram.(PackagedProgram.java:195) > > > >>>>>>>> at > > > >>>>> > > > >> > org.apache.flink.client.CliFrontend.buildProgram(CliFrontend.java:784) > > > >>>>>>>> at > org.apache.flink.client.CliFrontend.run(CliFrontend.java:288) > > > >>>>>>>> at > > > >>>>> > > > >>>> > > > >>> > > > >> > > > > > > org.apache.flink.client.CliFrontend.parseParameters(CliFrontend.java:1050) > > > >>>>>>>> at > > > >> org.apache.flink.client.CliFrontend.main(CliFrontend.java:1103) > > > >>>>>>>> Caused by: java.lang.ExceptionInInitializerError > > > >>>>>>>> at java.lang.Class.forName0(Native Method) > > > >>>>>>>> at java.lang.Class.forName(Class.java:278) > > > >>>>>>>> at > > > >>>>> > > > >>>> > > > >>> > > > >> > > > > > > org.apache.flink.client.program.PackagedProgram.loadMainClass(PackagedProgram.java:578) > > > >>>>>>>> ... 5 more > > > >>>>>>>> Caused by: java.io.FileNotFoundException: Could not locate > > > >>>>> org/apache/flink/clojure/WordCount__init.class or > > > >>>>> org/apache/flink/clojure/WordCount.clj on classpath: > > > >>>>>>>> at clojure.lang.RT.load(RT.java:443) > > > >>>>>>>> at clojure.lang.RT.load(RT.java:411) > > > >>>>>>>> at clojure.core$load$fn__5018.invoke(core.clj:5530) > > > >>>>>>>> at clojure.core$load.doInvoke(core.clj:5529) > > > >>>>>>>> at clojure.lang.RestFn.invoke(RestFn.java:408) > > > >>>>>>>> at clojure.lang.Var.invoke(Var.java:415) > > > >>>>>>>> at org.apache.flink.clojure.WordCount.(Unknown Source) > > > >>>>>>>> ... 8 more > > > >>>>>>> > > > >>>>>>> I am not sure why the class is not found. It is contained in > the > > > >> jar > > > >>>>>>> file. I can fix this error by copying the user jar > > > >>>>>>> (flink-clojure-0.10.0.jar) into Flink's lib-folder. > > > >>>>>>> > > > >>>>>>> It seems, that Flink is not looking into the user-jar when > > loading > > > >>>> this > > > >>>>>>> class. Can anybody explain why? > > > >>>>>>> > > > >>>>>>> Thx. > > > >>>>>>> > > > >>>>>>> -Matthias > > > >>>>>>> > > > >>>>>> > > > >>>>> > > > >>>>> > > > >>>> > > > >>> > > > >> > > > > > > > > > > > > > --089e0102def47578e20526a2a239--