- Created Saturday, June 21st 2014 @ 18:44:29
I uploaded a trivially simple bot to try the untested clojure support, and it appears to be failing to find the clojure/string library that I used to split the input line.
The key error seems to be: Caused by: java.io.FileNotFoundException: Could not locate clojure/string__init.class or clojure/string.clj on classpath:
I built the code myself using leiningen, but I wasn't sure what format was expected, so my zip online contains the core.clj file and not any of the leiningen structure (project.clj, src folder, etc).
It seems to me there are a few possibilities:
1) My zip file format doesn't match what you expect.
2) The build process is unintentionally excluding clojure/string namespace
3) The build process is intentionally excluding clojure/string namespace and anyone using clojure should stick to some smaller subset (clojure/core?).
Can you provide any hints as to how its building clojure now or what the expectations are?
- Created Saturday, June 21st 2014 @ 20:15:14
For what its worth I was able to work around the clojure/string issue by using java interop to call java.util.String's split method, but it still doesn't pass the tests:
Test failed: no output
In my local testing the bot responds to "Action
", but perhaps there is another issue. Is there an example input file we can test with?
- Created Saturday, June 21st 2014 @ 20:25:23
Was able to make some more progress by explicitly calling my main function in the file, which is what lein does when you execute "lein run".
Any information about how the clojure code is invoked might help narrow down these issues and make providing a very simple Clojure starter bot easier.
That said, it appears to work!
- Created Monday, June 23rd 2014 @ 14:38:10
Glad it works. We should add some more information about this indeed, because it's not the 'traditional' way to compile/run clojure. We don't compile but run it with java and the clojure jar.
- Created Monday, June 23rd 2014 @ 14:55:13
I tried to recreate the clojure/string namespace issue locally using
java -jar <clojure.jar> core.clj
and it didn't seem to have any trouble finding the clojure/string package.
Are you passing a -cp flag or something that might be affecting the classpath. Perhaps I can recreate?
- Updated Monday, June 23rd 2014 @ 15:01:56
this is how it's ran:
java -cp lib/clojure.jar:bin/ -Xss8m -Xmx450m clojure.main '$MAINCLJ'
running is called from /bin, source files are located in /src and the jar is in /lib
- Updated Tuesday, June 24th 2014 @ 01:20:34
I tried to mimic the way you launch by running my bot with:
java -cp ~/.m2/repository/org/clojure/clojure/1.6.0/clojure-1.6.0.jar -Xss8m -Xmx450m clojure.main omaha_cloj/core.clj
It worked fine locally, but when I upload using clojure/string it still can't see the clojure.string namespace:
Caused by: java.io.FileNotFoundException: Could not locate clojure/string__init.class or clojure/string.clj on classpath
It is simple enough to use java interop rather than the Clojure string library in this specific case, but there are probably others where the real clojure libraries would be better.
Is there any chance you are using some kind of trimmed down clojure jar? In my case string__init.class is clearly in the jar file and should therefore be on the classpath.
Another possibility is a different java version? I'm using "OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)"
- Created Tuesday, June 24th 2014 @ 02:54:21
I sorted it out. The issue isn't how its launching, but the version of Clojure you are using. My updated bot prints the version to system err:
Clojure Version= 1.1.0
Clojure 1.1 came out late in 2009, and quite a few things I've tried so far (clojure.String, case function, etc) didn't arrive until 1.2 which was released in Aug 2010.
It would be really great if we could use the latest (1.6.0) but moving to something slightly newer than 1.1 would probably add a lot of functionality.
I'm not sure how & where you are hosting, or if you depend on pre-packaged versions, but I know Ubuntu 14.04 has packages for 1.2 and 1.4.
- Created Monday, June 30th 2014 @ 09:34:28
Thanks for pointing that out, I've updated Clojure to version 1.6
- Updated Sunday, July 13th 2014 @ 11:23:32
I was working on a Clojure bot as well and ran into the same issue. I use multiple files and namespaces, all but core.clj can't be found on the classpath:
Exception in thread "main" java.io.FileNotFoundException: Could not locate ai_omaha/cards__init.class or ai_omaha/cards.clj on classpath: , compiling:(/src/ai-omaha/src/ai_omaha/core.clj:1:1)
I can reproduce the error locally with: java -cp ~/.m2/repository/org/clojure/clojure/1.6.0/clojure-1.6.0.jar clojure.main src/ai_omaha/core.clj
How is '$MAINCLJ' set? I think normally Leiningen sets the classpath and runs the -main function. I don't have enough experience running Clojure without Leiningen to give a solution, but I will try and find this out.
- Created Monday, July 14th 2014 @ 12:48:22
$MAINCLJ is the file with 'defn -main' in it
- Created Thursday, August 7th 2014 @ 21:47:13
Couldn't get the app to automatically require other namespaces. Leiningen usually handles the icks of classpaths etc. I worked around it by creating a main.clj (with the -main function) that bootstraps the app. It starts with a series of (load-file "src/ai_omaha/core.clj) etc statements for loading all the other namespaces. At least it works.
The problem I have now is the message:
Running testcase /opt/aigames/etc/testsheadsupomaha/testheadsupomaha.txt... Testing Bot with setup input... ... finished testcase in 3.1799999997 seconds Test failed: no output
Is there a way we can access/run these test cases for debugging? It seems to work locally...