DB problems on Jetty restart

204 views
Skip to first unread message

Nathan Parry

unread,
Dec 30, 2009, 8:15:40 PM12/30/09
to Lift
Searching turned up a few older threads similar to the problem I'm
seeing, but I couldn't find any solution.

Using just the skeleton project created by lift-archetype-basic, I'm
getting these exceptions out of jetty:

org.h2.jdbc.JdbcSQLException: Database may be already in use: Locked
by another process. Possible solutions: close all other connection(s);
use the server mode [90020-121]

ERROR - Failed to Boot
java.lang.NullPointerException: Looking for Connection Identifier
ConnectionIdentifier(lift) but failed to find either a JNDI data
source with the name lift or a lift connection manager with the
correct name

Once this happens, the app is non-functional. This occurs whenever
jetty restarts due to updated code. I can trigger the issue by:

1. Running mvn jetty:run in one console
2. Running mvn scala:cc in another console
3. Running touch src/main/scala/bootstrap/liftweb/Boot.scala in a 3rd
console

This causes a recompilation, which causes a jetty restart, which blows
up with the exceptions.

Has anybody else seen or fixed this issue? Should it be useful, I've
stashed the project at http://nparry.com/posted_files/jetty_lift_issues/lifttest.tgz
including a jetty.log of the output with the full stack traces.


Wandering into wild-speculation territory (AKA speak and remove all
doubt) ...

Based on the jdbc exception, I poked around in the DB code - looking
at ProtoDBVendor I couldn't see how connections in 'pool' would ever
be released. Thus I tried a quick hack in my project to force the
pool to be empty...

DB.defineConnectionManager(DefaultConnectionIdentifier,
new StandardDBVendor(
Props.get("db.driver") openOr
"org.h2.Driver",
Props.get("db.url") openOr
"jdbc:h2:lift_proto.db",
Props.get("db.user"),
Props.get("db.password")) {
override def maxPoolSize = 0
})

This obviously is not a good solution, but it does seem to clear up
the exceptions when jetty restarts - the theory being that during
shutdown the old connections are not closed, leading to errors during
restart since the new connection can't be created. Forcing an empty
pool means there is no old connection around to trigger the problem.

I guess the question out of all that would be - do we need (or is
there already) a shutdown hook to correspond to the boot hook? This
would allow for cleanup in this sort of situation (ie, close any
connections left in the pool).

--
Nathan

joseph hirn

unread,
Dec 31, 2009, 12:33:14 AM12/31/09
to Lift
Yes I had an open thread on this issue but it's not being seen as a
real issue.

http://groups.google.com/group/liftweb/browse_thread/thread/78454f767280b4b5/d0f462593ae77072?hl=en#d0f462593ae77072


On Dec 30, 7:15 pm, Nathan Parry <npa...@gmail.com> wrote:
> Searching turned up a few older threads similar to the problem I'm
> seeing, but I couldn't find any solution.
>
> Using just the skeleton project created by lift-archetype-basic, I'm
> getting these exceptions out of jetty:
>
> org.h2.jdbc.JdbcSQLException: Database may be already in use: Locked
> by another process. Possible solutions: close all other connection(s);
> use the server mode [90020-121]
>
> ERROR - Failed to Boot
> java.lang.NullPointerException: Looking for Connection Identifier
> ConnectionIdentifier(lift) but failed to find either a JNDI data
> source with the name lift or a lift connection manager with the
> correct name
>
> Once this happens, the app is non-functional.  This occurs whenever
> jetty restarts due to updated code.  I can trigger the issue by:
>
> 1. Running mvn jetty:run in one console
> 2. Running mvn scala:cc in another console
> 3. Running touch src/main/scala/bootstrap/liftweb/Boot.scala in a 3rd
> console
>
> This causes a recompilation, which causes a jetty restart, which blows
> up with the exceptions.
>
> Has anybody else seen or fixed this issue?  Should it be useful, I've

> stashed the project athttp://nparry.com/posted_files/jetty_lift_issues/lifttest.tgz

Nathan Parry

unread,
Dec 31, 2009, 11:12:33 AM12/31/09
to Lift
Thanks, that cleared up the problem. It even pointed out
LiftRules.unloadHooks which answered my second question.

On Dec 31, 12:33 am, joseph hirn <joseph.h...@gmail.com> wrote:
> Yes I had an open thread on this issue but it's not being seen as a
> real issue.
>

> http://groups.google.com/group/liftweb/browse_thread/thread/78454f767...

joseph hirn

unread,
Dec 31, 2009, 12:37:52 PM12/31/09
to Lift
Glad I could help.

David Pollak

unread,
Dec 31, 2009, 1:13:28 PM12/31/09
to lif...@googlegroups.com
On Wed, Dec 30, 2009 at 5:15 PM, Nathan Parry <npa...@gmail.com> wrote:
Searching turned up a few older threads similar to the problem I'm
seeing, but I couldn't find any solution.

Using just the skeleton project created by lift-archetype-basic, I'm
getting these exceptions out of jetty:

org.h2.jdbc.JdbcSQLException: Database may be already in use: Locked
by another process. Possible solutions: close all other connection(s);
use the server mode [90020-121]

ERROR - Failed to Boot
java.lang.NullPointerException: Looking for Connection Identifier
ConnectionIdentifier(lift) but failed to find either a JNDI data
source with the name lift or a lift connection manager with the
correct name

Once this happens, the app is non-functional.  This occurs whenever
jetty restarts due to updated code.  I can trigger the issue by:

1. Running mvn jetty:run in one console
2. Running mvn scala:cc in another console
3. Running touch src/main/scala/bootstrap/liftweb/Boot.scala in a 3rd
console


Thanks for the repro case.  I've opened a ticket on the issue: http://github.com/dpp/liftweb/issues/#issue/266
 

--

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
Surf the harmonics

David Pollak

unread,
Dec 31, 2009, 1:41:32 PM12/31/09
to Lift
The simplest way around this issue is:

new StandardDBVendor(Props.get("db.driver") openOr "org.h2.Driver",
Props.get("db.url") openOr
"jdbc:h2:lift_proto.db;AUTO_SERVER=TRUE",


Props.get("db.user"), Props.get("db.password"))

Note the ";AUTO_SERVER=TRUE" part of the DB URL. This makes the H2
restart issue go away. There's an additional issue of ActorPing which
is not restarting correctly. I've got a fix for that as well and I'll
have the code up on review board in a little while.

On Dec 31, 10:13 am, David Pollak <feeder.of.the.be...@gmail.com>
wrote:

> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com>


> > .
> > For more options, visit this group at
> >http://groups.google.com/group/liftweb?hl=en.
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net

> Beginning Scalahttp://www.apress.com/book/view/1430219890

Nathan Parry

unread,
Dec 31, 2009, 2:36:12 PM12/31/09
to Lift
Thanks for the quick turnaround!

On Dec 31, 1:41 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:

Reply all
Reply to author
Forward
0 new messages