#235 Doesn't work with clojure 1.5

3.12
closed
Philip Aston
None
4
2014-12-06
2013-04-26
No

The problem is that in clojure 1.5.0 and 1.5.1 class clojure.lang.RT should be initialized before clojure.lang.Compiler. Check this question: http://stackoverflow.com/questions/15207596/npe-in-clojure-lang-compiler-when-trying-to-load-a-resource

I can suggest following solution: in ClojureScriptEngine add static block:

static {
    clojure.lang.RT.init();
}

Stacktrace of current exception:

net.grinder.engine.common.EngineException: Clojure is not on the classpath
    at net.grinder.scriptengine.clojure.ClojureScriptEngineService.createScriptEngine(ClojureScriptEngineService.java:56) ~[grinder-core-3.11.jar:na]
    at net.grinder.engine.process.ScriptEngineContainer.getScriptEngine(ScriptEngineContainer.java:81) ~[grinder-core-3.11.jar:na]
    at net.grinder.engine.process.GrinderProcess.run(GrinderProcess.java:404) ~[grinder-core-3.11.jar:na]
    at net.grinder.engine.process.WorkerProcessEntryPoint.run(WorkerProcessEntryPoint.java:86) ~[grinder-core-3.11.jar:na]
    at net.grinder.engine.agent.IsolatedGrinderProcessRunner.run(IsolatedGrinderProcessRunner.java:53) [grinder-core-3.11.jar:na]
    at net.grinder.engine.agent.DebugThreadWorker$1.run(DebugThreadWorker.java:63) [grinder-core-3.11.jar:na]
Caused by: java.lang.ExceptionInInitializerError: null
    at clojure.lang.Compiler.<clinit>(Compiler.java:47) ~[clojure-1.5.0.jar:na]
    at net.grinder.scriptengine.clojure.ClojureScriptEngine.<init>(ClojureScriptEngine.java:54) ~[grinder-core-3.11.jar:na]
    at net.grinder.scriptengine.clojure.ClojureScriptEngineService.createScriptEngine(ClojureScriptEngineService.java:53) ~[grinder-core-3.11.jar:na]
    ... 5 common frames omitted
Caused by: java.lang.NullPointerException: null
    at clojure.lang.RT.baseLoader(RT.java:2043) ~[clojure-1.5.0.jar:na]
    at clojure.lang.RT.load(RT.java:417) ~[clojure-1.5.0.jar:na]
    at clojure.lang.RT.load(RT.java:411) ~[clojure-1.5.0.jar:na]
    at clojure.lang.RT.doInit(RT.java:447) ~[clojure-1.5.0.jar:na]
    at clojure.lang.RT.<clinit>(RT.java:329) ~[clojure-1.5.0.jar:na]
... 8 common frames omitted

Discussion

  • Philip Aston
    Philip Aston
    2013-04-29

    • assigned_to: Philip Aston
    • Priority: 1 --> 4
     
  • Philip Aston
    Philip Aston
    2013-04-29

    • status: open --> closed
     
  • Adrian Lanning
    Adrian Lanning
    2013-08-02

    This issue still seems to occur in Grinder 3.11. From a clean download, if I put clojure-1.4.0.jar on the classpath, the helloworld.clj example runs. But if I put clojure-1.5.1.jar on the classpath, the agent returns the same NullPointerException as the original poster.

    Would you consider re-opening this ticket?

     
  • Philip Aston
    Philip Aston
    2013-08-02

    This is fixed for the next release (3.12), see the milestone. I don't plan to release a patch against 3.11.

    Its a one line change (see the comment from 29/4) if you want to hack it locally.

     
  • Adrian Lanning
    Adrian Lanning
    2013-08-03

    Sorry for the confusion. I saw "The Grinder 3.11" in the commit diff for the grinder/CHANGES file and thought it had already landed.

    My apologies.

     
  • Jameson Quinn
    Jameson Quinn
    2014-07-08

    I'm trying to get meteor-load-test working and I think I'm still seeing this bug on the latest code. Here's what I've done:

    -installed meteor-load-test (on OSX with homebrew)
    -manually deleted all the 3.11-related files/dirs from ~/.m2/...
    -pulled and built 3.12-SNAPSHOT
    -edited meteor-load-test/project.clj to refer to 3.12-SNAPSHOT
    -run an agent and a console, and pressed "start workers"

    and here's the error I get:

    ...
    SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

    2014-07-08 10:30:42,016 ERROR worker-bootstrap: Error running worker process
    net.grinder.engine.common.EngineException: Clojure is not on the classpath
    at net.grinder.scriptengine.clojure.ClojureScriptEngineService.createScriptEngine(ClojureScriptEngineService.java:56) ~[grinder-core-3.12-SNAPSHOT.jar:na]
    ...

     
  • Philip Aston
    Philip Aston
    2014-07-13

    I cloned from HEAD, built, and "installed":

    $ git clone git://git.code.sf.net/p/grinder/code grinder-code
    $ mvn clean install -rf :grinder-http -DskipTests=true
    $ unzip grinder/target/grinder-3.12-SNAPSHOT-binary.zip
    

    then I ran the helloworld.clj:

    $ cd grinder-3.12-SNAPSHOT/examples/
    $ java -Dgrinder.script=helloworld.clj -Dgrinder.runs=2 -cp ../lib/grinder.jar net.grinder.Grinder
    2014-07-13 09:58:01,057 INFO  agent: The Grinder 3.12-SNAPSHOT
    2014-07-13 09:58:01,068 WARN  agent: Failed to connect to 'localhost/127.0.0.1:6372', proceeding without the console; set grinder.useConsole=false to disable this warning.
    2014-07-13 09:58:01,073 INFO  agent: Worker process command line: java '-javaagent:/tmp/foo/grinder-3.12-SNAPSHOT/examples/../lib/grinder-dcr-agent-3.12-SNAPSHOT.jar' -classpath '/tmp/foo/grinder-3.12-SNAPSHOT/examples/../lib/grinder.jar' net.grinder.engine.process.WorkerProcessEntryPoint
    2014-07-13 09:58:01,121 INFO  agent: worker ptlt21-0 started
    2014-07-13 09:58:02,530 INFO  worker.ptlt21-0: starting threads
    2014-07-13 09:58:02,560 INFO  worker.ptlt21-0: finished
    2014-07-13 09:58:02,880 INFO  agent: finished
    

    The log shows Clojure 1.5.1 was used:

    ptlt21:philipa% cat log/ptlt21-0.log
    2014-07-13 09:58:01,501 INFO  ptlt21-0 : The Grinder version 3.12-SNAPSHOT
    2014-07-13 09:58:01,507 INFO  ptlt21-0 : Java(TM) SE Runtime Environment 1.7.0_45-b18: Java HotSpot(TM) 64-Bit Server VM (24.45-b08, mixed mode) on Linux amd64 3.13.0-30-generic
    2014-07-13 09:58:01,509 INFO  ptlt21-0 : time zone is BST (+0100)
    2014-07-13 09:58:01,575 INFO  ptlt21-0 : registered plug-in net.grinder.plugin.http.HTTPPlugin
    2014-07-13 09:58:01,609 INFO  ptlt21-0 : worker process 0
    2014-07-13 09:58:01,636 INFO  ptlt21-0 : instrumentation agents: byte code transforming instrumenter for Jython 2.5; byte code transforming instrumenter for Java
    2014-07-13 09:58:02,526 INFO  ptlt21-0 : running "helloworld.clj" using Clojure 1.5.1
    

    So it works standalone.

    I suspect that Meteor is using other clojure classes before starting The Grinder. Unfortunately grinder code can't fix things that happen before it is called. This is a known weakness of the clojure runtime - http://dev.clojure.org/jira/browse/CLJ-1172.

    There's some muttering in CLJ-1172 about changes. You might try running with clojure 1.6.0 first in your CLASSPATH, just to see whether its been addressed.

    Otherwise, you'll have to get the meteor-load-test team to add the clojure.lang.RT.init() bootstrapping before they do anything significant with clojure.

     
  • Adrian Lanning
    Adrian Lanning
    2014-07-13

    Hi Jameson, thanks for trying meteor-load-test.

    meteor-load-test is pinned to Clojure 1.4.0 and Grinder 3.11 so you shouldn't see this issue with the stock lein deps but I can understand wanting to use a more current version.

    In your repro steps I noticed that you didn't mention updating the Clojure version so maybe that is causing the issue? (not sure if Grinder 3.12 works with Clojure 1.4)

    In any case, since this isn't an issue with The Grinder, please open a ticket over at https://github.com/alanning/meteor-load-test/issues and we'll figure out how to get it working.