shdqcdsn / counterclockwise

Automatically exported from code.google.com/p/counterclockwise
0 stars 0 forks source link

nrepl not found, need to add nrepl lib on classpath #453

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A strange behaviour just popped out from nowhere this morning.

I have to add the nrepl dependency explicitly in each projects otherwise
loading a Clojure file crashes with:

Exception in thread "main" java.io.FileNotFoundException: Could not locate 
clojure/tools/nrepl/server__init.class or clojure/tools/nrepl/server.clj on 
classpath: 
    at clojure.lang.RT.load(RT.java:432)
    at clojure.lang.RT.load(RT.java:400)
    at clojure.core$load$fn__4890.invoke(core.clj:5415)
    at clojure.core$load.doInvoke(core.clj:5414)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5227)
    at clojure.core$load_lib.doInvoke(core.clj:5264)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$load_libs.doInvoke(core.clj:5298)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$require.doInvoke(core.clj:5381)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at user$eval417.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:6511)
    at clojure.lang.Compiler.eval(Compiler.java:6477)
    at clojure.core$eval.invoke(core.clj:2797)
    at clojure.main$eval_opt.invoke(main.clj:297)
    at clojure.main$initialize.invoke(main.clj:316)
    at clojure.main$null_opt.invoke(main.clj:349)
    at clojure.main$main.doInvoke(main.clj:427)
    at clojure.lang.RestFn.invoke(RestFn.java:457)
    at clojure.lang.Var.invoke(Var.java:427)
    at clojure.lang.AFn.applyToHelper(AFn.java:172)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.main.main(main.java:37)

The Eclipse log shows this:

!ENTRY ccw.core 1 0 2012-10-05 10:26:20.680
!MESSAGE Starting REPL with program args: -i 
"/opt/eclipse/plugins/ccw.core_0.10.2.201210050017/ccw/debug/serverrepl.clj" -e 
"(require 'clojure.tools.nrepl.server)(do 
(clojure.tools.nrepl.server/start-server :ack-port 19214) nil)"  

!ENTRY ccw.core 4 0 2012-10-05 10:26:50.726
!MESSAGE Waiting for new REPL process ack timed out

!ENTRY ccw.core 4 0 2012-10-05 10:26:50.728
!MESSAGE Waiting for new REPL process ack timed out

!ENTRY ccw.core 4 0 2012-10-05 10:26:50.781
!MESSAGE Could not start a REPL for loading file 
/home/lprefontaine/workspaces/higiebus/HIGIEBUSProtocols/test/higiebus/protocol/
test/test_profile_dsl.clj

I upgraded to the last beta 0.10.2.20121005, same behaviour.
I deleted the run configurations for all clojure projects to make sure no
creepy stuff remained but it did not change the outcome.

A couple of times after removing the nrepl dependency I succeeded starting
one but this does not stand an Eclipse restart.

I searched in the older issues but nothing seems to correlate.

Any suggestions where to search ? Need more info ? 

Btwy, I feel so much at home with CCW that this thing was a real show stopper.
That's a good indication of my addiction level :)

Thank you
Luc

Original issue reported on code.google.com by lprefont...@softaddicts.ca on 5 Oct 2012 at 2:28

GoogleCodeExporter commented 9 years ago

Original comment by laurent....@gmail.com on 10 Oct 2012 at 7:57

GoogleCodeExporter commented 9 years ago
Is this still reproducible with the last nrepl release you tried?

Original comment by laurent....@gmail.com on 12 Oct 2012 at 10:12

GoogleCodeExporter commented 9 years ago
Will check this week-end, today I was resting catching up for a missed holiday 
last Monday :)

Original comment by lprefont...@softaddicts.ca on 12 Oct 2012 at 10:42

GoogleCodeExporter commented 9 years ago
I added in project.clj the explicit nrepl dependency to the snapshot released
by Chas yesterday and removed the explicit eclipse project dependency to the 
beta7
version shipped with CCW.

No way I can start a REPL, I get this:

Exception in thread "main" java.lang.RuntimeException: 
java.io.FileNotFoundException: Could not locate 
clojure/tools/nrepl/server__init.class or clojure/tools/nrepl/server.clj on 
classpath: 
    at clojure.lang.Util.runtimeException(Util.java:165)
    at clojure.lang.Compiler.eval(Compiler.java:6476)
    at clojure.lang.Compiler.eval(Compiler.java:6431)
    at clojure.core$eval.invoke(core.clj:2795)
    at clojure.main$eval_opt.invoke(main.clj:296)
    at clojure.main$initialize.invoke(main.clj:315)
...
Caused by: java.io.FileNotFoundException: Could not locate 
clojure/tools/nrepl/server__init.class or clojure/tools/nrepl/server.clj on 
classpath: 
    at clojure.lang.RT.load(RT.java:430)
    at clojure.lang.RT.load(RT.java:398)
    at clojure.core$load$fn__4610.invoke(core.clj:5386)
...

If I specify the latest nrepl 2.0 snapshot as an eclipse project dependencies
everything works fine.

Here's the class path as it appeared in the nrepl server background process 
command:

/home/lprefontaine/workspaces/higiebus/HIGIEBUSProtocols/resources
/home/lprefontaine/workspaces/higiebus/HIGIEBUSProtocols/dev-resources
/home/lprefontaine/workspaces/higiebus/HIGIEBUSProtocols/test
/home/lprefontaine/workspaces/higiebus/HIGIEBUSProtocols/src
/home/lprefontaine/workspaces/higiebus/HIGIEBUSProtocols/classes
/home/lprefontaine/workspaces/higiebus/HIGIEBUSServices/classes
/home/lprefontaine/.m2/repository/avalon-framework/avalon-framework/4.1.3/avalon
-framework-4.1.3.jar
/home/lprefontaine/.m2/repository/avout/avout/0.5.3/avout-0.5.3.jar
/home/lprefontaine/.m2/repository/clj-logging-config/clj-logging-config/1.9.8/cl
j-logging-config-1.9.8.jar
/home/lprefontaine/.m2/repository/org/clojure/clojure/1.3.0/clojure-1.3.0.jar
/home/lprefontaine/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/comm
ons-beanutils-1.7.0.jar
/home/lprefontaine/.m2/repository/commons-codec/commons-codec/1.5/commons-codec-
1.5.jar
/home/lprefontaine/.m2/repository/org/apache/commons/commons-exec/1.1/commons-ex
ec-1.1.jar
/home/lprefontaine/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.jar
/home/lprefontaine/.m2/repository/commons-logging/commons-logging/1.1/commons-lo
gging-1.1.jar
/home/lprefontaine/.m2/repository/net/sf/cron4j/cron4j/2.2.3/cron4j-2.2.3.jar
/home/lprefontaine/.m2/repository/org/jasypt/jasypt/1.9.0/jasypt-1.9.0.jar
/home/lprefontaine/.m2/repository/org/clojure/java.jdbc/0.2.3/java.jdbc-0.2.3.ja
r
/home/lprefontaine/.m2/repository/jline/jline/0.9.94/jline-0.9.94.jar
/home/lprefontaine/.m2/repository/net/sourceforge/jtds/jtds/1.2.5/jtds-1.2.5.jar
/home/lprefontaine/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
/home/lprefontaine/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16.jar
/home/lprefontaine/.m2/repository/logkit/logkit/1.0.1/logkit-1.0.1.jar
/home/lprefontaine/.m2/repository/mysql/mysql-connector-java/5.1.16/mysql-connec
tor-java-5.1.16.jar
/home/lprefontaine/.m2/repository/com/taoensso/nippy/0.10.1/nippy-0.10.1.jar
/home/lprefontaine/.m2/repository/ojdbc/ojdbc/14/ojdbc-14.jar
/home/lprefontaine/.m2/repository/oraclepki/oraclepki/10.2/oraclepki-10.2.jar
/home/lprefontaine/.m2/repository/orai18n/orai18n/10.2.0.3/orai18n-10.2.0.3.jar
/home/lprefontaine/.m2/repository/javax/servlet/servlet-api/2.3/servlet-api-2.3.
jar
/home/lprefontaine/.m2/repository/org/xerial/snappy/snappy-java/1.0.4.1/snappy-j
ava-1.0.4.1.jar
/home/lprefontaine/.m2/repository/org/springframework/spring/2.5.5/spring-2.5.5.
jar
/home/lprefontaine/.m2/repository/org/clojure/tools.cli/0.2.1/tools.cli-0.2.1.ja
r
/home/lprefontaine/.m2/repository/org/clojure/tools.logging/0.2.3/tools.logging-
0.2.3.jar
/home/lprefontaine/.m2/repository/org/clojure/tools.trace/0.7.3/tools.trace-0.7.
3.jar
/home/lprefontaine/.m2/repository/org/apache/zookeeper/zookeeper/3.3.2/zookeeper
-3.3.2.jar
/home/lprefontaine/.m2/repository/zookeeper-clj/zookeeper-clj/0.9.2/zookeeper-cl
j-0.9.2.jar
/opt/clojure1.3/clojure-1.3.jar

The command sent to clojure main:

clojure.main -i 
/opt/eclipse/plugins/ccw.core_0.10.2.201210050017/ccw/debug/serverrepl.clj -e 
(require 'clojure.tools.nrepl.server)(do 
(clojure.tools.nrepl.server/start-server :ack-port 26118) nil)

Looks like something in ccw when it launches the nrepl server, dependencies are
missing.

Hopes this helps. The only change is that now it seems stable, if no nrepl
dependency is specified in the eclipse project class path, it fails.
Is this related to the new nrepl version maybe. It's late, can't see much now so
I'll head for Morpheus's arms :)

Luc

Original comment by lprefont...@softaddicts.ca on 13 Oct 2012 at 4:52

GoogleCodeExporter commented 9 years ago
Luc, here is the code responsible for checking if nrepl is already in the 
classpath of the project (in which case ccw does nothing special), or if it is 
not there (in which case ccw adds "on the fly" its own nrepl dependency to the 
classpath of the launcher):

https://github.com/laurentpetit/ccw/blob/master/ccw.core/src/java/ccw/launching/
ClojureLaunchDelegate.java#L274

There must be a case we haven't covered well in this code which causes the 
clash with your environment.

Original comment by laurent....@gmail.com on 14 Oct 2012 at 8:33

GoogleCodeExporter commented 9 years ago
So, if you see no "Adding to project's classpath to support nREPL:  ..." log in 
the workspace's .metadata/.log file, then the only explanation is that 
clojureProject.getJavaProject().findElement(new Path("clojure/tools/nrepl")) is 
null, meaning you have, somewhere in your Eclipse project's classpath, the 
"clojure.tools.nrepl" package.

Original comment by laurent....@gmail.com on 14 Oct 2012 at 8:40

GoogleCodeExporter commented 9 years ago

Original comment by laurent....@gmail.com on 14 Oct 2012 at 8:41

GoogleCodeExporter commented 9 years ago
I will dig later today in the eclipse metadata files, maybe it will shed some 
light on
this issue.

Thank you,
Luc

Original comment by lprefont...@softaddicts.ca on 14 Oct 2012 at 3:09

GoogleCodeExporter commented 9 years ago
Finally found a window to dig into this. The microwave died Sunday and I have 
been
busy trying to fix it plus flushing some late accounting work these two last 
working
days. Shitty week...

I removed all the references to nrepl I could find in my projects. I moved the
dependency on the nrepl snapshot into a production profile in the project.clj
file in the master project. The idea was to revert to a clean state of the 
latest
beta 0.10.2.201210111845 I just installed this morning without any interferences
from the tweaks I made to test the 64k limit fix from Chas.
I upgraded first before starting my cleanup.

I first removed any explicit eclipse project dependencies 
(./ccw.leiningen/<project-name>.container files). egrepping the files confirmed 
to me that no references in
the project specific setups remained. I had also removed a user library 
referring
to nrepl (I defined one to test the 64k limit issue earlier).

I tried to start a repl with ctl-alt-s, it did not succeeded, the same message
as above came out.

References remained in the following files (using grep -a 'tools.nrepl')

./org.eclipse.jdt.core/externalLibsTimeStamps
./org.eclipse.jdt.core/variablesAndContainers.dat

./.plugins/org.eclipse.m2e.core/nexus/...

and in some misc files resources history files).

I finally did a restart and now there are only references in the nexus and 
resource history files. The external lid and variables and container files are 
now clean.
At that poing I could successfully load a file in the REPL.
Of course the 64k fix is not there but that confirms that I am running the plain
nrepl bundled with ccw.

In the .log file there are a number of messages about pom.xml not being 
refreshed.
I did an external rebuild to make sure that no references to nrepl existed in 
the
code. We dynamically load it only in production and they are no static 
references to
it to avoid conflicts with the nrepl version bundled with ccw while coding.

You can see that my first attempts to load a file in nrepl failed.
Only after the restart was I able to successfully start the repl.

My initial feeling is that some references were still stuck in Eclipse and that
your test for the presence of nrepl could not detect reliably that it was not 
on the
class path. At the level the test is made you may have to believe what Eclipse
says about the context. If Eclipse is wrong then you are done :)

I can understand the need to allow an override the internal ccw default nrepl 
dependency but for most people it's not needed (at least I can't see a common 
use
case for it, tell me if I am wrong).

Maybe you should always add it to the class path except if an explicit project 
option is enabled ? Having the same dependency twice is not an issue if it's 
the same. Maybe a runtime check for potential version conflict ?

The current behaviour is quite confusing as soon as you reference
another nrepl dependency which may or may not be used in reality as what I found
seems to imply.

Let me know if you want me to do an other test to try to narrow the problem more
precisely.

Thank you,
Luc

Original comment by lprefont...@softaddicts.ca on 17 Oct 2012 at 2:55

Attachments:

GoogleCodeExporter commented 9 years ago
Luc, sorry for your microwave ;-(, may it RIP ;).

Once the 0.10 branch is stabilized, a progress will have to be made on the way 
CCW "launches" projects. The launch may well be totally delegated to a 
"Leiningen" launch configuration type. Or we may want to only reuse the config 
from the project.clj. The former ensure that it will start exactly like the 
command line, which is important. The latter may prove easier to integrate into 
Eclipse (stdin/out redirection to the console, debug mode, getting back the 
nrepl server's port, etc.).

I have not fixed my minds yet, but the result may well be that the Leiningen's 
classpath container becomes useless as far as starting a project is concerned.

Original comment by laurent....@gmail.com on 18 Oct 2012 at 2:57

GoogleCodeExporter commented 9 years ago
Now that I have a clean slate, you can park this issue until the above decision 
has been made.

With lein 2 and profiles, we can avoid messing with this in dev. We need to 
include nrepl explicitly only in
production builds and this always done with an external lein build.

At least we know that there are potential problems to mess up with alien nrepl 
dependencies in
Eclipse.

Thank you,
Luc

Original comment by lprefont...@softaddicts.ca on 18 Oct 2012 at 3:32

GoogleCodeExporter commented 9 years ago

Original comment by laurent....@gmail.com on 18 Oct 2012 at 4:33

GoogleCodeExporter commented 9 years ago

Original comment by laurent....@gmail.com on 15 Nov 2012 at 10:30

GoogleCodeExporter commented 9 years ago

Original comment by laurent....@gmail.com on 22 May 2014 at 7:43