ztellman / penumbra

not under active development - idiomatic opengl bindings for clojure
354 stars 43 forks source link

Total failure on Mac OS X #19

Closed taoeffect closed 12 years ago

taoeffect commented 14 years ago

I'm pretty sure the penumbra/lwjgl superjar file doesn't work on OS X. :-\

Please see my comment here: http://nakkaya.com/2010/05/25/jmonkeyengine-hello-world-in-clojure/

I get this error:

Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.NoClassDefFoundError: [Lorg/lwjgl/opengl/DisplayMode; (core.clj:14)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:5371)
    at clojure.lang.Compiler.analyze(Compiler.java:5185)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:5352)
    at clojure.lang.Compiler.analyze(Compiler.java:5185)
    at clojure.lang.Compiler.analyze(Compiler.java:5146)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:4665)
    at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:4936)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:5364)
    at clojure.lang.Compiler.analyze(Compiler.java:5185)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:5352)
    at clojure.lang.Compiler.analyze(Compiler.java:5185)
    at clojure.lang.Compiler.analyze(Compiler.java:5146)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:4665)
    at clojure.lang.Compiler$FnMethod.parse(Compiler.java:4323)
    at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3168)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:5362)
    at clojure.lang.Compiler.analyze(Compiler.java:5185)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:5352)
    at clojure.lang.Compiler.analyze(Compiler.java:5185)
    at clojure.lang.Compiler.analyze(Compiler.java:5146)
    at clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java:798)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:5364)
    at clojure.lang.Compiler.analyze(Compiler.java:5185)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:5352)
    at clojure.lang.Compiler.analyze(Compiler.java:5185)
    at clojure.lang.Compiler.access$100(Compiler.java:35)
    at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:438)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:5364)
    at clojure.lang.Compiler.analyze(Compiler.java:5185)
    at clojure.lang.Compiler.analyze(Compiler.java:5146)
    at clojure.lang.Compiler.eval(Compiler.java:5423)
    at clojure.lang.Compiler.load(Compiler.java:5852)
    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__4504.invoke(core.clj:4893)
    at clojure.core$load.doInvoke(core.clj:4892)
    at clojure.lang.RestFn.invoke(RestFn.java:409)
    at clojure.lang.Var.invoke(Var.java:365)
    at jME.core.(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: [Lorg/lwjgl/opengl/DisplayMode;
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
    at java.lang.Class.privateGetPublicMethods(Class.java:2547)
    at java.lang.Class.getMethods(Class.java:1410)
    at clojure.lang.Reflector.getMethods(Reflector.java:310)
    at clojure.lang.Compiler$StaticMethodExpr.(Compiler.java:1347)
    at clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java:832)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:5364)
    ... 40 more
Caused by: java.lang.ClassNotFoundException: org.lwjgl.opengl.DisplayMode
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    ... 48 more

Basically, it looks like the lwjgl.jar and native lives in lwjgl-2.4.2.jar aren't getting loaded on OS X when created with the uberjar.

I have to add lwjgl.jar and lwjgl_util.jar to the system-wide java extensions directory (~/Library/Java/Extensions) which get loaded into all java processes. Then I have to manually specify the path to the native libs:

java -Djava.library.path=./native/macosx/x86/ -jar jME-1.0.0-SNAPSHOT-standalone.jar

Only then will it work. Here's my project.clj file:

(defproject jME "1.0.0-SNAPSHOT"
  :description "FIXME: write"
  :dependencies [[org.clojure/clojure "1.2.0-master-SNAPSHOT"]
                 [org.clojure/clojure-contrib "1.2.0-SNAPSHOT"]
                 [org.clojars.nakkaya.jmonkeyengine/jme "2.0.1"]
                 [penumbra/lwjgl "2.4.2"]]
  :native-dependencies [[penumbra/lwjgl "2.4.2"]]
  :dev-dependencies    [[native-deps "1.0.0"]]
  :main jME.core
  :disable-implicit-clean true ; included to fix a bug in Leinginen 1.2.0-RC2
)
ztellman commented 14 years ago

My development environment is OS X, so I'm pretty sure it's not that. Did you run "lein native-deps"?

taoeffect commented 14 years ago

Yup. That's why the -Djava.library.path=./native/macosx/x86/ is there.

Did you try compiling that project (without anything in your ~/Library/Java/Extensions folder)? Are you using Leiningen 1.2.0-RC2?

I'd be happy to try any suggestions out.

ztellman commented 14 years ago

I am using Leiningen 1.2.0-RC2 with a clean Extensions folder. The error you're seeing seems to imply that you don't have lwjgl.jar on your classpath. My expectation is that if you're using 1.2.0-RC2 and run "lein repl", it should work without issue.

taoeffect commented 14 years ago

'lein repl' does nothing (it sits there, not outputting anything).

Also, how is this a classpath issue when that should be solved by 'lein uberjar' with the standalone jar?

taoeffect commented 14 years ago

Crap. Closed the issue by accident.

ztellman commented 14 years ago

Sorry, I misread your original report. I expect uberjar only takes :dependencies into account, not :native-dependencies. Why use an uberjar in the first place?

taoeffect commented 14 years ago

Running the normal jar doesn't work either. How are you running it?

I tried with the uberjar and the non-uberjar (lame-jar, if you will):

java -Djava.library.path=./native/macosx/x86/ -cp jME-1.0.0-SNAPSHOT.jar:"lib/*" jME.core

Same exception. It's obviously not loaded the lwjgl.jar, but the lwjgl.jar is inside the lwjgl-2.4.2.jar (along with other jar files and native libraries). They're not being loaded.

I use uberjars because they're easy to run from the terminal. Again, lein repl doesn't work.

taoeffect commented 14 years ago

Perhaps this will help, I've zipped up the directory, you can get it here:

http://www.taoeffect.com/other/jME.zip

ztellman commented 14 years ago

I run things from the repl, or the slime-repl in emacs. The fact that the repl isn't running is pretty strange. Is it just not running for this project, or for all of them?

I always give complete paths in my classpath. "lib/*" may not be sufficient, I'm not sure. Try following the template given in the "Getting Started" wiki entry for Penumbra.

ztellman commented 14 years ago

Okay, I could get to a repl using "lein repl" with the contents of the zip file at http://dl.dropbox.com/u/174179/jME%202.zip

I was able to get the same error as you before calling lein native-deps. I now strongly suspect it's that "lib/*" is not a sufficiently qualified path.

taoeffect commented 14 years ago

I don't know what the deal is. I downloaded that zip file, unzipped it, went into the directory, ran 'lein repl', and it still just sits there doing nothing.

It's late, I've got to head off for now. Let me know if you're able to run the example in that folder or if you have any other ideas. Thanks for your help so far.

ztellman commented 14 years ago

Sorry, I dunno. If I run (main-) at the repl, everything runs. I would focus on getting that working. Uninstall lein and reinstall, maybe?

taoeffect commented 14 years ago

I don't know either. Leiningen is working fine for other projects with 'lein repl', just this doesn't work. I don't think it's a leiningen issue because I haven't touched that stuff (and did partially reinstall it by wiping out ~/.m2 and running lein self-install)..

I'm guessing something on a higher level is different between our systems, but I've given up for now as this just isn't that important, and in the future if I need to do this I could probably just use a manual Ant script. Still, I wouldn't be surprised if others were experiencing the same issue.