I have those lines in my code
implicit val anyContentAsMultipartFormWritable: Writeable[AnyContentAsMultipartFormData] = {
MultipartFormDataWritable.singleton.map(_.mdf)
}
I had to upgrade my play version from play 2.5 to play 2.6.6, and now those lines are not working. This is the problem:
value mdf is not a member of play.api.mvc.AnyContentAsMultipartFormData
I see that mdf is a member of that class at documentation, and it not seems that this changed in play 2.6.6.
I would appreciate any help.
Related
I was upgrading my project from scala 2.11 to scala 2.12.
For DB Interaction slick-extentions was used, but I found out that slick-extension has been merged with Slick itself since Slick-3.2.0.
While I was going through the docs I found about JdbcProfiles and discontinuation of Drivers etc.
Now, I have a lot of code where withSession method from scala.slick.jdbc.JdbcBackend has been used - like -
db.withSession { implicit session =>
rmobVersionControl.foreach(e =>
elements += new RMOBVersionControlElement(e._1, e._2, e._3))
}
In the docs I see that withSession() method is Deprecated (Since version 3.0).
But I was wondering if there's a way to keep this code in slick 3.2.0 because changing all this code and using Action-Based Api would be a lot of pain.
I recently updated my Spark version from 2.2 to 2.4.0
I started having an error in this block (which was working fine with 2.2 version):
object Crud_mod {
def f(df: DataFrame,
options: JDBCOptions,
conditions: List[String]) {
val url = options.url
val tables = options.table
val dialect = JdbcDialects_mod.get(url)
error: value table is not a member of org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions
[ERROR] val tables = options.table
So I took a look inside Spark sources and value table seems to exist in JDBCOptions class.
What am I missing please?
Your sources link is pointing to a constructor, that accepts table as an argument, but I can't find table value in class itself.
However, there's tableOrQuery (here) method, that can be used for your needs, I think.
I am encountering a compile time error while attempting to get Squeryl example code running. The following code is based on the My Adventures in Coding blog post about connecting to SQLServer using Squeryl.
import org.squeryl.adapters.MSSQLServer
import org.squeryl.{ SessionFactory, Session}
import com.company.model.Consumer
class SandBox {
def tester() = {
val databaseConnectionUrl = "jdbc:jtds:sqlserver://myservername;DatabaseName=mydatabasename"
val databaseUsername = "userName"
val databasePassword = "password"
Class.forName("net.sourceforge.jtds.jdbc.Driver")
SessionFactory.concreteFactory = Some(()=>
Session.create(
java.sql.DriverManager.getConnection(databaseConnectionUrl, databaseUsername, databasePassword),
new MSSQLServer))
val consumers = table[Consumer]("Consumer")
}
}
I believe I have the build.sbt file configured correctly to import the Squeryl & JTDS libraries. When running SBT after adding the dependencies it appeared to download the libraries need.
libraryDependencies ++= List (
"org.squeryl" %% "squeryl" % "0.9.5-6",
"net.sourceforge.jtds" % "jtds" % "1.2.4",
Company.teamcityDepend("company-services-libs"),
Company.teamcityDepend("ssolibrary")
) ::: Company.teamcityConfDepend("company-services-common", "test,gatling")
I am certain that at least some of the dependencies were successfully installed. I base this on the fact that the SessionFactory code block compiles successfully. It is only the line that attempts to setup a map from the Consumer class to the Consumer SQLServer table.
val consumers = table[Consumer]("Consumer")
This line causes a compile time error to be thrown. The compile is not able to find the table object.
[info] Compiling 8 Scala sources to /Users/pbeacom/Company/integration/target/scala-2.10/classes...
[error] /Users/pbeacom/Company/integration/src/main/scala/com/company/code/SandBox.scala:25: not found: value table
[error] val consumers = table[Consumer]("Consumer")
The version of Scala in use is 2.10 and if the table line is commented the code compiles successfully. Use of the table object to accomplish data model mappings is nearly ubiquitous in the Squeryl examples I'm been researching online and no one else seems to have encountered a similar problem.
Shortly after posting this and reviewing it I finally noticed my problem. I was not being conscious enough of the heavy use of mixins in Scala. I failed to extend the Schema class. That's why table is unknown in the scope of the SandBox class. I was able to solve the problem with the following class definition:
class SandBox extends Schema {
def tester() = {
...
I can't use scalax because it is in a state between sbt 0.7.7 and sbt 0.11.2 and will not install on windows. (it is missing org.scala-tools.sbt#sbt_2.7.7;0.4.7-p10 even though I have downloaded that and changes scripts to match - newbie well out of his depth).
I can find no examples in the web without scalax.
All I want to do is write some lines of text to a file. However I don't want to have all lines in memory at once.
Can someone point me at an example?
Scala 2.9, Windows 7 - 64 bit.
The easiest thing to do would probably be using java.io.PrintWriter like so:
scala> val pw = new java.io.PrintWriter("/tmp/foo.txt")
pw: java.io.PrintWriter = java.io.PrintWriter#1e1ff563
scala> pw.println("Hello")
scala> pw.close()
You might want to look up PrintWriter here.
here is my test case , while i right click the file eclipse doest not show any run as junit test option. I try to manual create run configuration but does not take any sense.
scala version:2.8.1 scalatest:1.3 eclipse:3.6.2
package org.jilen.cache.segment
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers
#RunWith(classOf[JUnitRunner])
class RandomSegmentSpec extends FlatSpec with ShouldMatchers {
val option = SegmentOptions()
"A Simple Segment" should "contains (douglas,lea) after put into" in {
val segment = RandomSegment.newSegment(option)
segment.put("douglas", "lea")
segment("douglas") should be("lea")
}
it should "return null after (douglas,lea) is remove" in {
val segment = RandomSegment.newSegment(option)
segment.put("douglas", "lea")
segment -= ("douglas")
segment("douglas") should equal(null)
}
it should "contains nothing after clear" in {
val segment = RandomSegment.newSegment(option)
segment.put("jilen", "zhang")
segment.put(10, "ten")
segment += ("douglas" -> "lea")
segment += ("20" -> 20)
segment.clear()
segment.isEmpty should be(true)
}
}
I've encountered this seemingly randomly, and I think I've finally figured out why.
Unfortunately the plugin doesn't yet change package declarations when you move files, nor the class names when you rename files. (Given you can put multiple classes in one file, the latter will likely never be done.) If you are used to the renamings being done automagically in Eclipse, like I am, you're bound to get caught on this.
So... check carefully the following:
the package declaration in your Scala file matches the Eclipse package name
the name of the test class in the Scala file matches the name of the Scala file
I just ran into this, fixed both, and now my test runs!
This is a known problem with the Eclipse IDE for Scala. I'm currently working on the plugin for this. Watch this space.
I found Scalatest to be very bad at integrating with Eclipse (running the tests from eclipse showed that it ran them - but they would not pass or fail, but simply show up as passive blank boxes).
For some reason I could NOT get it to work after 3 hours of trying things!
Finally I tried specs2 - and it worked (Scala 2.9, Junit4 and Eclipse 3.6)!
They have a great doc here:
http://etorreborre.github.com/specs2/guide/org.specs2.guide.Runners.html#Runners+guide
Since I don't care which testing framework to use, I will try Specs2 purely from the convenience point of view.