Re: ClassNotfound Exception while loading JAR files in Clojure 1.2

77 views
Skip to first unread message

Sean Corfield

unread,
May 22, 2013, 11:01:30 AM5/22/13
to clo...@googlegroups.com
You'll need to provide more details about exactly which Clojure JARs
you use and the stack trace for the exception (at least telling us
which class is not found and enough of the stack trace for us to see
where the reference is coming from).

My suspicion is you're using the Clojure 1.2 contrib library and
something in there refers to a now defunct class from HTMLUnit? It's
worth noting that the monolithic contrib library is no longer
maintained so you won't get any updates to that. Instead, as part of
the move to Clojure 1.3 (a couple of years back), the parts of contrib
that actually had maintainers were moved into new libraries, updated
individually. Many of them are still compatible with Clojure 1.2 but a
lot of the parts of the original contrib were abandoned for a number
of reasons.

Sean


On Tue, May 21, 2013 at 11:25 PM, <vcom...@gmail.com> wrote:
>
> Hi,
>
> We have built a web application using grails framework and we use Groovy,
> Java and Clojure programming languages. We use
> Clojure 1.2. The clojure files include classes from HTMLUnit. Recently
> HTMLUnit released a new version of JAR file and we were
> trying to migrate the web app to new version of HTMLUnit.
>
> When we deploy the web app under Jetty (comes with Grails), during the
> deployment the Clojure code which uses HTMLUnit fails with ClassNotFound
> Exception.
>
> What is the reason for this error and any help or pointers to solve this
> issue is greatly appreciated.
>
> Looking forward to your reply.
>
> Regards
> Vasu
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

vcom...@gmail.com

unread,
May 22, 2013, 11:20:28 AM5/22/13
to clo...@googlegroups.com
Hi Sean,

   Thanks for your reply. I use Clojure.Jar version 1.2.0 and the contrib.jar is also the same version.

   Copied below is the stack trace of the Error:

Caused by: java.lang.NoClassDefFoundError: com/gargoylesoftware/htmlunit/html/BaseFrameElement (agent.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:5440)
        at clojure.lang.Compiler.eval(Compiler.java:5415)
        at clojure.lang.Compiler.load(Compiler.java:5857)
        at clojure.lang.RT.loadResourceScript(RT.java:340)
        at clojure.lang.RT.loadResourceScript(RT.java:331)
        at clojure.lang.RT.load(RT.java:409)
        at clojure.lang.RT.load(RT.java:381)
        at clojure.core$load$fn__4511.invoke(core.clj:4905)
        at clojure.core$load.doInvoke(core.clj:4904)
        at clojure.lang.RestFn.invoke(RestFn.java:409)
        at clojure.core$load_one.invoke(core.clj:4729)
        at clojure.core$load_lib.doInvoke(core.clj:4766)
        at clojure.lang.RestFn.applyTo(RestFn.java:143)
        at clojure.core$apply.invoke(core.clj:542)
        at clojure.core$load_libs.doInvoke(core.clj:4800)
        at clojure.lang.RestFn.applyTo(RestFn.java:138)
        at clojure.core$apply.invoke(core.clj:544)
        at clojure.core$use.doInvoke(core.clj:4880)
        at clojure.lang.RestFn.invoke(RestFn.java:458)
        at nlplabs.webfetch.lib.dgeneral$eval780$loading__4410__auto____781.invoke(dgeneral.clj:1)
        at nlplabs.webfetch.lib.dgeneral$eval780.invoke(dgeneral.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:5424)
        at clojure.lang.Compiler.eval(Compiler.java:5415)
        at clojure.lang.Compiler.load(Compiler.java:5857)
        at clojure.lang.RT.loadResourceScript(RT.java:340)
        at clojure.lang.RT.loadResourceScript(RT.java:331)
        at clojure.lang.RT.load(RT.java:409)
        at clojure.lang.RT.load(RT.java:381)
        at clojure.core$load$fn__4511.invoke(core.clj:4905)
        at clojure.core$load.doInvoke(core.clj:4904)
        at clojure.lang.RestFn.invoke(RestFn.java:409)
        at clojure.core$load_one.invoke(core.clj:4729)
        at clojure.core$load_lib.doInvoke(core.clj:4766)
        at clojure.lang.RestFn.applyTo(RestFn.java:143)
        at clojure.core$apply.invoke(core.clj:542)
        at clojure.core$load_libs.doInvoke(core.clj:4804)
        at clojure.lang.RestFn.applyTo(RestFn.java:138)
        at clojure.core$apply.invoke(core.clj:542)
        at clojure.core$require.doInvoke(core.clj:4869)
        at clojure.lang.RestFn.invoke(RestFn.java:409)
        at nlplabs.webfetch.lib$eval776.invoke(lib.clj:35)
        at clojure.lang.Compiler.eval(Compiler.java:5424)
        at clojure.lang.Compiler.eval(Compiler.java:5414)
        at clojure.lang.Compiler.load(Compiler.java:5857)
        at com.nlplabs.util.GClojure.load(GClojure.java:41)
        at com.nlplabs.util.GClojure.loadExtractorLib(GClojure.java:32)
        at com.nlplabs.util.GClojure$loadExtractorLib.call(Unknown Source)
        at com.nlplabs.lf.protocols.WEBProtocol.<clinit>(WEBProtocol.groovy:19)
        ... 27 more
Caused by: java.lang.NoClassDefFoundError: com/gargoylesoftware/htmlunit/html/BaseFrameElement
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at nlplabs.webfetch.agent$eval786$loading__4410__auto____787.invoke(agent.clj:1)
        at nlplabs.webfetch.agent$eval786.invoke(agent.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:5424)
        ... 74 more
Caused by: java.lang.ClassNotFoundException: com.gargoylesoftware.htmlunit.html.BaseFrameElement
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        ... 79 more
Server running. Browse to http://localhost:8080/jlfr

 ************ Copied below is the code snippet of agent.clj which has the import statement. *******************
(ns nlplabs.webfetch.agent
  (:refer-clojure)
  (:use nlplabs.lib nlplabs.webfetch.scheduler nlplabs.webfetch.util
        clojure.contrib.str-utils)


  (:import (com.gargoylesoftware.htmlunit BrowserVersion
                                                 Page
                                                 JavaScriptPage
                                                 UnexpectedPage
                                                 TextPage
                                                 WebClient
                                                 MockWebConnection
                                                 History)
 ......
 ))

  The error comes when it tries to load WebClient Class. WebClient.java imports BaseFrameElement Class. When I comment WebClient, the compilation
  passes through.

  Let me know if you need any more information.

Regards
 Vasu

Andy Fingerhut

unread,
May 22, 2013, 11:33:03 AM5/22/13
to clo...@googlegroups.com
I'll be more blunt than Sean was :-)

Is there a reason why you *must* use Clojure 1.2?  If so, what is it?

If there isn't such a reason, you will likely get much better support from other Clojure users if you use Clojure 1.4 or 1.5.1 (1.5.1 was released a couple of months ago, so many are still using Clojure 1.4, and relatively few are using 1.3).

Andy

vcom...@gmail.com

unread,
May 22, 2013, 11:47:30 AM5/22/13
to clo...@googlegroups.com

 Hi Andy,

    I inherited the code written by some one who is no longer with us. First, I would like to migrate to new version of HTMLUnit and then
    look at migrating the clojure to the new version.

Regards
 Vasu
Reply all
Reply to author
Forward
0 new messages