Search Results

Search found 972 results on 39 pages for 'scala'.

Page 13/39 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • SBT run differences between scala and java?

    - by Eric Cartner
    I'm trying to follow the log4j2 configuration tutorials in a SBT 0.12.1 project. Here is my build.sbt: name := "Logging Test" version := "0.0" scalaVersion := "2.9.2" libraryDependencies ++= Seq( "org.apache.logging.log4j" % "log4j-api" % "2.0-beta3", "org.apache.logging.log4j" % "log4j-core" % "2.0-beta3" ) When I run the main() defined in src/main/scala/logtest/Foo.scala: package logtest import org.apache.logging.log4j.{Logger, LogManager} object Foo { private val logger = LogManager.getLogger(getClass()) def main(args: Array[String]) { logger.trace("Entering application.") val bar = new Bar() if (!bar.doIt()) logger.error("Didn't do it.") logger.trace("Exiting application.") } } I get the output I was expecting given that src/main/resources/log4j2.xml sets the root logging level to trace: [info] Running logtest.Foo 08:39:55.627 [run-main] TRACE logtest.Foo$ - Entering application. 08:39:55.630 [run-main] TRACE logtest.Bar - entry 08:39:55.630 [run-main] ERROR logtest.Bar - Did it again! 08:39:55.630 [run-main] TRACE logtest.Bar - exit with (false) 08:39:55.630 [run-main] ERROR logtest.Foo$ - Didn't do it. 08:39:55.630 [run-main] TRACE logtest.Foo$ - Exiting application. However, when I run the main() defined in src/main/java/logtest/LoggerTest.java: package logtest; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; public class LoggerTest { private static Logger logger = LogManager.getLogger(LoggerTest.class.getName()); public static void main(String[] args) { logger.trace("Entering application."); Bar bar = new Bar(); if (!bar.doIt()) logger.error("Didn't do it."); logger.trace("Exiting application."); } } I get the output: [info] Running logtest.LoggerTest ERROR StatusLogger Unable to locate a logging implementation, using SimpleLogger ERROR Bar Did it again! ERROR LoggerTest Didn't do it. From what I can tell, ERROR StatusLogger Unable to ... is usually a sign that log4j-core is not on my classpath. The lack of TRACE messages seems to indicate that my log4j2.xml settings aren't on the classpath either. Why should there be any difference in classpath if I'm running Foo.main versus LoggerTest.main? Or is there something else causing this behavior? Update I used SBT Assembly to build a fat jar of this project and specified logtest.LoggerTest to be the main class. Running it from the command line produced correct results: Eric-Cartners-iMac:target ecartner$ java -jar "Logging Test-assembly-0.0.jar" 10:52:23.220 [main] TRACE logtest.LoggerTest - Entering application. 10:52:23.221 [main] TRACE logtest.Bar - entry 10:52:23.221 [main] ERROR logtest.Bar - Did it again! 10:52:23.221 [main] TRACE logtest.Bar - exit with (false) 10:52:23.221 [main] ERROR logtest.LoggerTest - Didn't do it. 10:52:23.221 [main] TRACE logtest.LoggerTest - Exiting application.

    Read the article

  • Thread pool in scala

    - by ghedas
    I have a project that is actor-based and for one part of it I must use some actors that receive message after that one actor assigns to each request separately and each actor is responsible for doing its message request, so I need something like a thread pool for actors of my project, are there any features in Scala that is useful for my necessity? how can I achieve this goal? tanks a lot for your attention!

    Read the article

  • scala actor message definition

    - by BenZen
    Do i need to define class for message i want to retrieve on a scala actor? i trying to get this up where am i wrong def act() { loop { react { case Meet = foundMeet = true ; goHome case Feromone(qty) if (foundMeet == true) = sender ! Feromone(qty+1); goHome }}}

    Read the article

  • Are Maybes a good pattern for scala?

    - by Fred Haslam
    For a while I have been struggling to integrate scala with java methods that might return null. I came up with the following utility which helps a lot: // produce an Option, nulls become None object Maybe { def apply[T](t:T) = if (t==null) None else Some(t) } Maybe(javaClass.getResultCouldBeNull()).map( result => doSomeWork(result) ) I have a few questions about this solution: Is there a better or more standard pattern to use? Am I duplicating something that already exists? Does this functionality have hidden gotchas?

    Read the article

  • Unpacking tuple types in Scala

    - by jpalecek
    I was just wondering, can I decompose a tuple type into its components' types in Scala? I mean, something like this trait Container { type Element } trait AssociativeContainer extends Container { type Element <: (Unit, Unit) def get(x : Element#First) : Element#Second }

    Read the article

  • Scala passing type parameters to object

    - by Shahzad Mian
    In Scala v 2.7.7 I have a file with class Something[T] extends Other { } object Something extends OtherConstructor[Something] { } This throws the error: class Something takes type parameters object Something extends OtherConstructor[Something] { However, I can't do this object Something[T] extends OtherConstructor[Something[T]] { } It throws an error: error: ';' expected but '[' found. Is it possible to send type parameters to object? Or should I change and simply use Otherconstructor

    Read the article

  • Create and populate two-dimensional array in Scala

    - by ~asteinlein
    What's the recommended way of creating a pre-populated two-dimensional array in Scala? I've got the following code: val map = for { x <- (1 to size).toList } yield for { y <- (1 to size).toList } yield (x, y) How do I make an array instead of list? Replacing .toList with .toArray doesn't compile. And is there a more concise or readable way of doing this than the nested for expressions?

    Read the article

  • scala Slider throws casting exception

    - by coubeatczech
    hello, I create an Slider object: val slider = new Slider{ min = 0 max = 30 labels = Map(0 -> new Label("Nula"),15-> new Label("Pul"),30-> new Label("Max")) paintLabels = true } when I run this, an exception is thrown: scala.swing.Label cannot be cast to java.awt.Component but why? When i browse the docs, the excpected type for labels is a Map[Int,Label].

    Read the article

  • Scala: Can't catch exception thrown inside a closure

    - by Dmitriy
    Disclaimer: absolute novice in Scala :( I have the following defined: def tryAndReport(body: Unit) : Unit = { try { body } catch { case e: MySpecificException => doSomethingUseful } } I call it like this: tryAndReport{ someCodeThatThrowsMySpecificException() } While the call to someCodeThatThrowsMySpecificException happens just fine, the exception is not being caught in tryAndReport. Why? Thank you!

    Read the article

  • Can one create Sized Types in Scala?

    - by Jens Schauder
    Is it possible to create types like e.g. String(20) in scala? The aim would be to have compiler checks for things like: a: String(20) b: String(30) a = b; // throws a compiler exception when no implicit conversion is available b= a; // works just fine Note: It doesn't need to be/named String

    Read the article

  • Where do I find an Open Source project written in Scala?

    - by stacker
    I'm looking for a well documented open source project, written in scala to see best practices etc. At sourceforge.net I found a few projects tagged as scala but they were actually written in java. github seems a bit better: http://groups.google.com/group/scala-melb/web/open-scala-projects Does anyone know such a project which could be recommended for learning?

    Read the article

  • Scala Map conversion

    - by Benjamin Metz
    I'm a Scala newbie I'm afraid: I'm trying to convert a Map to a new Map based on some simple logic: val postVals = Map("test" - "testing1", "test2" - "testing2", "test3" - "testing3") I want to test for value "testing1" and change the value (while creating a new Map) def modMap(postVals: Map[String, String]): Map[String, String] = { postVals foreach {case(k, v) => if(v=="testing1") postVals.update(k, "new value")} }

    Read the article

  • Improving MVP in Scala

    - by Alexey Romanov
    The classical strongly typed MVP pattern looks like this in Scala: trait IView { } trait Presenter[View <: IView] { // or have it as an abstract type member val view : View } case class View1(...) extends IView { ... } case object Presenter1 extends Presenter[View1] { val view = View1(...) } Now, I wonder if there is any nice way to improve on it which I am missing...

    Read the article

  • Simple Scala actor question

    - by 7zark7
    I'm sure this is a very simple question, but embarrassed to say I can't get my head around it: I have a list of values in Scala. I would like to use use actors to make some (external) calls with each value, in parallel. I would like to wait until all values have been processed, and then proceed. There's no shared values being modified. Could anyone advise? Thanks

    Read the article

  • Streaming Video In Scala InfoChannel Designer 5

    - by godleuf
    I am having the hardest time finding urls to use in Scala Designer 5 showing video streams. I am new at this program, but there is an option to run a video as a background. I have found a couple of samples to link to, but nothing great thus far. Anyone out there using this program and wanting to do the same? Thanks.

    Read the article

  • Scala Hoogle equivalent?

    - by Alexey Romanov
    Hoogle allows you to search many standard Haskell libraries by either function name, or by approximate type signature. I find it very useful. Is there anything like Hoogle for Scala? Search in ScalaDoc 2 only finds types and packages by name.

    Read the article

  • Best method to peek into a Scala Actor's Mailbox

    - by scaling_out
    Using Scala 2.8 RC1 or newer, what is the best (easiest and/or most direct) method to "peek" at the waiting messages in an actor's mailbox (from within the same actor's act() method) in order to examine what is in the queue, without having to react/receive the messages and/or disturb the current contents of the mailbox in any way. The purpose of this is so that an actor may determine if it is safe to process a request to exit by first determining if any of the remaining mailbox messages are ones that must be processed, instead of just dropped by stopping the actor immediately.

    Read the article

  • Is scala's cake pattern possible with parametrized components?

    - by Nicolas
    Parametrized components work well with the cake pattern as long as you are only interested in a unique component for each typed component's, example: trait AComponent[T] { val a:A[T] class A[T](implicit mf:Manifest[T]) { println(mf) } } class App extends AComponent[Int] { val a = new A[Int]() } new App Now my application requires me to inject an A[Int] and an A[String], obviously scala's type system doesn't allow me to extends AComponent twice. What is the common practice in this situation ?

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >