Skip to content

Commit

Permalink
Fix resource base under Jetty 12.0.8+
Browse files Browse the repository at this point in the history
  • Loading branch information
ddworak committed Aug 16, 2024
1 parent 8f9f8ab commit 9afb55b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import org.eclipse.jetty.rewrite.handler.{RewriteHandler, RewriteRegexRule}
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.server.handler.ContextHandlerCollection
import org.eclipse.jetty.server.handler.gzip.GzipHandler
import org.eclipse.jetty.util.resource.ResourceFactory

import java.nio.file.Path

class ApplicationServer(val port: Int, homepageResourceBase: String, guideResourceBase: String)(implicit scheduler: Scheduler) {
private val server = new Server(port)
Expand Down Expand Up @@ -56,7 +59,7 @@ class ApplicationServer(val port: Int, homepageResourceBase: String, guideResour
}
contextHandler.addServlet(atmosphereHolder, "/atm/*")

//this is required for org.atmosphere.container.JSR356AsyncSupport to setup at all
//required for org.atmosphere.container.JSR356AsyncSupport to setup at all
JavaxWebSocketServletContainerInitializer.configure(contextHandler, null)

contextHandler.addServlet(new ServletHolder(RestServlet[MainServerREST](new ExposedRestInterfaces)), "/rest_api/*")
Expand All @@ -73,7 +76,8 @@ class ApplicationServer(val port: Int, homepageResourceBase: String, guideResour
val contextHandler = new ServletContextHandler
contextHandler.setSessionHandler(new SessionHandler)
contextHandler.setVirtualHosts(hosts)
contextHandler.addServlet(new ServletHolder(new DefaultServlet).setup(_.setInitParameter("baseResource", resourceBase)), "/*")
contextHandler.setBaseResource(ResourceFactory.of(contextHandler).newResource(Path.of(resourceBase)))
contextHandler.addServlet(new ServletHolder(new DefaultServlet), "/*")
contextHandler
}

Expand Down
3 changes: 1 addition & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ object Dependencies {

val scalaLoggingVersion = "3.9.5"

//todo 12.0.8+ does not serve static resources properly
val jettyVersion = "12.0.7"
val jettyVersion = "12.0.12"
val typesafeConfigVersion = "1.4.3"
val flexmarkVersion = "0.64.8"
val logbackVersion = "1.3.14"
Expand Down

0 comments on commit 9afb55b

Please sign in to comment.