Giter Club home page Giter Club logo

framework's Introduction

The Lift Web Framework

Build Status

Lift is the most powerful, most secure web framework available today. There are Seven Things that distinguish Lift from other web frameworks.

Lift applications are:

  • Secure -- Lift apps are resistant to common vulnerabilities including many of the OWASP Top 10
  • Developer centric -- Lift apps are fast to build, concise and easy to maintain
  • Scalable -- Lift apps are high performance and scale in the real world to handle insane traffic levels
  • Interactive like a desktop app -- Lift's Comet support is unparalled and Lift's ajax support is super-easy and very secure

Because Lift applications are written in Scala, an elegant JVM language, you can still use your favorite Java libraries and deploy to your favorite Servlet Container and app server. Use the code you've already written and deploy to the container you've already configured!

Getting Started

Compatibility note: As of Lift 3.0, you'll need to be running Java 8 to use Lift. For those using Java 6 or Java 7, you'll need to use Lift 2.6 until you can upgrade your Java installation.

You can create a new Lift project using your favorite build system by adding Lift as a dependency. Below we walk through setting up Lift in sbt and Maven.

With sbt (new project)

If you're using a recent version of sbt (e.g. 0.13.16), you can create a new Lift application using our Giter8. To create a new, basic Lift application that has some example code, simply execute:

sbt new lift/basic-app.g8

Or, if you're more on the advanced side of the room, you can also create a new, entirely blank application:

sbt new lift/blank-app.g8

Follow the prompts to create your Lift application.

Running the Server

In order to run the server, navigate to the application folder and run the sbt command. In the SBT prompt, run:

~jetty:start

By default, the server should run on http://localhost:8080.

The above command will do what you probably want; the application will recompile and restart whenever you change HTML, resources or Scala code.

If your efforts are primarily dedicated to the frontend, you may find that it's not efficient to recompile and restart the application every time you change CSS or HTML.

In this case, a good alternative command is

jetty:quickstart

The difference between start and quickstart is that start serves assets from your target directory where the exploded WAR is, and quickstart serves from the src directory where you're editing the files.

Note that there is not a leading tilde ~ on the quickstart command. This is so that compile is not triggered when resources change. Your changed resources will be served directly. Note that in this mode Scala changes must be manually compiled.

With sbt (Existing project)

If you're using Lift in an existing sbt project you'll need to:

  1. Add the xsbt-web-plugin if you don't already have it or some other way to start a servlet app.
  2. Add the lift dependencies.

To add the xsbt-web-plugin download the most recent version of our web-plugin.sbt file to your project/ folder.

Then, enable the plugin for the container you want to use and in your build.sbt file. Below, we activate the JettyPlugin:

enablePlugins(JettyPlugin)

More information on using the plugin can be found on the xsbt-web-plugin project.

After you've done this, you'll want to add Lift to your libraryDependencies in addition to Logback if you don't already have another SLF4J logging library in place. For example:

libraryDependencies ++= {
  val liftVersion = "3.3.0"
  Seq(
    "net.liftweb"       %% "lift-webkit" % liftVersion % "compile",
    "ch.qos.logback" % "logback-classic" % "1.2.3"
  )
}

Running the Server

The same run process as above applies to this project configuration.

With Maven

Add Lift to your pom.xml like so:

<dependency>
  <groupId>net.liftweb</groupId>
  <artifactId>lift-webkit_${scala.version}</artifactId>
  <version>3.3.0</version>
</dependency>

Where ${scala.version} is 2.11 or 2.12. Individual patch releases of the Scala compiler (e.g. 2.12.2) are binary compatible with everything in their release series, so you only need the first two version parts.

You can learn more about Maven integration on the wiki.

Learning Lift

There are lots of resources out there for learning Lift. Some of our favorites include:

If you've found one that you particularly enjoy, please open a PR to update this README!

Issues & Pull Requests

Per our contributing guidelines, Issues on the Lift GitHub project are intended to describe actionable, already-discussed items. Committers on the project may open issues for themselves at any time, but non-committers should visit the Lift mailing list and start a discussion for any issue that they wish to open.

We will accept issues and pull requests into the Lift codebase if the pull requests meet the following criteria:

Project Organization

The Lift Framework is divided into several components that are published independently. This organization enables you to use just the elements of Lift necessary for your project and no more.

This Repository

This repository, framework, contains the following components:

  • core: Core elements used by Lift projects. If you wish to reuse some of Lift's helpers and constructs, such as Box, this component may be all you need. However, a web application will most likely require one or more of Lift's other components.
  • web: This component includes all of Lift's core HTTP and web handling. Including lift-webkit in your build process should be sufficient for basic applications and will include lift-core as a transitive dependency.
  • persistence: This component includes Mapper and Record, Lift's two ORMs. While you needn't use either and can use the ORM of your choice, Mapper and Record integrate nicely with Lift's idioms. Mapper is an ORM for relational databases, while Record is a broader ORM with support for both SQL databases and NoSQL datastores.

Other Repostories

There are a variety of other repositories available on the Lift GitHub page. While many are concerned with building Lift or are build program archetypes, there are two you will probably encounter fairly frequently as a Lift user:

modules

The modules organization contains some of the many add-on modules that are part of the Lift project. If you don't find a module you need here, consider looking for it on the Lift modules directory or creating a module and sharing it with the community.

examples

The examples repository contains the source code for several example Lift applications, including demo.liftweb.com.

Building Lift

If you simply want to use Lift in your project, add Lift as a dependency to your build system or download the JAR files directly.

If you wish to build Lift from source, check out this repository and use the included liftsh script to build some or all of the components you want.

git clone https://github.com/lift/framework.git
cd framework
./liftsh +update +publish

There is additional documentation on the wiki.

Additional Resources

Homepage

The main Lift website is http://www.liftweb.net. The site contains information on the latest Lift releases, a getting started guide, links to several Lift online books, and additional information.

Mailing List

The Lift Google Group is the official place for support and is an active, friendly community to boot! It can be found at http://groups.google.com/forum/#!forum/liftweb.

Wiki

The Lift wiki is hosted on Assembla and can be found at http://www.assembla.com/spaces/liftweb/wiki/. Anyone is welcome to contribute to the wiki; you must create an account and watch the Lift project in order to create or edit wiki pages.

ScalaDocs

The ScalaDocs for each release of Lift, in additional to the actual JARs, are available on the Liftweb.net site. You can access the source code–based documentation for releases via the site's homepage or by navigating directly to the URL for the specific release. For instance, the Lift 3.2 release can be accessed at http://liftweb.net/api/32/api/.

License

Lift is open source software released under the Apache 2.0 license.

Continuous Integration

SNAPSHOTs are built by Travis CI

framework's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

framework's Issues

Disabling auto-reload on webapp restart

Prior state:

  • local web application server is running
  • browser has the application open on some page other than the start page

Trigger:

  • local server restarts, for example due to changed .class files

Current Result:
The next jQuery request from the open browser window results in the browser being returned to the start page. This can be problematic during development, because the prior state then often has to be manually reinstated again before work can continue.

Desired Result:
It would be great to be able to continue work in the browser without be sent back to the start page again.

scala.MatchError: Index(Array(IndexField(NULL), IndexField(NULL)))

For the last couple of days I get the MatchErro on boot of ESME (see below for full stack trace).

I guess this is related to the following commit, although I verified that dchenbecker's fix on 20 July is updated on my system, and the error persists:

http://groups.google.com/group/liftweb/browse_thread/thread/722c75462e400a4c

We are using Lift 1.1-SNAPSHOT. This is ESME constructs the index:

override def dbIndexes = Index(user, message) :: super.dbIndexes

Full stack trace follows:

scala.MatchError: Index(Array(IndexField(NULL), IndexField(NULL)))
at net.liftweb.mapper.Schemifier$$anonfun$net$liftweb$mapper$Schemifier$$ensureIndexes$2.apply(Schemifier.scala:266)
at net.liftweb.mapper.Schemifier$$anonfun$net$liftweb$mapper$Schemifier$$ensureIndexes$2.apply(Schemifier.scala:261)
at scala.List.foreach(List.scala:841)
at net.liftweb.mapper.Schemifier$.net$liftweb$mapper$Schemifier$$ensureIndexes(Schemifier.scala:260)
at net.liftweb.mapper.Schemifier$$anonfun$schemify$1$$anonfun$3.apply(Schemifier.scala:62)
at net.liftweb.mapper.Schemifier$$anonfun$schemify$1$$anonfun$3.apply(Schemifier.scala:62)
at scala.List.foldLeft(List.scala:1066)
at net.liftweb.mapper.Schemifier$$anonfun$schemify$1.apply(Schemifier.scala:62)
at net.liftweb.mapper.Schemifier$$anonfun$schemify$1.apply(Schemifier.scala:54)
at net.liftweb.mapper.DB$.use(DB.scala:317)
at net.liftweb.mapper.Schemifier$.schemify(Schemifier.scala:53)
at net.liftweb.mapper.Schemifier$.schemify(Schemifier.scala:36)
at bootstrap.liftweb.Boot.boot(Boot.scala:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHelpers.scala:408)
at net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHelpers.scala:406)
at net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.scala:1096)
at net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.scala:1096)
at net.liftweb.util.Full.map(Box.scala:330)
at net.liftweb.http.DefaultBootstrap$.boot(LiftRules.scala:1096)
at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:556)
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:653)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1239)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:466)
at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:124)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:222)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

Remove dependency on Maven

it seems doing even Hello World in Lift means getting acquainted with maven. There is no stand-alone ZIP of Lift for easy download (especially on Linux).

Maven is a fairly divisive platform, with lots of supporters and naysayers. I don't think it's in Lift's interest to force it upon users (I personally prefer running with just plain embedded Jetty in my web app and no Maven).

Gregg Bolinger mentions in one of his blogs that the Maven dependency is the reason he never looked into Lift seriously:

http://www.greggbolinger.com/blog/2009/07/29/1248925200000.html

Re: Grails: The Search Really Is Over (For Now)
Comment from Gregg Bolinger on August 5, 2009 3:02:02 AM CDT #
I've looked at Scala. It is supported in Grails now, as is Clojure and something else I can't remember. Anyway, looking at list my first big issue was every tutorial I saw was using Maven. I know some folks like it, I personally don't. Other than that, I have no real opinion of Lift. I haven't looked at it enough.

Please provide a regular ZIP or TAR.GZ of the stable Lift version, together with all dependencies.
Thanks

S.params throws exception for a non-existent parameter

From the list:

Hi,

I have been having trouble reading a list of HTTP parameters with the
same name that may or may not exist. If I call S.params("nn") and "nn"
doesn't exist, it throws a NoSuchElementException: "key not found". I
was expecting an empty List.

The code for S.params is

def params(n: String): List[String] = request.map(_.params(n)).openOr
(Nil)

Shouldn't it be something like:

def params(n: String): List[String] = request.map(_.params.getOrElse
(n,Nil)).openOr(Nil)

lift 1.0 uninstaller has HOSED mvn for all mvn on box even new versions on OS X javarebel

This really blows. First I got a javarebel expiration. Then I ran the uninstaller for lift. Now I can't run mvn - maven - from the command line. I get this:

./mvn
Error opening zip file: /Applications/liftweb-1.0/java-rebel/javarebel.jar
Error occurred during initialization of VM
agent library failed to init: instrument
Abort trap

How can I fix this!!!!! I need to use mvn. I have work to do!!!!

Autocomplete never submit value

Hello,

I'm playing with the Autocomplete widget in Lift 1.1 current SNAPTHOT version (generated on Sat Jun 20 06:47:53 PDT 2009) and I get the submitted value back in the Scala code, everything else works fine (autocomplete elements are shonw, etc). I'm quite new to lift, so perhaps I miss somthing obious.

I think that the problem is in the generated Javascript, when the selected value should be copied in the hidden field (line 131 of lift-widgets-1.1-SNAPSHOT-sources.jar!/net/liftweb/widgets/autocomplete/AutoComplete.scala, in "onLoad" value definition):
8<--------------
jQuery("#"""+id+"""").autocomplete(data, """+autocompleteOptions.toJsCmd+""").result(function(event, dt, formatted) {
jQuery("#"""+hidden+"""").val(dt.nonce);
8<--------------

The problem seems to be that dt has no "nonce" field, it's an array. If I modify the code as follow:
8<--------------
jQuery("#"""+id+"""").autocomplete(data, """+autocompleteOptions.toJsCmd+""").result(function(event, dt, formatted) {
jQuery("#"""+hidden+"""").val(formatted);
8<--------------

Everything works as expected.

Hope it may help ! Francois Armand

JPA archetype may be broken on enumerations

Triage this:

[ERROR] /private/var/www/xxx-master/spa/src/main/scala
[ERROR] /private/var/www/xxx-master/spa/src/main/scala/../scala
[INFO] Compiling 9 source files to
/private/var/www/xxx-master/spa/target/classes
[WARNING]
/private/var/www/xxx-master/spa/src/main/scala/com/xxx/model/EnumvType.scala:48:
error: value valueOf is not a member of Enumeration with com.xxx.model.Enumv
[WARNING] return et.valueOf(value).getOrElse(null)
[WARNING] ^
[WARNING] one error found

TextileParser issues

1# * and _. Look at the following:

scala> import net.liftweb.textile._
import net.liftweb.textile._

scala> TextileParser.toHtml("foo bar")
res7: scala.xml.NodeSeq =

foo __bar__

scala> TextileParser.toHtml("bar")
res8: scala.xml.NodeSeq =

bar

scala> TextileParser.toHtml("bar foo")
res9: scala.xml.NodeSeq =

bar *foo*

Something clearly isn't working with __ and ** ;)
#2 links with classes

scala> TextileParser.toHtml(""" "(cmsadmin-link)click here":# """)
res10: scala.xml.NodeSeq =

(cmsadmin-link)click here

Usually this should work too.

Truncated URLs

I have a problem with URLs whose last path segment contains a
fullstop, eg: /x/3.1/y/1.11

To illustrate the issue, I created a new lift project and added the
following to the Boot:

LiftRules.dispatch.prepend { 
    case Req(List("x", x,"y", y), _, _) => () => Full(XmlResponse( <p>x={ x } y={ y } </p> )) 
} 

Pointing a browser at /x/3.1/y/1.11 returns: x=3.1 y=1
So y is being truncated at the fullstop.
Doing this in Java with Jetty and a servlet, I can get the full path
out and parse it correctly so is Lift misbehaving?

Error attempting to persist Keyless Mapper

Calling save on a keyless Mapper object results in a NullPointerException: Trying to open an empty Box.

A simple example to reproduce the issue is attached along with the full stack trace.


Boot.scala

package bootstrap.liftweb

import _root_.net.liftweb.util._
import _root_.net.liftweb.http._
import _root_.net.liftweb.sitemap._
import _root_.net.liftweb.sitemap.Loc._
import Helpers._

import com.spiralarm.liftbug.mapperissue.model._
import _root_.java.sql.{Connection, DriverManager}
import _root_.net.liftweb.mapper.{DB, ConnectionManager, Schemifier, DefaultConnectionIdentifier, ConnectionIdentifier}

/**
    * A class that's instantiated early and run.  It allows the application
    * to modify lift's environment
    */
class Boot {
    def boot {
    // where to search snippet
    LiftRules.addToPackages("com.spiralarm.liftbug.mapperissue")

    // Build SiteMap
    val entries = Menu(Loc("Home", List("index"), "Home")) :: Nil
    LiftRules.setSiteMap(SiteMap(entries:_*))
    DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor)
    DB.addLogFunc((query, time) =>  Log.debug("DBQUERY {" +query + "} time{" + time + "} ms") )
    Schemifier.schemify(true,Log.infoF _,Parent,Child,ParentChild)

    Log.info("Parent Child join " + ParentChild.join("parent","child"))




    }
}
object DBVendor extends ConnectionManager { 

    // Force load the driver 
     Class.forName("com.mysql.jdbc.Driver")   

    // define methods 

        def newConnection(name : ConnectionIdentifier) = { 
         try { 
             Full(DriverManager.getConnection("jdbc:mysql://localhost:3306/bugs", "bugs", "bugs")) 
         } catch { 
         case e : Exception => e.printStackTrace; Empty 
         } 
     } 

    def releaseConnection (conn : Connection) { conn.close } 
} 

Parent.scala
package com.spiralarm.liftbug.mapperissue.model

import net.liftweb._ 
import net.liftweb.mapper._

class Parent extends LongKeyedMapper[Parent] with IdPK {

  def getSingleton = Parent

  object name  extends MappedString(this,10) 
}
object Parent extends Parent with LongKeyedMetaMapper[Parent]

class Child extends LongKeyedMapper[Child] with IdPK {

  def getSingleton = Child

  object name  extends MappedString(this,10)

}
object Child extends Child with LongKeyedMetaMapper[Child]

class ParentChild extends Mapper[ParentChild] {

  def getSingleton = ParentChild

  object parent extends MappedLongForeignKey(this, Parent)  
  object child  extends MappedLongForeignKey(this, Child) 
  object index  extends MappedInt(this) 

}
object ParentChild extends ParentChild with MetaMapper[ParentChild]{


   def join (parent :String, child :String):Boolean = {
     val p = Parent.create.name(parent).saveMe
     val c = Child.create.name(parent).saveMe
     join(p,c)
   }


   def join (parent :Parent, child :Child):Boolean = {
    val list = ParentChild.findAll(By(ParentChild.parent,parent))
    val i = list.isEmpty match {
      case true => 0
      case false => list.size
    }
    this.create.parent(parent).child(child).index(i).save
    }

}

java.lang.NullPointerException: Trying to open an empty Box
    at net.liftweb.util.EmptyBox.open_$bang(Box.scala:370)
    at net.liftweb.util.EmptyBox.open_$bang(Box.scala:366)
    at net.liftweb.mapper.MetaMapper$$anonfun$12.apply(MetaMapper.scala:583)
    at net.liftweb.mapper.MetaMapper$$anonfun$12.apply(MetaMapper.scala:578)
    at net.liftweb.mapper.DB$.use(DB.scala:305)
    at net.liftweb.mapper.MetaMapper$class.save(MetaMapper.scala:577)
    at com.spiralarm.liftbug.mapperissue.model.ParentChild$.save(Parent.scala:35)
    at net.liftweb.mapper.Mapper$$anonfun$save$1.apply(Mapper.scala:84)
    at net.liftweb.mapper.Mapper$$anonfun$save$1.apply(Mapper.scala:84)
    at net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:65)
    at net.liftweb.mapper.Safe$.runSafe(Safe.scala:44)
    at net.liftweb.mapper.Mapper$class.runSafe(Mapper.scala:50)
    at com.spiralarm.liftbug.mapperissue.model.ParentChild.runSafe(Parent.scala:26)
    at net.liftweb.mapper.Mapper$class.save(Mapper.scala:83)
    at com.spiralarm.liftbug.mapperissue.model.ParentChild.save(Parent.scala:26)
    at com.spiralarm.liftbug.mapperissue.model.ParentChild$.join(Parent.scala:51)
    at com.spiralarm.liftbug.mapperissue.model.ParentChild$.join(Parent.scala:41)
    at bootstrap.liftweb.Boot$$anonfun$boot$3.apply(Boot.scala:29)
    at bootstrap.liftweb.Boot$$anonfun$boot$3.apply(Boot.scala:29)
    at net.liftweb.util.Log4JLogger.info(Log.scala:240)
    at net.liftweb.util.Log$.info(Log.scala:54)
    at bootstrap.liftweb.Boot.boot(Boot.scala:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHelpers.scala:392)
    at net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHelpers.scala:390)
    at net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.scala:909)
    at net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.scala:909)
    at net.liftweb.util.Full.map(Box.scala:330)
    at net.liftweb.http.DefaultBootstrap$.boot(LiftRules.scala:909)
    at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:573)
    at net.liftweb.http.LiftFilter.init(LiftServlet.scala:548)
    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:653)
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1239)
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:466)
    at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:124)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
    at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
    at org.mortbay.jetty.Server.doStart(Server.java:222)
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
    at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
    at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
    at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
    at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

Incorrect Lock Ordering on SessionVar When Called from CometActor Constructor

When accessing a session variable from the constructor of a CometActor, deadlock will sometimes occur (usually with another comet thread already running against the session). The issue is comet actors are created from within LiftSession#findComet, which locks the session. If you access a SessionVar during this construction process, you will then lock the corresponding variable. However, most often it is the variable which locks first, and then the session (e.g. when accessing a session var during the normal course of execution). This of course can lead to deadlock when one thread is attempting to access a session var while another thread is creating a comet actor.

Problem with schemifier and H2

There is an issue with the mapper schemifier when using an H2 database. Specifically, if a user and password are specified, an exception is thrown during the boot process when attempting to verify the schema. If a user/password are not specified there is no problem.

A reproduce-able example can be found at:
http://github.com/eltimn/lift_1_1_sample/tree/master

Here is a partial stack-trace:
[INFO] Starting jetty 6.1.16 ...
2009-07-30 13:54:55.416::INFO: jetty-6.1.16
2009-07-30 13:54:55.566::INFO: No Transaction manager found - if your webapp requires one, please configure one.
INFO - CREATE TABLE users (id BIGINT NOT NULL AUTO_INCREMENT , firstname VARCHAR(32) , lastname VARCHAR(32) , email VARCHAR(48) , locale VARCHAR(16) , timezone VARCHAR(32) , password_pw VARCHAR(48) , password_slt VARCHAR(20) , textarea VARCHAR(2048) , validated BOOLEAN , uniqueid VARCHAR(32) , superuser BOOLEAN)
ERROR - Failed to Boot
java.util.NoSuchElementException: key not found: users
at scala.collection.Map$class.default(Map.scala:169)
at scala.collection.mutable.HashMap.default(HashMap.scala:33)
at scala.collection.Map$class.apply(Map.scala:80)
at scala.collection.mutable.HashMap.apply(HashMap.scala:33)
at net.liftweb.mapper.Schemifier$$anonfun$6$$anonfun$apply$7.apply(Schemifier.scala:189)
at net.liftweb.mapper.Schemifier$$anonfun$6$$anonfun$apply$7.apply(Schemifier.scala:189)
at net.liftweb.mapper.Schemifier$.net$liftweb$mapper$Schemifier$$using(Schemifier.scala:43)

Installer issue with existing bash profile

The Liftweb installer for Mac OS X generates a .bash_profile file whether .profile exists already or not. As a result of this, the shell will ignore the preexisting environment variables defined by .profile. The installer should detect the presence of .profile, and perform an append operation instead.

Xml parsing problem with html special characters

I'm having trouble parsing xhtml pages as xml if that page contains special characters like ® or   The html im parsing is created by lift.

The problem is generated whenever referencing a variable.xml and the result is:
[Fatal Error] :54:46: The entity "reg" was referenced, but not declared.
And the printout of the xml.

Code example:
val result: String =
get("/some_page/here/" + variable) match {
case h: HttpResponse =>
val input = (h.xml \ "input")
println("I got something" + input)
""
case other =>
println("Got something weird - got "+other)
""
}
result

MappedBinary may not handle BLOBs correctly

Just looking at the source, we have:

def buildSetActualValue(accessor: Method, inst: AnyRef, columnName: String): (T, AnyRef) => Unit =
(inst, v) => doField(inst, accessor, {case f: MappedBinary[T] =>
  val toSet = v match {
    case null => null
    case ba: Array[Byte] => ba
    case other => other.toString.getBytes("UTF-8")
  }
  f.data() = toSet
  f.orgData() = toSet
})

But the toSet doesn't have a case for getting a java.sql.Blob instance. I think that converting a BLOB to a String and then back to bytes is much less efficient than just doing:

  val toSet = v match {
    case null => null
    case ba: Array[Byte] => ba
    case blob : Blob => blob.getBytes(1, blob.length)
    case other => other.toString.getBytes("UTF-8")
  }

Problem with Db.runQuery and NUMERIC results

I'm using adhoc queries and I'm running into a problem where the results
of aggregate functions get mapped to integers:

I have this

val (,result) = DB.runQuery("SELECT AVG(vt.fuel_efficiency), vt.fuel_type, vt.category FROM "+
"vehicles v JOIN vehicle_types vt ON v.vehicle_type_id= vt.id "+
"WHERE v.account_id=? "+
"GROUP BY vt.fuel_type, vt.category "+
"ORDER BY vt.fuel_type, vt.category",
List(User.currentUser.open
!.account.is))

in Postgres, the first column is returned as NUMERIC, ie with decimals, but in

private def asString(pos: Int, rs: ResultSet, md: ResultSetMetaData)

we have this:

case BIGINT | INTEGER | DECIMAL | NUMERIC | SMALLINT | TINYINT =>
rs.getLong(pos).toString

which seems wrong.

So... numeric should be rs.getDouble(pos).toString ?

Yes, or BigDecimal. Same goes for DECIMAL I think. "The recommended Java
mapping for the DECIMAL and NUMERIC types is java.math.BigDecimal" [1]

[1] http://java.sun.com/j2se/1.5.0/docs/guide/jdbc/getstart/mapping.html

Oracle: Invalid column type

I just tried to run the todo app.
(http://liftweb.net/docs/getting_started/mod_master.html) against our Oracle (10.2) database. I used Oracle's SQLDeveloper to confirm that the tables had been created and had the right columns. However, when I tried to "Sign Up" in the todo app., I got this stuff right in the browser (nothing in the log):
Exception occured while processing /user_mgt/sign_up
Message: java.sql.SQLException: Invalid column type

More details about this exception can be found here:
http://groups.google.com/group/liftweb/browse_thread/thread/9adaf97d0ccb1fbd

I'm using Lift 1.0.

/Jon

Schema (for schemifier) should be specifiable

Schemifier seems to decide for you what schema to schemify tables in. When the DriverType doesn't specify a default schema, the username is used. This precludes automatically creating an H2 database with a username because it doesn't have the schema. Should the default schema name for H2 be ""?

DOM optimizations

The DOM processing should be done in 3 distinguished phases:

  1. surround & include processing
  2. merge (head, tail, Lift's comet&Ajax scripts, etc)
  3. binary transformation (including fixHtml)

Marius

lift-testkit - xml parsing error when processing HttpResponse

I have a test case which issues http gets/posts to our server running the Innovation Games application. It is our 'stress test' for the Buy-A-Feature game. It currently works using an older variant of the lift-testkit library. When I run it with the current lift-testkit library I get the exception below.

I have isolated it down to the line in the library which is failing. Below I list both the working and non-working code.

TestFramework.scala: line 280 (non-working):
override lazy val xml = XML.load(new root.java.io.ByteArrayInputStream(body))

TestFramework.scala (working):
override lazy val xml = {
try3{
val s = new String(body, "UTF-8").replaceAll("""<!.*>""","")
XML.loadString(s)}

Stack Trace/Exception:

First test instance get headers: Map(Content-Length -> List(2711), Expires -> List(Wed, 8 Jul 2009 17:41:35 UTC), Set-Cookie -> List(JSESSIONID=1x0d2w2cmflwg;Path=/), Pragma -> List(no-cache), Server -> List(Jetty(6.1.16)), Content-Type -> List(text/html), X-Lift-Version -> List(1.1-SNAPSHOT), Cache-Control -> List(no-cache; private; no-store; must-revalidate; max-stale=0; post-check=0; pre-check=0; max-age=0))
Exception in thread "Thread-7" java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1290)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:677)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:1315)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:1282)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:283)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(XMLDocumentScannerImpl.java:1192)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(XMLDocumentScannerImpl.java:1089)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1002)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at scala.xml.parsing.FactoryAdapter.loadXML(FactoryAdapter.scala:292)
at scala.xml.parsing.NoBindingFactoryAdapter.loadXML(NoBindingFactoryAdapter.scala:60)
at scala.xml.XML$.load(XML.scala:64)
at net.liftweb.http.testing.HttpResponse.xml(TestFramework.scala:280)
at com.enthiosys.buyafeature.stress_test.TestInstance.runWith(StressTest.scala:66)
at com.enthiosys.buyafeature.stress_test.StressTest$$anonfun$main$2$$anon$2.run(StressTest.scala:44)

autocomplete widget - make options settable?

the default autocomplete options i.e.

val autocompleteOptions = JsRaw(...

need to be more easily set. I had to override and copy-paste the render function to change these. Making them settable without extending the class would be ideal. making the autocompleteOptions val an overridable outer function would be fine though.

JSON strings should be enclosed in double quotes

Currently, lift appears to generate JSON string values enclosed in single quotes such as ['hello', 'world']. Although this is valid for JavaScript strings, the same is not true for JSON strings, which must (for strict parsers) always be encloded in double quotes.

This occurred with lift 1.0 and server generated JSON via the JsonResponse class.

When in dev mode, flag SiteMap failures

When running in development mode (and upcoming Bespin mode), flag pages that are not served because they are not in SiteMap as such in the error message (404)

H2 not getting primary keys created

Run the following code


import root.net.liftweb.util._
import Helpers._
import root.java.sql.{Connection, DriverManager}

class M extends LongKeyedMapper[M] with IdPK {
def getSingleton = M
object field extends MappedString(this, 10)
}
object M extends M with LongKeyedMetaMapper[M]

object H2TestCase {
def main(args: Array[String]) {
DB.defineConnectionManager(DefaultConnectionIdentifier, new ConnectionManager {
def newConnection(name: ConnectionIdentifier): Box[Connection] = {
Class.forName("org.h2.Driver")
Full(DriverManager.getConnection("jdbc:h2:mem:lift;DB_CLOSE_DELAY=-1"))
}

  def releaseConnection(conn: Connection) {
      try {
          conn.close
      } catch {
          case e => Empty //ignore
      }
  }


})

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

}

}

The output is:
INFO - CREATE TABLE m (field VARCHAR(10) , id BIGINT NOT NULL AUTO_INCREMENT)
INFO - CREATE INDEX m_id ON m ( id )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.