1

I am trying to deploy my topology bundled as a fat jar to remote Cluster . The jar can be deployed successfully but when deployed , I am seeing the following error in the worker log : It says it cannot find class for JpaRepository as shown below

enter image description here

The jar that I am submitting to cluster already contains this class though . I copied jar from the cluster and saw its contents and here is what I see

enter image description here

Would be really thankful if anyone of u has ny idea why is this failing as I am not having any clue how to proceed further on this . I am already deploying jar with class but still it says classNotFound :(( . Everything works well on Local Cluster.

Also One thing :- The Jar I am uploading is of 68MB (bit on heavier side) . Can that have anything to do with this??

Ankur Garg
  • 2,553
  • 8
  • 30
  • 41
  • You submit `spring-data-jpa-1.6.4.RELEASE.jar` via `storm jar` command? As an alternative to build a fat jar, you can also manually copy the dependency jars into `STORM_HOME/lib` (of course on each machine of you cluster). You might need to restart the cluster in order to make Storm pick up the jars. – Matthias J. Sax Oct 15 '15 at 20:35
  • I didnt submitted using storm jar command ...I submitted from my Eclipse using Nimbus Client :=> Map storm_conf = Utils.readStormConfig(); storm_conf.put(Config.NIMBUS_HOST, "130.211.244.139"); String jar = "/Users/agarg/Documents/notificationRepo/apache-storm/build/libs/apache-storm-SNAPSHOT-ns.r134-boot.jar"; NimbusClient nimbus = new NimbusClient(storm_conf, "130.211.244.139", 6627); String uploadedJarLocation = StormSubmitter.submitJar(storm_conf, jar); – Ankur Garg Oct 15 '15 at 20:39
  • Also , I only have a single node cluster rite now... – Ankur Garg Oct 15 '15 at 20:40
  • I have too many dependent jars..Submitting all of them might be difficult ..I can try pushing this jar manually though ..That being said ..Does storm scans all the jars in the libs folder ..I mean along with fat jar If i push more jars to libs folder ..will storm scan them too if it does not find somehow inside fat jar ? – Ankur Garg Oct 15 '15 at 20:44

1 Answers1

2

If you submit via Eclipse you should to the following:

public static void main(String[] args) {
    TopologyBuilder b = new TopologyBuilder();
    // build your topology
    b.setSpout(...);
    b.setBolt(...);

    Config c = new Config();
    c.put(Config.NIMBUS_HOST, "130.211.244.139");
    // not sure you you use 6627; 6123 is default port; if you change the port, just use 6627 of course
    c.put(Config.NIMBUS_THRIFT_PORT, new Integer(6123));

    StormSubmitter.submitTopology("myTopolgyName", conf, b.createTopology());
}

Furthermore, you need to specify JVM argument -Dstorm.jar=/Users/agarg/Documents/notificationRepo/apache-storm/build/libs/apache-storm-SN‌​APSHOT-ns.r134-boot.jar.

If you want to avoid including transitive dependencies into you jar, you can also copy them manually to Storm's lib folder. Of course, you need to copy them to all machines. You also might need to restart the cluster. You can copy as many jars as you which to lib folder -- Storm will "pick up" all of them.

Furthermore, if you build a fat jar, the dependent jars cannot be nested into the far jar (ie, the extracted content of dependent jars must be included into the far jar). For example, you dependent jar dep.jar contains a file DClass.class; thus, your fat jar must not contain "dep.jar" (neither in top level nor "lib" folder) but "DClass.class" next to all your Spout and Bolt classes (ie, "DClass.class" must be contained on top level folder within the jar. Of course, you also need to respect package structure, ie, if "dep.jar" contains a file dpackage.DClass2 (ie, "DClass2.class" in folder "dpackage") the far jar must contain a directory "dpackage" (in top level folder within the jar) that contains "DClass2.class".

Matthias J. Sax
  • 59,682
  • 7
  • 117
  • 137
  • Thanks Matthias ..So Now I am manually deploying the jars and it seems to be working (I am getting different classNotFoundException each time now :) ) ..However , this is far from ideal solution..Ideally , I would want one fat jar to do the job for me as to repeat the same on all nodes is a tedious and painful task ..So , is the storm designed such way or is it a bug which can be fixed ? – Ankur Garg Oct 15 '15 at 21:13
  • You can build a far jar and include all the dependencies in it to avoid manual copying the dependent jars to `lib` folder. In your example, all dependencies must be included in `apache-storm-SN‌​APSHOT-ns.r134-boot.jar`. You just need to make sure, that the fat jar does not contain the dependencies as `jar` files -- Storm cannot handle nested jars. – Matthias J. Sax Oct 15 '15 at 21:36
  • Actually , I couldnot get your point here ...I believed I was doing the same thing ..The fat jar has all dependencies as jar in seperate lib folder . Let me attach an image to my apache-storm-SN‌​APSHOT-ns.r134-boot.jar to elaborate . May be then I will understand what u meant – Ankur Garg Oct 15 '15 at 21:38
  • I just extended my answer. – Matthias J. Sax Oct 15 '15 at 21:41
  • Aah little late ..I too posted the pic ..Anyways since i have posted now ..please confirm my understanding and I will delete it..And Thankyou very much for helping me so much here :) – Ankur Garg Oct 15 '15 at 21:50
  • Btw , how do u build such fat jars ..can u share me any sample gradle or maven build file where it bundles external dependencies as class files (I know I am being a bit lazy here ) but if possible please share .. – Ankur Garg Oct 15 '15 at 21:55