You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

生产环境下Play Framework读取public目录静态文件异常问题

Docker部署后静态文件路由访问报错,本地运行正常

基本信息

  • 静态文件路径:public/robots.txt
  • 访问地址:http://localhost:9000/robots.txt
  • 预期:正常加载文件无错误
  • 现状:本地运行正常,Docker部署后访问抛出异常

报错日志

[error] a.a.OneForOneStrategy - null
java.lang.NullPointerException: null
    at kamon.instrumentation.akka.instrumentations.akka_26.InstrumentNewExecutorServiceOnAkka26$.around(DispatcherInstrumentation.scala:109)
    at akka.dispatch.ThreadPoolConfig$ThreadPoolExecutorServiceFactory.createExecutorService(ThreadPoolBuilder.scala)
    at akka.dispatch.Dispatcher$LazyExecutorServiceDelegate.executor$lzycompute(Dispatcher.scala:44)
    at akka.dispatch.Dispatcher$LazyExecutorServiceDelegate.executor(Dispatcher.scala:44)
    at akka.dispatch.ExecutorServiceDelegate.execute(ThreadPoolBuilder.scala:219)
    at akka.dispatch.ExecutorServiceDelegate.execute$(ThreadPoolBuilder.scala:219)
    at akka.dispatch.Dispatcher$LazyExecutorServiceDelegate.execute(Dispatcher.scala:43)
    at akka.dispatch.Dispatcher.registerForExecution(Dispatcher.scala:127)
    at akka.dispatch.MessageDispatcher.attach(AbstractDispatcher.scala:152)
    at akka.actor.dungeon.Dispatch.start(Dispatch.scala:121)
[error] p.c.s.n.PlayRequestHandler - Cannot invoke the action
akka.stream.AbruptTerminationException: Processor actor [Actor[akka://application/system/Materializers/StreamSupervisor-0/flow-1-0-headSink#-440110538]] terminated abruptly

当前路由配置(conf/routes)

GET     /robots.txt        controllers.Assets.at(path="/public", file="robots.txt")

解决建议

  • 检查Kamon与Akka/Play版本兼容性:报错来自Kamon对Akka 2.6的Instrumentation代码空指针,大概率是版本不匹配,升级或降级Kamon到适配当前框架版本的稳定版。
  • 临时禁用Kamon的Akka Dispatcher监控:在Kamon配置文件中添加kamon.instrumentation.akka.dispatchers.enabled = false,绕过有问题的监控逻辑。
  • 排查Docker镜像依赖打包:确认构建镜像时所有依赖(包括Kamon相关)都完整打包,无版本冲突或缺失。
  • 改用Play默认静态文件路由:Play框架默认会把public/目录下的文件映射到根路径,无需手动配置robots.txt的路由,直接删除自定义路由后重试访问。

内容的提问来源于stack exchange,提问作者Nandha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 03:25:35