Skip to content

Instantly share code, notes, and snippets.

@BowlingX
BowlingX / gist:4124688
Created November 21, 2012 12:45
assembly.sbt
import AssemblyKeys._
assemblySettings
mainClass in assembly := Some("com.yourCompany.YourMainClass")
@BowlingX
BowlingX / gist:3958151
Created October 26, 2012 10:47
Flash Map with request Support
trait MyFlashMapSupport extends Handler {
this: CoreDsl with DynamicScope with SessionSupport =>
import FlashMapSupport._
abstract override def handle(req: HttpServletRequest, res: HttpServletResponse) {
withRequest(req) {
val f = getFlash(req)
val isOutermost = !req.contains(lockKey)
if (isOutermost) {
@BowlingX
BowlingX / gist:3951613
Created October 25, 2012 09:26
Sample Scala Main with embedded Jetty
package com.bowlingx.run
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.webapp.WebAppContext
import com.bowlingx.util.Logging
/**
* This describes our Main Entry point to launch YourApp
* Launches an embedded Jetty Server
@BowlingX
BowlingX / gist:3951607
Created October 25, 2012 09:24
Bash Jar File Runner with log rotation
#!/bin/bash
set -e
XNAME="YourApp"
SCALATRA_ENV="production"
TMP_DIR="tmp/$XNAME/"
JAVA_OPTIONS=(-Xmx3024M -XX:MaxPermSize=512M)
LOGDIR="/usr/share/YourApp/logs/$XNAME"
PORT="9090"
JAVA_OPTIONS=("${JAVA_OPTIONS[@]}" "-Djava.io.tmpdir=$TMP_DIR")
JAVA_OPTIONS=("${JAVA_OPTIONS[@]}" "-Dorg.scalatra.environment=$SCALATRA_ENV")
@BowlingX
BowlingX / gist:3951597
Created October 25, 2012 09:23
Init Script for Java Application
#! /bin/sh
### BEGIN INIT INFO
# Provides: YourApp
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: YourShortDescription
# Description: YourDescription
### END INIT INFO
@BowlingX
BowlingX / gist:3933516
Created October 22, 2012 19:24
Hazelcast Map Configuration
<!-- Session Storage: -->
<map name="shiro-activeSessionCache">
<backup-count>1</backup-count>
<!-- Delete Sessions after one Hour if no access -->
<!-- https://groups.google.com/forum/?fromgroups=#!topic/hazelcast/iScOrTaSJbA -->
<max-idle-seconds>3600</max-idle-seconds>
<eviction-policy>LRU</eviction-policy>
<map-store enabled="true">
<!--
Name of the class implementing MapLoader and/or MapStore.
@BowlingX
BowlingX / gist:3933478
Created October 22, 2012 19:16
Scala Hazelcast Session Store
package com.bowlingx.model
import net.liftweb.mongodb.record.{MongoMetaRecord, MongoRecord}
import net.liftweb.mongodb.record.field.StringPk
import com.hazelcast.core.MapStore
import java.util
import com.bowlingx.util.Logging
import net.liftweb.record.field.{StringField, DateTimeField, BinaryField}
import java.io._
import util.Calendar
@BowlingX
BowlingX / gist:3788190
Created September 26, 2012 13:53
Scalate with Scalate Compiler
trait TemplateBindings extends ScalateSupport {
self: ScalatraServlet =>
override protected def defaultTemplatePath: List[String] = List("/webTmpl/views")
override protected def createTemplateEngine(config: ConfigT) = {
val engine = super.createTemplateEngine(config)
engine.layoutStrategy = new DefaultLayoutStrategy(engine,
TemplateEngine.templateTypes.map("/webTmpl/layouts/default." + _): _*)
ivyXML :=
<dependencies>
<exclude org="org.eclipse.jetty.orbit" />
</dependencies>
libraryDependencies ++= Seq(
"org.scalatra" % "scalatra" % "2.1.0-SNAPSHOT",
"org.scalatra" % "scalatra-specs2" % "2.1.0-SNAPSHOT" % "test",
"ch.qos.logback" % "logback-classic" % "1.0.0" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "8.1.4.v20120524" % "container",
@BowlingX
BowlingX / gist:2635689
Created May 8, 2012 14:40
Exception during Websocket Access with Apache Shiro and Atmosphere
16:38:32.716 [qtp2112864060-76] WARN o.a.w.protocol.SimpleHttpProtocol - org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: java.io.InvalidClassException: scala.collection.mutable.HashSet; local class incompatible: stream classdesc serialVersionUID = 1, local class serialVersionUID = -693344176634852721 Status 500 Message Server Error
16:38:50.381 [qtp2112864060-73 Selector0] WARN o.a.websocket.WebSocketProcessor - AsynchronousProcessor.AsynchronousProcessorHook was null
16:38:50.775 [qtp2112864060-76] WARN o.a.websocket.WebSocketProcessor - Failed invoking AtmosphereFramework.doCometSupport()
org.apache.shiro.cache.CacheException: net.sf.ehcache.CacheException: java.io.InvalidClassException: scala.collection.mutable.HashSet; local class incompatible: stream classdesc serialVersionUID = 1, local class serialVersionUID = -693344176634852721
at org.apache.shiro.cache.ehcache.EhCache.put(EhCache.java:105) ~[shiro-ehcache-1.2.0.jar:1.2.0]
at org.apache.shiro.session.mgt.eis.CachingSessionD