No JLineReader in REPL

172 views
Skip to first unread message

Jan van der Vorst

unread,
Jun 2, 2011, 11:35:11 AM6/2/11
to scala-user
Since 2.9.0 when starting the REPL (both in a cmd shell and in a
cygwin bash shell) I get the message:
Failed to created JLineReader: java.lang.NoClassDefFoundError: Could
not initialize class org.fusesource.jansi.internal.Kernel32

The result is that there is no 'history' in the REPL, making it very
hard to use.
I am working in Windows XP with Scala version 2.9.0.1 (Java
HotSpot(TM) Client VM, Java 1.6.0_25)

I have seen some proposed patches in the scala-language group but I
can't get any of them to work for me.
Also I can't find any open bug-report regarding this problem.

Is this a known problem?
Should I file a bug-report?

thanks,
Jan van der Vorst

marc

unread,
Jun 2, 2011, 12:41:18 PM6/2/11
to scala...@googlegroups.com
Jan,

I had a similar issue where sbt console was not echoing text.  I am not sure if this is your issue, however, comment #5  here fixed the issue for me.

Sciss

unread,
Jun 2, 2011, 1:14:08 PM6/2/11
to scala...@googlegroups.com
i had the same problem with sbt console when moving to 0.7.7. this is how i fixed it:

$ rm -r ~/.ivy2/sbt/
$ rm -r project/boot
$ sbt clean-cache

it was sufficient to remove ~/.ivy2/sbt so i didn't need to delete all my cache. it seems that this directory hasn't be recreated yet by sbt, so maybe it was something specific to sbt 0.7.5 ?

best, -sciss-

huynhjl

unread,
Jun 2, 2011, 2:03:10 PM6/2/11
to scala-user
I'm not exactly sure on the circumstances when that happens, but I've
had similar issues when the jline/jansi dlls cannot be written to the
temp directory.

with cmd.exe try this:
del %TEMP%\jansi.dll
del %TEMP%\jline_.dll

then try again.

With cygwin, use (as bootcp interferes with dll loading):
scala -nobootcp

--Jean-Laurent

Daniel Sobral

unread,
Jun 2, 2011, 2:14:10 PM6/2/11
to Sciss, scala...@googlegroups.com
None of these solutions have worked for me. I have erased ivy2, m2,
project/boot, done sbt clean-cache, and I still have this problem.

--
Daniel C. Sobral

I travel to the future all the time.

marc

unread,
Jun 2, 2011, 3:47:20 PM6/2/11
to scala...@googlegroups.com, Sciss
Ouch.  Good luck!  If I think of anything else, I will post.

Jan van der Vorst

unread,
Jun 3, 2011, 8:36:38 AM6/3/11
to scala-user
Thanks to you all!

I am sorry to say that none worked for me.
By the way, I am not using SBT so I expect that the problem can not be
caused by the ivy directory.

anyway, thanks again,
Jan van der Vorst

huynhjl

unread,
Jun 3, 2011, 11:09:29 AM6/3/11
to scala-user
Hi Jan,

I would recommend to file a bug report with your Windows system
information and the error message.

One more thing you could try is to compile and run the following
program:

object Test extends App {
println(org.fusesource.jansi.internal.WindowsSupport.getConsoleMode)
}

This would cause the dll to be unpacked and loaded. I suspect it will
fail on your system. The stack trace may provide more information than
what the REPL provides. For instance, after I intentionally corrupted
my environment:

C:\code\scala\tmp>\setup\scala\scala-2.9.0.final\bin\scala.bat -cp
classes Test
java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [C:
\code\scala\tmp\jansi.dll: Access is denied, C:\code\scala\tmp
\jansi.dll: Access is denied]
at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:
182)

Assuming you're not the only one to get this error, any extra
information is useful to pinpoint the root cause.

--Jean-Laurent

Dave

unread,
Jun 3, 2011, 11:57:50 AM6/3/11
to scala-user
Have you (double) checked your environment variables? Do you have a
SCALA_HOME environment variable?
Check also your CLASSPATH for other (old) references and remove that.

SCALA_HOME should be C:\scala-2.9.0.1 (or where scala is installed)
and
In PATH there should be %SCALA_HOME%\bin
If this done, scala.bat is automatically adding all lib jars to the
CLASSPATH when startin scala
then class org.fusesource.jansi.internal.Kernel32 should be found in
lib\jline.jar by scala.bat

Jan van der Vorst

unread,
Jun 4, 2011, 4:52:19 AM6/4/11
to scala-user
Hi Jean-Laurent

I did as you proposed and created the object Test. And indeed I got a
more descriptive error message now:

C:\cygwin\home\jv54580\prog\JLine>scala Test
java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no
jansi in java.library.path, C:\WINDOWS\Temp\jansi.d
ll: This application has failed to start because the application
configuration is incorrect. Reinstalling the applicatio
n may fix this problem]
at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:
182)
at org.fusesource.hawtjni.runtime.Library.load(Library.java:
142)
at
org.fusesource.jansi.internal.Kernel32.<clinit>(Kernel32.java:40)
at
org.fusesource.jansi.internal.WindowsSupport.getConsoleMode(WindowsSupport.java:
48)
at Test$delayedInit$body.apply(jline.scala:2)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV
$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:60)
at scala.App$$anonfun$main$1.apply(App.scala:60)
at scala.collection.LinearSeqOptimized
$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:45)
at scala.collection.generic.TraversableForwarder
$class.foreach(TraversableForwarder.scala:30)
at scala.App$class.main(App.scala:60)
at Test$.main(jline.scala:1)
at Test.main(jline.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run
$1.apply(ScalaClassLoader.scala:78)
at scala.tools.nsc.util.ScalaClassLoader
$class.asContext(ScalaClassLoader.scala:24)
at scala.tools.nsc.util.ScalaClassLoader
$URLClassLoader.asContext(ScalaClassLoader.scala:88)
at scala.tools.nsc.util.ScalaClassLoader
$class.run(ScalaClassLoader.scala:78)
at scala.tools.nsc.util.ScalaClassLoader
$URLClassLoader.run(ScalaClassLoader.scala:101)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:33)
at scala.tools.nsc.ObjectRunner
$.runAndCatch(ObjectRunner.scala:40)
at scala.tools.nsc.MainGenericRunner.runTarget
$1(MainGenericRunner.scala:56)
at
scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:80)
at scala.tools.nsc.MainGenericRunner
$.main(MainGenericRunner.scala:89)
at
scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)


I checked whether C:\WINDOWS\Temp\jansi.dll is present, it is.
(By the way, although the prompt suggests otherwise I am running this
in a cmd.exe shell.)

Thanks for your advice.
Jan
> > > Ouch.  Good luck!  If I think of anything else, I will post.- Hide quoted text -
>
> - Show quoted text -

Jan van der Vorst

unread,
Jun 4, 2011, 4:56:46 AM6/4/11
to scala-user
Hi Dave,
I double checked but unfortunately this is not the culprit.
Thanks for your advice,
Jan

huynhjl

unread,
Jun 4, 2011, 4:15:04 PM6/4/11
to scala-user
Thanks. I don't think that it's likely to be corrupted, but could you
check the md5 on the jansi.dll?

d47102e00a05c357e91988d56ca7a635 *META-INF/native/windows64/jansi.dll
2452a4f2c62c0447948444cfb0f9f428 *META-INF/native/windows32/jansi.dll

A bit of googling suggests that the "This application has failed to
start because the application
configuration is incorrect. Reinstalling the application may fix this
problem" message is usually associated with missing dependencies
http://msdn.microsoft.com/en-us/library/ms235299(v=vs.80).aspx

The following tool http://www.dependencywalker.com/ can help with
finding out which one. On my machine it shows that I have:
- c:\windows\system32\NTDLL.DLL
- c:\windows\system32\KERNEL32.DLL
It also shows I don't have MSVCR90.DLL.

I can't imagine that you would have corrupted NTDLL.DLL or
KERNEL32.DLL and not notice otherwise. May be it's something to do
with the path, once you start scala... Could it be that
java.library.path get's overwritten and c:\windows\system32 is
missing? Try this and see if yield obvious clues.

object Test extends App {
println(System.getProperty("java.library.path"))
println(org.fusesource.jansi.internal.WindowsSupport.getConsoleMode)
}

Other than that I'm out of ideas...

Jan van der Vorst

unread,
Jun 5, 2011, 6:15:45 AM6/5/11
to scala-user


> 2452a4f2c62c0447948444cfb0f9f428 *META-INF/native/windows32/jansi.dll
md5 matches.

> It also shows I don't have MSVCR90.DLL.
I get an error message regarding a missing MSVCR90.DLL
I presume you also got that message, but in your case this does not
lead to a problem with the JLineReader right?



> missing? Try this and see if yield obvious clues.
> ...
I do not see anything special; c:\windows\system32 is in.

> Other than that I'm out of ideas...
Thanks for putting in your time, you showed me some interesting
tricks.
Jan

Jan van der Vorst

unread,
Jun 5, 2011, 8:01:54 AM6/5/11
to scala-user
Gotcha!
Problem solved by installing the MS VC++ Runtime libraries from
http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2
which contains msvcr90.dll

many thanks to Jean-Laurent!
Jan

huynhjl

unread,
Jun 5, 2011, 8:09:48 AM6/5/11
to scala-user
> > It also shows I don't have MSVCR90.DLL.
>
> I get an error message regarding a missing MSVCR90.DLL
> I presume you also got that message, but in your case this does not
> lead to a problem with the JLineReader right?

Correct. I'm not in front of the right computer to check my setup but
I found a pretty good read here: http://www.davidlenihan.com/2007/07/winsxs.html

I would give a shot at installing vcredist_x86.exe (or
vcredist_x64.exe).

http://www.microsoft.com/downloads/en/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&displaylang=en
http://www.microsoft.com/downloads/en/details.aspx?familyid=BA9257CA-337F-4B40-8C14-157CFDFFEE4E&displaylang=en

huynhjl

unread,
Jun 5, 2011, 8:31:21 AM6/5/11
to scala-user
Awesome! I learned a few things myself and I'm glad that it wasn't in
vain.

On Jun 5, 5:01 am, Jan van der Vorst <ndervo...@gmail.com> wrote:
> Gotcha!
> Problem solved by installing the MS VC++ Runtime libraries fromhttp://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=A5C8...
Reply all
Reply to author
Forward
0 new messages