complete port to scala, work around scala's failure with optional dependency on ServletContext