sbt / sbt-onejar

Packages your project using One-JAR™
MIT License
268 stars 45 forks source link

Scala object not found #1

Closed timperrett closed 13 years ago

timperrett commented 13 years ago

Hey hey,

Just tried to add one-jar to extradoc that I forked to see if one could create a binary version negating the need for shell scripts and using the one-jar sbt plugin results in:

λ java -jar extradoc_2.8.0-0.1-SNAPSHOT-onejar.jar error: fatal error: object scala not found. one error found

You see this error when the scala library cannot be properly loaded. Any ideas? I'm unsure if this is a direct issue with the plugin or one-jar itself. There was some funky stuff going on with one-jar which was why I have ditched it at work in favour of Apache Shade.

Cheers, Tim

timperrett commented 13 years ago

Oh btw, the repo is here: https://github.com/timperrett/extradoc/

Just run onejar and try to invoke the output JAR to replicate the issue

retronym commented 13 years ago

The plugin is laying things out as expected, other than for putting extradoc_2.8.0-0.1-SNAPSHOT.jar in both ./lib and ./main.


 ~/code/extradoc[master*]: jar tf ./target/scala_2.8.0/extradoc_2.8.0-0.1-SNAPSHOT-onejar.jar | sort
META-INF/MANIFEST.MF
OneJar.class
boot-manifest.mf
com/simontuffs/onejar/Boot$1.class
com/simontuffs/onejar/Boot$2.class
com/simontuffs/onejar/Boot$3.class
com/simontuffs/onejar/Boot.class
com/simontuffs/onejar/Handler$1.class
com/simontuffs/onejar/Handler.class
com/simontuffs/onejar/IProperties.class
com/simontuffs/onejar/JarClassLoader$1.class
com/simontuffs/onejar/JarClassLoader$2.class
com/simontuffs/onejar/JarClassLoader$ByteCode.class
com/simontuffs/onejar/JarClassLoader$FileURLFactory$1.class
com/simontuffs/onejar/JarClassLoader$FileURLFactory.class
com/simontuffs/onejar/JarClassLoader$IURLFactory.class
com/simontuffs/onejar/JarClassLoader$OneJarURLFactory.class
com/simontuffs/onejar/JarClassLoader.class
com/simontuffs/onejar/OneJarFile$1.class
com/simontuffs/onejar/OneJarFile$2.class
com/simontuffs/onejar/OneJarFile.class
com/simontuffs/onejar/OneJarURLConnection.class
doc/one-jar-license.txt
lib/extradoc_2.8.0-0.1-SNAPSHOT.jar
lib/scala-compiler.jar
lib/scala-library.jar
main/extradoc_2.8.0-0.1-SNAPSHOT.jar

You need to invoke Scalac from extradoc with settings suitable for this One-JAR classloader. This is a similar situation to embedding the REPL in SBT, and Mark Harrah contributed a change to Scala 2.8.1 that makes this possible.

https://gist.github.com/404272 https://lampsvn.epfl.ch/trac/scala/changeset/22949

timperrett commented 13 years ago

Damn, figured this might be the problem - perhaps i'll just drop in a pom for the time being and use shade to make a standalone binary :-) Thanks for the super prompt response!

retronym commented 13 years ago

This might work as an alternative to Shade: https://github.com/codahale/assembly-sbt