On Tue, Jan 29, 2013 at 8:11 AM, James Xu <xumingming64398...@gmail.com>wrote:
> Don’t know the exact reason for your issue, but for your question: > > "How can a > class be present at compile time but not at runtime?" > I find this to be relevant: http://onjava.com/pub/a/onjava/2005/01/26/classloading.html > > It IS possible, AFAIK there are two cases: > 1) maven pom can specify a dependency's scope as *provided*, the > dependency will be available at compile time, but will not be packaged > into final jar. (Usually because the dependency is provided already by the > deploy environment) > 2) Some code load class through Class.forName, rather than explicit use. > For example JDBC drivers. > > > On 13-1-29 下午3:03, "larry google groups" <lawrencecloj...@gmail.com> > wrote: > > > > >Maybe someone can tell me where I went wrong on this one. > > > >I have an app. Written with Clojure 1.4. > > > >At first the app was very small, so I put all the code into core.clj. > >When I got to about 500 or 600 lines of code, core.clj was too big, so > >I started to break it up. There were some string-to-enlive-node > >functions that I moved to a file I called > >transform_strings_and_nodes.clj. > > > >The app keeps the most recent 15 minutes worth of session info in > >memory, then saves it to the database. Eventually, when this is live, > >tourists will arrive and interact with a kiosk and choose an > >itinerary. The itinerary is bulky, a lot of HTML strings held in > >memory. I began to wonder how bulky this might get. I thought I would > >write a profile function, relying on Timbre > >https://github.com/ptaoussanis/timbre. > > > >During development, I would have this function run in a thread and > >call itself every 5 minutes. I decided I would hit the app with a lot > >of dummy data, and the profile function would do stuff like time how > >long it took to transform all the HTML strings in memory into Enlive > >nodes. > > > >This was working for awhile. I am not sure what changed, but now I am > >getting: > > > >Exception in thread "Thread-4" java.lang.NoClassDefFoundError: > >kiosks_clojure/transform_strings_and_nodes > >$join_all_tourist_itineraries_together$fn__115 > > at kiosks_clojure.transform_strings_and_nodes > >$join_all_tourist_itineraries_together.invoke(transform_strings_and_nodes. > >clj: > >84) > > at kiosks_clojure.transform_strings_and_nodes > >$render_html_string_to_enlive_nodes.invoke(transform_strings_and_nodes.clj > >: > >94) > > at kiosks_clojure.transform_strings_and_nodes > >$prepare_render_html_string_to_enlive_nodes.invoke(transform_strings_and_n > >odes.clj: > >101) > > at kiosks_clojure.transform_strings_and_nodes > >$profile_render_html_string_to_enlive_nodes.invoke(transform_strings_and_n > >odes.clj: > >105) > > at clojure.lang.AFn.run(AFn.java:24) > > at java.lang.Thread.run(Thread.java:722) > >Caused by: java.lang.ClassNotFoundException: > >kiosks_clojure.transform_strings_and_nodes > >$join_all_tourist_itineraries_together$fn__115 > > at java.net.URLClassLoader$1.run(URLClassLoader.java:366) > > at java.net.URLClassLoader$1.run(URLClassLoader.java:355) > > at java.security.AccessController.doPrivileged(Native Method) > > at java.net.URLClassLoader.findClass(URLClassLoader.java:354) > > at java.lang.ClassLoader.loadClass(ClassLoader.java:423) > > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java: > >308) > > at java.lang.ClassLoader.loadClass(ClassLoader.java:356) > > > > > >As far as I can read the stack trace, the exception seems to get > >triggered here: > > > >(defn join-all-tourist-itineraries-together [sessions] > > (reduce > > (fn [vector-of-tourist-itineraries-as-strings next-tourist-session] > > (conj vector-of-tourist-itineraries-as-strings (get-in next- > >tourist-session [:itinerary-as-string]))) > > [] > > sessions)) > > > > > >Which is called from here: > > > >(defn render-html-string-to-enlive-nodes [] > > "2013-01-24 - I worry about how slow this might get when the memory > >is full of intineraries. I'm going to run these tests while this in > >development, to get a sense for what kind of performance we might > >get." > > (let [sessions (:sessions @um/interactions) > > accumulated-total-of-all-tourist-itineraries-in-memory-as- > >strings (st/join (join-all-tourist-itineraries-together sessions)) > > length-of-string-to-be-rendered (.length (str accumulated- > >total-of-all-tourist-itineraries-in-memory-as-strings)) > > itineraries-as-one-string-wrapped-in-div (apply str "<div > >id='all-itineraries'>" accumulated-total-of-all-tourist-itineraries-in- > >memory-as-strings "</div>")] > > (println (apply str "In render-html-string-to-enlive-nodes, the > >length of the HTML string: " length-of-string-to-be-rendered)) > > (transform-html-string-to-enlive-nodes itineraries-as-one-string- > >wrapped-in-div (keyword "#all-itineraries")))) > > > >(defn prepare-render-html-string-to-enlive-nodes [] > > (p :string-to-enlive-nodes (render-html-string-to-enlive-nodes))) > > > >(defn profile-render-html-string-to-enlive-nodes [] > > (. java.lang.Thread sleep 300000) > > (profile :debug :summary-render-html-strings-to-enlive-nodes > >(prepare-render-html-string-to-enlive-nodes))) > > > > > > > >I looked for info about this error and I found this: > > > > > http://javarevisited.blogspot.com/2011/06/noclassdeffounderror-exception-i > >n.html > > > >which says: > > > >"NoClassDefFoundError in Java comes when Java Virtual Machine is not > >able to find a particular class at runtime which was available during > >compile time. " > > > > > >I am very ignorant of the JVM and I do not understand how this can > >happen. Right now, while testing this app, I am compiling it locally > >on my Macintosh and I am running it locally on my Macintosh. How can a > >class be present at compile time but not at runtime? > > > > > > > > > >-- > >-- > >You received this message because you are subscribed to the Google > >Groups "Clojure" group. > >To post to this group, send email to clojure@googlegroups.com > >Note that posts from new members are moderated - please be patient with > >your first post. > >To unsubscribe from this group, send email to > >clojure+unsubscr...@googlegroups.com > >For more options, visit this group at > >http://groups.google.com/group/clojure?hl=en > >--- > >You received this message because you are subscribed to the Google Groups > >"Clojure" group. > >To unsubscribe from this group and stop receiving emails from it, send an > >email to clojure+unsubscr...@googlegroups.com. > >For more options, visit https://groups.google.com/groups/opt_out. > > > > > > > -- > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Please correct me if I'm wrong or incomplete, even if you think I'll subconsciously hate it. -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.