I just read your original post and that error is exactly what I was referring to in my last post. The problem is, by default, the database shuts down when the jvm shuts down. So, if you want to dynamically restart jetty, you need a way to shutdown the db if the jvm is not shutown. You can do as I described in my last post, using sbt, but there are other options. I'm not sure if that will work with mvn.
H2 comes with a DbStarter [1] ServletContextListener that will start up and shutdown the db. It can also start up a tcp server, if you need that. However, it requires you to specify the db url, user, and pass as context-params. Which is a show stopper for me. There is only one line in DbStarter that one would really need and that is a sql statement that is sent to the db. This code is in the contextDestroyed method. So, if there is a way in Lift to call some code when the servlet context is destroyed, then one could put that sql statement there and manually shutdown the db. I realize you use Derby, but I'm guessing that it works similarly. So, Lifters, is there a way to call some code when the context is destroyed? Or, is there another way to accomplish this? [1] http://code.google.com/p/h2database/source/browse/trunk/h2/src/main/org/h2/server/web/DbStarter.java On Aug 1, 10:25 am, Tim Nelson <tnell...@gmail.com> wrote: > I was having the same problems using jetty's hot deploy with ~ prepare- > webapp in sbt so I switched to using JavaRebel. It works much better > and I haven't had any problems with reloading since. I don't think > there's any info on the sbt site about jrebel, but it's real easy to > get set up. Just install it and get a license (free for scala use) > from them at:http://www.zeroturnaround.com/scala-license/ > > Then change your sbt script to: > java -Xmx256M -noverify -javaagent:/path/to/javarebel-2.0.2/ > javarebel.jar -jar `dirname $0`/sbt-launcher-0.5.1.jar "$@" > > I did run into a problem using an embedded H2 database, which may or > may not occur with Derby, when using jetty-run/jetty-stop from the sbt > prompt. What happens is jetty-stop does not shutdown the jvm, so H2 > doesn't shut down. To get around this I use "sbt jetty" directly in > the terminal, that way when you stop it, the jvm shuts down and the db > with it. I then have a second terminal that I open an sbt prompt in > and use ~ prepare-webapp. > > For me, this setup has worked much better. > > Tim > > On Aug 1, 9:39 am, "Nolan Darilek" <no...@thewordnerd.info> wrote: > > > Wondering if anyone has gotten a chance to take a look at this? Life got > > busy, and since my Lift projects aren't commercial just yet, they went > > on the back burner. But I'm still seeing this. > > > Also, not sure how I missed this question, but I don't think SBT is > > undeploying the app before redeploying. Should it be? Maybe this is an > > SBT rather than a Lift issue? > > > Here is a partial transcript of an SBT session, not sure if these are > > the same errors. It involves me making a code change, at which point > > ~prepare-webapp picks it up and redeploys. I then get an error, try > > stopping and relaunching Jetty and get another. Also, after that point, > > I can't access the web app unless I completely restart SBT. Sorry for > > the ANSI escape sequences in this. > > > If this is an SBT issue then I'll gladly take it to that list. Thanks > > for looking into this! > > > ERROR - Failed to Boot > > java.lang.IllegalStateException: Cannot modify after boot. > > at net.liftweb.http.RulesSeq$class.safe_$qmark(LiftRules.scala:1056) > > at net.liftweb.http.RulesSeq$class.prepend(LiftRules.scala:1063) > > at net.liftweb.http.RulesSeq$$anon$5.prepend(LiftRules.scala:1043) > > at net.liftweb.http.LiftFilter.preBoot(LiftServlet.scala:564) > > at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:555) > > at net.liftweb.http.LiftFilter.init(LiftServlet.scala:530) > > at > > org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97) > > at > > org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) > > at > > org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:620) > > > at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) > > at > > org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1234) > > > at > > org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) > > at > > org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:460) > > at > > org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) > > at > > sbt.LazyJettyRun$$anonfun$sbt$LazyJettyRun$$reload$6.apply(WebApp.scala:198) > > > at > > sbt.LazyJettyRun$$anonfun$sbt$LazyJettyRun$$reload$6.apply(WebApp.scala:198) > > > at scala.List.foreach(List.scala:841) > > at sbt.LazyJettyRun$.sbt$LazyJettyRun$$reload(WebApp.scala:198) > > at sbt.LazyJettyRun$$anon$1.filesChanged(WebApp.scala:124) > > at org.mortbay.util.Scanner.reportBulkChanges(Scanner.java:486) > > at org.mortbay.util.Scanner.reportDifferences(Scanner.java:352) > > at org.mortbay.util.Scanner.scan(Scanner.java:280) > > at org.mortbay.util.Scanner$1.run(Scanner.java:232) > > at java.util.TimerThread.mainLoop(Timer.java:512) > > at java.util.TimerThread.run(Timer.java:462) > > [0m[ [0minfo [0m] [0mReload complete. [0m > > [0m[ [0minfo [0m] [0mCompilation successful. [0m > > [0m[ [0minfo [0m] [0m Post-analysis: 17 classes. [0m > > [0m[ [0minfo [0m] [34m== compile == [0m > > [0m[ [0minfo [0m] [34m [0m > > [0m[ [0minfo [0m] [34m== prepare-webapp == [0m > > [0m[ [0minfo [0m] [34m== prepare-webapp == [0m > > [0m[ [32msuccess [0m] [0mSuccessful. [0m > > [0m[ [0minfo [0m] [0m [0m > > [0m[ [0minfo [0m] [0mTotal time: 10 s [0m > > Waiting for source changes... (press any key to interrupt) > > [0m[ [0minfo [0m] [0mReloading web application... [0m > > [0m[ [0minfo [0m] [0mNO JSP Support for /, did not find > > org.apache.jasper.servlet.JspServlet [0m > > ERROR - Failed to Boot > > java.lang.IllegalStateException: Cannot modify after boot. > > at net.liftweb.http.RulesSeq$class.safe_$qmark(LiftRules.scala:1056) > > at net.liftweb.http.RulesSeq$class.prepend(LiftRules.scala:1063) > > at net.liftweb.http.RulesSeq$$anon$5.prepend(LiftRules.scala:1043) > > at net.liftweb.http.LiftFilter.preBoot(LiftServlet.scala:564) > > at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:555) > > at net.liftweb.http.LiftFilter.init(LiftServlet.scala:530) > > at > > org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97) > > at > > org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) > > at > > org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:620) > > > at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) > > at > > org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1234) > > > at > > org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) > > at > > org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:460) > > at > > org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) > > at > > sbt.LazyJettyRun$$anonfun$sbt$LazyJettyRun$$reload$6.apply(WebApp.scala:198) > > > at > > sbt.LazyJettyRun$$anonfun$sbt$LazyJettyRun$$reload$6.apply(WebApp.scala:198) > > > at scala.List.foreach(List.scala:841) > > at sbt.LazyJettyRun$.sbt$LazyJettyRun$$reload(WebApp.scala:198) > > at sbt.LazyJettyRun$$anon$1.filesChanged(WebApp.scala:124) > > at org.mortbay.util.Scanner.reportBulkChanges(Scanner.java:486) > > at org.mortbay.util.Scanner.reportDifferences(Scanner.java:352) > > at org.mortbay.util.Scanner.scan(Scanner.java:280) > > at org.mortbay.util.Scanner$1.run(Scanner.java:232) > > at java.util.TimerThread.mainLoop(Timer.java:512) > > at java.util.TimerThread.run(Timer.java:462) > > [0m[ [0minfo [0m] [0mReload complete. [0m > > > > jetty-stop > > [0m[ [0minfo [0m] [34m [0m > > [0m[ [0minfo [0m] [34m== jetty-stop == [0m > > [0m[ [0minfo [0m] [34m== jetty-stop == [0m > > [0m[ [32msuccess [0m] [0mSuccessful. [0m > > [0m[ [0minfo [0m] [0m [0m > > [0m[ [0minfo [0m] [0mTotal time: 0 s [0m > > > jetty-run > > [0m[ [0minfo [0m] [34m [0m > > [0m[ [0minfo [0m] [34m== compile == [0m > > [0m[ [0minfo [0m] [0m Source analysis: 0 new/modified, 0 indirectly > > invalidated, 0 removed. [0m > > [0m[ [0minfo [0m] [0mCompiling main sources... [0m > > [0m[ [0minfo [0m] [0mNothing to compile. [0m > > [0m[ [0minfo [0m] [0m Post-analysis: 17 classes. [0m > > [0m[ [0minfo [0m] [34m== compile == [0m > > [0m[ [0minfo [0m] [34m [0m > > [0m[ [0minfo [0m] [34m== prepare-webapp == [0m > > [0m[ [0minfo [0m] [34m== prepare-webapp == [0m > > [0m[ [0minfo [0m] [34m [0m > > [0m[ [0minfo [0m] [34m== jetty-run == [0m > > 2009-07-30 08:49:12.337::INFO: Logging to STDERR via > > org.mortbay.log.StdErrLog > > [0m[ [0minfo [0m] [0mjetty-6.1.14 [0m > > [0m[ [0minfo [0m] [0mNO JSP Support for /, did not find > > org.apache.jasper.servlet.JspServlet [0m > > java.sql.SQLException: Failed to start database 'lift_example', 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.newEmbedSQLException(Unknown > > Source) > > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown > > Source) > > at > > org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(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 bootstrap.liftweb.DBVendor$.createOne(Boot.scala:79) > > at bootstrap.liftweb.DBVendor$.newConnection(Boot.scala:91) > > at net.liftweb.mapper.DB$$anonfun$2.apply(DB.scala:89) > > at net.liftweb.mapper.DB$$anonfun$2.apply(DB.scala:89) > > at net.liftweb.util.Full.flatMap(Box.scala:332) > > at net.liftweb.mapper.DB$.newConnection(DB.scala:89) > > at net.liftweb.mapper.DB$.getConnection(DB.scala:136) > > at net.liftweb.mapper.DB$.use(DB.scala:315) > > at net.liftweb.mapper.Schemifier$.schemify(Schemifier.scala:53) > > at net.liftweb.mapper.Schemifier$.schemify(Schemifier.scala:36) > > at > > ... > > read more » --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---