问题描述
我有一个基于Lift的REST应用程序。我的开发环境正在运行内置在SBT中的Jetty服务器,并且该应用程序已部署在Tomcat 7上。
I have a Lift-based REST application. My dev environment is running the Jetty server built into SBT, and the application is deployed on Tomcat 7.
我最近将Ehcache集成到我的设置中,放弃了自定义缓存。它在我的Jetty开发服务器中完美运行。但是,当我部署到tomcat时,我的Lift应用程序提供的所有URL都会得到404。除了日志中的404之外,没有例外,也没有相关的日志项目。
I recently integrated Ehcache to my setup, discarding a custom cache. It works flawlessly in my Jetty dev server. When I deploy to tomcat however, any URL's served by my Lift application get 404's. There are no exceptions, and no log items as far as I can find that are relevant, aside from the 404 in the log.
当我注释掉提到的行时Ehcache并将其作为依赖项删除,Tomcat启动并正常运行并提供这些URL。取消注释Ehcache之后,它又一次变成了404。
When I comment out the lines referring to Ehcache and remove it as a dependency, Tomcat fires up and works fine and serves those urls. As soon as I uncomment Ehcache, it's all 404's again.
有人知道发生了什么吗?我知道Ehcache使用SLF4J进行日志记录,是否以某种方式阻止了ehcache错误出现在我的日志中?
Does anyone know what is going on? I know Ehcache uses SLF4J to log, is that somehow stopping ehcache errors from appearing in my logs?
build.sbt的相关部分:
Relevant section of build.sbt:
Seq(
"net.liftweb" %% "lift-webkit" % liftVersion % "compile",
"net.liftweb" %% "lift-mapper" % liftVersion % "compile",
"com.typesafe.slick" %% "slick" % "2.0.0-M3",
"org.eclipse.jetty" % "jetty-webapp" % "8.1.7.v20120910" % "container,test",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container,test" artifacts Artifact("javax.servlet", "jar", "jar"),
"ch.qos.logback" % "logback-classic" % "1.0.6",
"org.specs2" %% "specs2" % "1.14" % "test",
"mysql" % "mysql-connector-java" % "5.1.25",
"net.sf.ehcache" % "ehcache" % "2.8.2",
"javax.transaction" % "transaction-api" % "1.1",
"org.slf4j" % "slf4j-simple" % "1.7.7"
)
ehcache.xml的相关部分
Relevant seciont of ehcache.xml
<cache name="mycache"
maxEntriesLocalHeap="10000"
maxEntriesLocalDisk="1000"
eternal="false"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="21600"
timeToLiveSeconds="43200"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
</cache>
任何帮助将不胜感激。
Any help would be greatly appreciated. Thanks in advance.
推荐答案
最后解决了这个问题。这是两个单独的问题。首先,我在生产环境中运行的Tomcat 7.0.42有一个(或多个)错误。 EhCache静默失败。
Finally solved this. It was two separate problems. First, there was a bug (or multiple) with Tomcat 7.0.42 I was running in production. EhCache was failing silently.
在7.0.52的单独安装中,它引发异常,表示无法找到我的ehcache.xml文件。将文件移至WEB-INF / classes /解决了该异常,应用程序启动了。回到我的7.0.42安装,它仍然不会启动。
In a separate installation of 7.0.52, It was throwing an Exception, saying it was unable to locate my ehcache.xml file. Moving the file to WEB-INF/classes/ solved that exception and the application spun up. Moving back to my 7.0.42 installation however, it still would not fire up.
在将我的生产安装强制为7.0.52后,该应用程序启动并运行正常。
After forcing my production installation to 7.0.52, the application fires up and works fine.
因此,总的来说,我有两个问题:
So in summary, I had two problems:
- Ehcache无法执行找到我的配置文件
- Tomcat 7.0.42似乎有错误
解决方案:
- 将ehcache.xml移至WEB-INF / classes
- 从7.0.42升级Tomcat-> 7.0.52
这篇关于Ehcache导致Tomcat 7提供404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!