JPA dependency issue after upgrading to Play framework 2.4 - jpa

Ebean ORM has been pulled out from main Play core and has been introduced as an dependency in Play 2.4. great move.
But this is breaking the existing code. After following the Play migration instructions for Ebean, I get several JPA annotations errors. Upon investigating, it seems that ebean is pulling JPA 1.0 persistence API.
[info] | +-org.avaje.ebeanorm:avaje-ebeanorm-agent:4.5.3
[info] | | +-javax.persistence:persistence-api:1.0
[info] | |
[info] | +-org.avaje.ebeanorm:avaje-ebeanorm:4.6.2
[info] | +-com.fasterxml.jackson.core:jackson-core:2.4.1 (evicted by: 2.5.3)
[info] | +-com.fasterxml.jackson.core:jackson-core:2.4.3 (evicted by: 2.5.3)
[info] | +-com.fasterxml.jackson.core:jackson-core:2.5.3
[info] | +-javax.persistence:persistence-api:1.0
[info] | +-org.slf4j:slf4j-api:1.7.12
[info] | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.12)
Where as in Play 2.3.9 this was not the case, it was pulling i jpa 2.0
[info] | +-org.avaje.ebeanorm:avaje-ebeanorm-agent:3.2.2
[info] | +-org.avaje.ebeanorm:avaje-ebeanorm:3.3.4
[info] | +-org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final
[info] |
[info] +-com.typesafe.play:play-java-jdbc_2.11:2.3.9 [S]
[info] | +-com.typesafe.play:play-java_2.11:2.3.9 [S]
[info] | | +-com.google.code.findbugs:jsr305:2.0.3
[info] | | +-com.google.guava:guava:16.0.1
Any pointers on excluding JPA 1.0 and depend on hibernate-jpa-2.0-api?

You can exclude persistence-api from ebean dependencies.
Something like
("org.avaje.ebeanorm" % "avaje-ebeanorm" % "4.6.2").exclude("javax.persistence","persistence-api")

Related

Can't poke MixedVec

I declared a MixedVec in my Module interface:
class WbInterconOneMaster(val awbm: WbMaster,
val awbs: Seq[WbSlave]) extends Module {
val io = IO(new Bundle{
val wbm = Flipped(new WbMaster(awbm.dwidth, awbm.awidth))
val wbs = MixedVec(awbs.map{i => Flipped(new WbSlave(i.dwidth, i.awidth, i.iname))})
})
That compile correctly and Verilog is correctly generated. But I can't poke values on signal like it :
for(wbs <- dut.io.wbs) {
poke(wbs.ack_o, 0)
}
Got this error at execution time (verilator backend):
[info] java.util.NoSuchElementException: head of empty list
[info] at scala.collection.immutable.Nil$.head(List.scala:420)
[info] at scala.collection.immutable.Nil$.head(List.scala:417)
[info] at scala.collection.mutable.Stack.top(Stack.scala:132)
[info] at chisel3.internal.naming.NamingStack.pop_return_context(Namer.scala:133)
[info] at chisel3.util.MixedVec.length(MixedVec.scala:81)
[info] at scala.collection.IndexedSeqLike$class.iterator(IndexedSeqLike.scala:90)
[info] at chisel3.util.MixedVec.iterator(MixedVec.scala:81)
[info] at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
[info] at chisel3.util.MixedVec.foreach(MixedVec.scala:81)
[info] at wbplumbing.TestWbInterconDualSlave.<init>(testwbplumbing.scala:61)
Note that the question was already asked on github project with the chisel version 3.1.6 but it's marked as closed. I'm using 3.1.8 version and it seems to be broken yet.
[edit]
I upgraded my project with chisel 3.2.0 and iotester 1.3.0 :
libraryDependencies += "edu.berkeley.cs" %% "chisel3" % "3.2.0"
libraryDependencies += "edu.berkeley.cs" %% "chisel-iotesters" % "1.3.0"
And I still have an error when I uncomment the line :
for(wbs <- dut.io.wbs) {
poke(wbs.ack_o, 0)
}
(if I left these lines commented, that works)
But the stack trace is different :
[info] - should read and write wishbone value on two slaves *** FAILED ***
[info] chisel3.internal.ChiselException: Error: Not in a RawModule. Likely cause: Missed Module() wrap, bare chisel API call, or attempting to construct hardware inside a BlackBox.
[info] at chisel3.internal.throwException$.apply(Error.scala:42)
[info] at chisel3.internal.Builder$.referenceUserModule(Builder.scala:287)
[info] at chisel3.Data.connect(Data.scala:384)
[info] at chisel3.Data.$colon$eq(Data.scala:475)
[info] at wbplumbing.TestWbInterconDualSlave$$anonfun$15.apply(testwbplumbing.scala:63)
[info] at wbplumbing.TestWbInterconDualSlave$$anonfun$15.apply(testwbplumbing.scala:62)
[info] at scala.collection.Iterator$class.foreach(Iterator.scala:742)
[info] at scala.collection.AbstractIterator.foreach(Iterator.scala:1194)
[info] at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
[info] at chisel3.util.MixedVec.foreach(MixedVec.scala:88)
[info] ...
I am not sure what is going on but I was able to reproduce your error in the current chisel3 release, but the same code seems to run properly under the chisel 3.2 release candidate snapshot. Is it possible for you to try your code there.
Hopefully it will work better. The problem does not appear to be directly in MixedVec but must be in underlying code.
I must say that you need to be especially careful when using MixedVec, it is not indexable by a hardware index, so all references to its elements must be referenced from constant Scala ints at elaboration time.

Reading sbt dependency tree

I'm upgrading some libraries within a Play! project. During the process I'm trying to resolve errors like this:
java.lang.ClassNotFoundException: akka.event.slf4j.Slf4jLoggingFilter
Which I am assuming comes from incompatible transitive dependencies?
But I'm struggling to effectively use sbt-dependency-graph to help me track down the problem.
[info] +-ch.qos.logback:logback-classic:1.1.3
[info] | +-ch.qos.logback:logback-core:1.1.3
[info] | +-org.slf4j:slf4j-api:1.7.21
[info] | +-org.slf4j:slf4j-api:1.7.7 (evicted by: 1.7.21)
Why are there 2 versions of slf4j-api listed ๐Ÿ‘†๐Ÿป
I'm assuming, the newer version (1.7.21) is taking precedence over 1.7.7 But then, why in some instances, do I see as many as 5 different versions of the same dependency (all but 1 evicted):
| | | | +-org.slf4j:slf4j-ext:1.7.12
| | | | +-ch.qos.cal10n:cal10n-api:0.8.1
| | | | +-org.slf4j:slf4j-api:1.6.2 (evicted by: 1.7.21)
| | | | +-org.slf4j:slf4j-api:1.6.4 (evicted by: 1.7.21)
| | | | +-org.slf4j:slf4j-api:1.7.12 (evicted by: 1.7.21)
| | | | +-org.slf4j:slf4j-api:1.7.2 (evicted by: 1.7.21)
| | | | +-org.slf4j:slf4j-api:1.7.21
Once the conflict is found -- do I need to upgrade all dependencies to be using the same version?
Is there another approach I should be taking?
Discovered that "the SLF4J API is backward compatible for all versions". Despite java.lang.ClassNotFoundException being called from an slf4j. So digging a little deeper:
Akka Kindly provides binary compatibility rules which show that backwards compatibility is violated between major versions.
Looking at the dependency tree we were seeing different major versions of akka dependencies (2.3.x and 2.4.x): com.typesafe.akka:akka-actor_2.11:2.3.13 (evicted by: 2.4.11) and com.typesafe.akka:akka-slf4j_2.11:2.3.13
Standardizing all akka dependencies around a major version fixed it:
Our original dependencies only provided the "com.typesafe.akka" %% "akka-actor" % "2.4.11" and play was providing "akka-slf4j" % "2.3.13" transitively which was breaking binary compatibility.
+-com.typesafe.akka:akka-slf4j_2.11:2.3.13 [S]
| +-com.typesafe.akka:akka-actor_2.11:2.3.13 (evicted by: 2.4.11)
Providing both akka-slf4j and akka-actor with the same major version solved this issue.

Serenity BDD Timeout Error

I am running Serenity Jbehave Scripts with example table with 19 rows of values but the script is executing only 7 rows which are present in the example table and giving exception as below when executing the 8th row
The Stack trace from console is :
Example: {workspaceName=admin, menuName=Admin, menuOption=Parameter Maintenance, portletTitle=Parameter Maintenance}
Given login to CMS as colinw and colinw
Then I Navigate to admin Workspace
When I Select Parameter Maintenance Option from Admin Menu
Then I Verify Portlet Parameter Maintenance is Displayed
Then I Close the Portlet Parameter Maintenance
Then logout from CMS
Example: {workspaceName=admin, menuName=Admin, menuOption=Product Maintenance, portletTitle=Product Type}
Story stories/smoke/ShakeDownScript.story duration of 301 seconds has exceeded timeout of 300 seconds
(AfterStories)
[pool-2-thread-1] INFO net.thucydides.core.webdriver.SystemPropertiesConfiguration - project.build.directory : null
[pool-2-thread-1] INFO net.thucydides.core.webdriver.SystemPropertiesConfiguration - project.reporting.OutputDirectory : null
[pool-2-thread-1] INFO net.thucydides.core.webdriver.SystemPropertiesConfiguration - OutputDirectory : C:\WCG Automation\CMS\CMS_Automation\target\site\serenity
Given login to CMS as colinw and colinw
Then I Navigate to admin Workspace
Generating reports view to 'C:\WCG Automation\CMS\CMS_Automation\target\jbehave' using formats '[stats, console, html, xml, serenityreporter, junitscenarioreporter]' and view properties '{decorateNonHtml=true}'
Reports view generated with 0 stories (of which 0 pending) containing 0 scenarios (of which 0 pending)
Tests run: 47, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 313.246 sec <<< FAILURE! - in wcg.cms.CMSTestSuite
wcg.cms.CMSTestSuite Time elapsed: 3.651 sec <<< ERROR!
java.lang.RuntimeException:org.jbehave.core.embedder.Embedder$RunningStoriesFailed: Failures in running stories:
stories/smoke/ShakeDownScript.story: java.util.concurrent.CancellationException
at org.jbehave.core.embedder.Embedder$ThrowingRunningStoriesFailed.handleFailures(Embedder.java:553)
at org.jbehave.core.embedder.Embedder.handleFailures(Embedder.java:238)
at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:216)
at net.serenitybdd.jbehave.embedders.ExtendedEmbedder.runStoriesAsPaths(ExtendedEmbedder.java:60)
at net.serenitybdd.jbehave.runners.SerenityReportingRunner.run(SerenityReportingRunner.java:175)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
Results :
Tests in error:
JUnit4Provider.invoke:128->executeTestSet:153->executeWithRerun:173->execute:283 ยป Runtime
Tests run: 47, Failures: 0, Errors: 1, Skipped: 0
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! The file encoding for reports output files should be provided by the POM property ${project.reporting.outputEncoding}.
[INFO]
[INFO] --- serenity-maven-plugin:1.1.36:aggregate (serenity-reports) # CMS_Automation ---
[INFO] LOADING LOCAL PROPERTIES FROM C:\WCG Automation\CMS\CMS_Automation\serenity.properties
[INFO] LOADING LOCAL PROPERTIES FROM C:\WCG Automation\CMS\CMS_Automation\serenity.properties
[INFO] LOADING LOCAL PROPERTIES FROM C:\WCG Automation\CMS\CMS_Automation\serenity.properties
[INFO] webdriver.base.url=http://nssrvdfsdev01/calms2cms/
[INFO] serenity.project.name=Automation Testing
[INFO] webdriver.timeouts.implicitlywait=60000
[INFO] project.build.directory : C:\WCG Automation\CMS\CMS_Automation
[INFO] project.reporting.OutputDirectory : null
[INFO] OutputDirectory : C:\WCG Automation\CMS\CMS_Automation\target\site\serenity
[INFO] current_project.base.dir: C:\WCG Automation\CMS\CMS_Automation
Generating HTML Story Reports from C:\WCG Automation\CMS\CMS_Automation\target\site\serenity
Generating HTML Story Reports to C:\WCG Automation\CMS\CMS_Automation\target\site\serenity
[INFO] project.build.directory : C:\WCG Automation\CMS\CMS_Automation
[INFO] project.reporting.OutputDirectory : null
[INFO] OutputDirectory : C:\WCG Automation\CMS\CMS_Automation\target\site\serenity
Merging requirements = [Requirement{name='Smoke', type='feature' parent = 'null', cardNumber='null'}]
Merging requirements = []
Merged requirements set = [Requirement{name='Smoke', type='feature' parent = 'null', cardNumber='null'}]
[INFO] REPORTS GENERATED IN C:\WCG Automation\CMS\CMS_Automation\target\site\serenity
[INFO] REPORT HOME PAGE: C:\WCG Automation\CMS\CMS_Automation\target\site\serenity\index.html
[INFO] Generating release reports for: []
GENERATE CUSTOM REPORTS
[INFO]
[INFO] --- maven-failsafe-plugin:2.18.1:verify (default) # CMS_Automation ---
[INFO] Failsafe report directory: C:\WCG Automation\CMS\CMS_Automation\target\failsafe-reports
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! The file encoding for reports output files should be provided by the POM property ${project.reporting.outputEncoding}.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping Sample Serenity project using JBehave and WebDriver
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:25 min
[INFO] Finished at: 2016-08-22T17:26:18+05:30
[INFO] Final Memory: 37M/416M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:verify (default) on project CMS_Automation: There are test failures.
[ERROR]
[ERROR] Please refer to C:\WCG Automation\CMS\CMS_Automation\target\failsafe-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
it appears that story execution is exceeding the timeout of 300 seconds . is there any way so that we can reset the 300 seconds to 600 seconds in the framework
The solution is quite simple.
I found a related question and answer here.
You can either run the tests with an extra argument like:
mvn clean verify -DstoryTimeoutInSecs=600
Or put a property in the serenity.properties file (which should be in the root of your project if you have it) like this:
story.timeout.in.secs=600

How can I fix evicted libraries and ambiguous reference error in Scala (Akka 2.4.0)?

I have code that uses the new Akka 2.4.0. Apparently I've got some libs that are compiled with earlier versions, so I get the warnings/errors shown.
Most problematic, I get an ambiguous reference problem shown below.
OK, so the compiler is warning me (I think) that it's bumped older Akka versions in favor of 2.4.0, then it's confused about akka.pattern.ask.
What should I do about it?
My output is below:
> test:compile
[info] Compiling 5 Scala sources to /Users/wmy965/git/hello/common/target/scala-2.11/test-classes...
[error] /Users/wmy965/git/hello/common/src/test/scala/common.test.service/FacilitiesTests.scala:16: ambiguous reference to overloaded definition,
[error] both method ask in trait AskSupport of type (actorSelection: akka.actor.ActorSelection, message: Any, sender: akka.actor.ActorRef)(implicit timeout: akka.util.Timeout)scala.concurrent.Future[Any]
[error] and method ask in trait AskSupport of type (actorSelection: akka.actor.ActorSelection, message: Any)(implicit timeout: akka.util.Timeout)scala.concurrent.Future[Any]
[error] match expected type ?
[error] import akka.pattern.ask._
[error] ^
[error] /Users/wmy965/git/hello/common/src/test/scala/common.test.service/FacilitiesTests.scala:43: value ? is not a member of akka.actor.ActorRef
[error] Error occurred in an application involving default arguments.
[error] val result = Misc.await(harness.facilities.mongoControl ? MongoAction({ mongo =>
[error] ^
[error] two errors found
[error] (common/test:compileIncremental) Compilation failed
[error] Total time: 1 s, completed Oct 23, 2015 5:57:17 PM
> evicted
[info] Updating {file:/Users/wmy965/git/hello/}hello...
[info] Updating {file:/Users/wmy965/git/hello/}common...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Resolving org.scala-lang.modules#scala-xml_2.11;1.0.4 ...
[warn] There may be incompatibilities among your library dependencies.
[warn] Here are some of the libraries that were evicted:
[warn] * com.typesafe.akka:akka-actor_2.11:(2.3.12, 2.3.7) -> 2.4.0 (caller: com.cof:common_2.11:reactive2_a6d8f9, com.typesafe.akka:akka-stream-experimental_2.11:1.0, co.blocke:laterabbit_2.11:0.3, com.typesafe.akka:akka-slf4j_2.11:2.4.0, com.thenewmotion.akka:akka-rabbitmq_2.11:1.2.4)
[info] Here are other libraries that were evicted:
[info] * org.slf4j:slf4j-api:(1.7.7, 1.6.0) -> 1.7.12 (caller: com.bionicspirit:shade_2.11:1.7.Z, org.mongodb:casbah-core_2.11:2.8.2, org.mongodb:casbah-gridfs_2.11:2.8.2, org.slf4j:slf4j-simple:1.7.7, com.typesafe.akka:akka-slf4j_2.11:2.4.0, org.mongodb:casbah-commons_2.11:2.8.2, org.mongodb:casbah-query_2.11:2.8.2)
[info] * org.mongodb:casbah_2.11:2.8.0 -> 2.8.2 (caller: com.cof:common_2.11:reactive2_a6d8f9, co.blocke:scalajack_mongo_2.11:4.4.1)
[info] * org.scala-lang:scala-reflect:2.11.0 -> 2.11.7 (caller: co.blocke:scalajack_2.11:4.4.1, org.monifu:monifu-core_2.11:0.7.0)
[info] * org.joda:joda-convert:1.2 -> 1.7 (caller: com.github.nscala-time:nscala-time_2.11:1.0.0, co.blocke:scalajack_2.11:4.4.1)
[info] * org.scala-lang:scala-library:(2.11.0, 2.11.5, 2.11.4) -> 2.11.7 (caller: com.bionicspirit:shade_2.11:1.7.Z, com.github.nscala-time:nscala-time_2.11:1.0.0, com.typesafe.akka:akka-http-experimental_2.11:1.0, com.typesafe.akka:akka-stream-experimental_2.11:1.0, co.blocke:laterabbit_2.11:0.3, org.mongodb:casbah-gridfs_2.11:2.8.2, co.blocke:scalajack_2.11:4.4.1, com.typesafe.akka:akka-slf4j_2.11:2.4.0, org.monifu:monifu-core_2.11:0.7.0, org.mongodb:casbah-core_2.11:2.8.2, com.cof:common_2.11:reactive2_a6d8f9, com.typesafe.akka:akka-http-core-experimental_2.11:1.0, com.typesafe.akka:akka-actor_2.11:2.4.0, org.scala-lang:scala-reflect:2.11.7 (), org.mongodb:casbah_2.11:2.8.2, com.typesafe.akka:akka-parsing-experimental_2.11:1.0, org.mongodb:casbah-commons_2.11:2.8.2, org.mongodb:casbah-query_2.11:2.8.2, co.blocke:scalajack_mongo_2.11:4.4.1, com.thenewmotion.akka:akka-rabbitmq_2.11:1.2.4)
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[success] Total time: 1 s, completed Oct 23, 2015 5:57:30 PM
To avoid ambiguity, you can either add sender() or ActorRef.noSender - depends on the context. Or add a timeout mongoControl.ask(MongoAction({...}))(1.second)

Execute multiple Scalatests in sbt

I have multiple IntelliJ (Scala) modules that have build.sbt file and scalatest code.
I also created ScalaTest configurations for each of them.
I can run the test one by one from the execution of sbt test.
Is it possible to execute all the tests at once? I can think of making a Python/Bash script, but I wonder if there is a simple way to do it.
for d in dirs:
execute("sbt test")
ADDED
From Alexey Romanov's answer, I created a build.sbt in the root directory with the following content
lazy val root = (project in file(".")).aggregate(context, contextProcessor)
lazy val context = project
lazy val contextProcessor = project
Then, I executed set test to make all the tests run.
[info] ContextTest:
[info] - Create context
[info] - Create context 2
[info] Run completed in 195 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[info] Compiling 1 Scala source to /Users/smcho/Desktop/code/ContextSharingSimulation/contextProcessor/target/scala-2.11/test-classes...
[info] DatabaseTest:
[info] - Create test
[info] - Create test2
[info] Run completed in 147 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 5 s, completed Aug 12, 2015 3:03:41 PM
Reference - http://www.scala-sbt.org/0.13.5/docs/Getting-Started/Multi-Project.html
; <module1>/test; <module2>/test; <module3>/test
Or create an aggregate project:
// in build.sbt
lazy val root = (project in file(".")).
aggregate(<module1>, ...)
Now you can just run sbt test. Actually, it should already be there by default:
If a project is not defined for the root directory in the build, sbt creates a default one that aggregates all other projects in the build.