sbt & liftweb mapper problem

34 views
Skip to first unread message

drwho

unread,
Jun 8, 2010, 5:06:11 AM6/8/10
to Lift
hi,

we are using the liftweb mapper stuff for our application and are
using scala specs for testing. so far we've been using maven to drive
the build and test cycle but i'd like to switch to sbt as that seems
to be a bit more nimble on its feet.

one problem that i'm running into with sbt is the following:

- in the specs for our models we have code like this:

val boot = new Boot

"XXX" should {

// do this initially
doFirst {
boot.dbSetup
boot.dbCleanUp
}

// do this after each example
doAfter {
boot.dbCleanUp

if (tempFile != None) {
tempFile.get.delete
tempFile = None
}
}

doLast {
boot.dbTearDown
}

with Boot.dbSetup containing this:

if (!DB.jndiJdbcConnAvailable_?) {
val v =
new StandardDBVendor(Props.get("db.driver") openOr
"org.apache.derby.jdbc.EmbeddedDriver",
Props.get("db.url") openOr
"jdbc:derby:data/db;create=true",
Props.get("db.user"),
Props.get("db.password"))
vendor = Full(v)

LiftRules.unloadHooks.append(v.closeAllConnections_!
_)

DB.defineConnectionManager(DefaultConnectionIdentifier, v)
}

Schemifier.schemify(true, Log.infoF _, ...)

and Boot.dbCleanUp containing a bunch of .bulkDelete_!!
(NotNullRef(XXX.id) calls to clean out the tables,
and Boot.dbTearDown containing:

def dbTearDown: Unit = {
vendor foreach (_.closeAllConnections_!)
}

- each spec that uses DB stuff has the doFirst/doAfter/doLast code in
it.

- running the specs via "mvn test" works just fine and running them
again via "mvn test" also works just fine.

- running the specs from sbt with "test" works fine the first time
round, but fails with

java.sql.SQLException: Failed to start database 'data/db', see the
next exception for details.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown
Source)
at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown
Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at net.liftweb.mapper.StandardDBVendor.createOne(DB.scala:1015)
at net.liftweb.mapper.ProtoDBVendor$class.newConnection(DB.scala:
1070)
at net.liftweb.mapper.StandardDBVendor.newConnection(DB.scala:1004)
at net.liftweb.mapper.DB$$anonfun$6$$anonfun$apply$3.apply(DB.scala:
134)
at net.liftweb.mapper.DB$$anonfun$6$$anonfun$apply$3.apply(DB.scala:
134)
at net.liftweb.common.EmptyBox.or(Box.scala:378)
at net.liftweb.mapper.DB$$anonfun$6.apply(DB.scala:134)
at net.liftweb.mapper.DB$$anonfun$6.apply(DB.scala:134)
at net.liftweb.common.Full.flatMap(Box.scala:336)
at net.liftweb.mapper.DB$.newConnection(DB.scala:134)
at net.liftweb.mapper.DB$.getConnection(DB.scala:230)
at net.liftweb.mapper.DB$.use(DB.scala:575)
at net.liftweb.mapper.Schemifier$.schemify(Schemifier.scala:68)
at net.liftweb.mapper.Schemifier$.schemify(Schemifier.scala:51)
at bootstrap.liftweb.Boot.dbSetup(Boot.scala:81)
...
Caused by: java.sql.SQLException: Failed to start database 'data/
db', see the next exception for details.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)
... 91 more
Caused by: java.sql.SQLException: Java exception: ':
java.nio.channels.OverlappingFileLockException'.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
... 88 more

the second time round.

any idea what we might be doing wrong?

David Pollak

unread,
Jun 8, 2010, 5:54:06 PM6/8/10
to lif...@googlegroups.com
I'd suggest running tests against an in-memory version of H2.  You'll get zero cruft on the hard drive and the tests run much faster.


--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics

drwho

unread,
Jun 9, 2010, 9:33:15 AM6/9/10
to Lift
ok, thx for the tip! really helped a lot!

cheers,
dirk
Reply all
Reply to author
Forward
0 new messages