Trying to get rid of H2

30 views
Skip to first unread message

Emmanuel Eytan

unread,
Jun 1, 2016, 6:55:35 PM6/1/16
to Lift
I've been running a site on 2.6-M2 for a while now. (Yes, I know, it's old. I should upgrade.)

The only database I'm using is Mongo. All the data I use (as far as I know) is in Mongo. But I can't get rid of the H2 dependency. There's this block of code in Boot.scala:

    if (!DB.jndiJdbcConnAvailable_?) {
      val vendor =
        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"))

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

      DB.defineConnectionManager(DefaultConnectionIdentifier, vendor)
    }

No matter what I do, I can't get rid of it. If I try, Lift throws a javax.naming.NoInitialContextException.

I tried things like

new javax.naming.InitialContext().addToEnvironment("lift", DefaultMongoIdentifier.jndiName)

And others. The thing is, I'm obviously guessing here. What can I replace that block with that will allow Lift to go on working with only Mongo?

Tim Nelson

unread,
Jun 2, 2016, 5:13:47 AM6/2/16
to Lift
Hi,

You should be able to just delete that whole block. lift-mongo doesn't use or need any of that.

I'm not sure what would throw that exception. Do you have other code that references the DB object?

Btw, you should be able to remove the dependency on lift-db, which is most likely being pulled in via lift-mapper.

Tim

Emmanuel Eytan

unread,
Jun 2, 2016, 5:12:16 PM6/2/16
to Lift
Do you mean I should remove this line from build.sbt?

    "net.liftweb"       %% "lift-mapper"        % liftVersion        % "compile"

I'll try removing it and see if:
  1. Stuff still works without it and
  2. Lift stops complaining without H2 without it.
Thanks!

Emmanuel Eytan

unread,
Jun 2, 2016, 5:34:02 PM6/2/16
to Lift
Your suggestion helped me find the offending line in my Boot.scala:

    // Make a transaction span the whole HTTP request
   S.addAround(DB.buildLoanWrapper)

I'm still not sure what it does, but by removing the line in build.sbt, the import for Mapper and that line, I am now without H2. Yay!

Thanks.

Tim Nelson

unread,
Jun 3, 2016, 5:45:34 AM6/3/16
to Lift
That line is for Mapper. It wraps a request around a transaction, I believe. Anyway, you don't need it for lift-mongo.

Tim
Reply all
Reply to author
Forward
0 new messages