java在Jetty中运行servlet时获得HTTP 500
我有一个servlet,直到几天前还运行得很好。但我唯一改变的是我为maven使用的nexus回购协议。我正在通过mvn jetty:run运行servlet
但当我试图访问该网站而不是查看主页时,我看到:
HTTP ERROR 500
Problem accessing /. Reason:
jregex/Pattern
我可以访问其他url,比如/favicon。伊科。但是我找不到关于这个jregex/模式错误的任何信息,而且代码中似乎根本没有使用jregex库
我在日志中也没有看到任何问题。看起来对主页的请求并没有发送到我的servlet,但对其他页面的请求却在发送
这在Arch Linux和Mac OS X 10.7上都是如此
这几乎肯定是一个依赖性问题,因为用旧的~/.m2
文件夹(带有旧nexus服务器的依赖性)替换我的~/.m2
文件夹后,它就可以工作了
有时我也会:
HTTP ERROR: 503
Problem accessing /. Reason:
SERVICE_UNAVAILABLE
# 1 楼答案
您正在运行的mvn命令是什么?您是否尝试过手动下载工件并在本地工件上运行mvn
我会首先使用mvn下载工件。这将验证您的所有设置/权限设置是否正常且适当。为此,可以使用Maven Dependency Plugin (v2.4)将依赖项下载到本地文件。有关更多详细信息,请参见this post
一旦你能确保你能在本地下载工件,试着在本地工件上运行jetty:run。如果这有效,那么你就知道你的回购协议有问题
如果仍不起作用,则可能是镜像设置或repo配置有问题。例如,如果mvn需要一个本地没有的插件或依赖项,它将寻求第三方回购。你的设置。xml文件可能会将所有这些镜像到您的本地nexus服务器,该服务器可能未配置为从MvnCentral下载
确保你没有任何依赖/插件下载问题。您可以轻松地从设置中指向mvncentral。完全绕过nexus服务器
# 2 楼答案
杰森,这是我的工作,这是我经常使用的,pom。xml(相关部分):
这里是网络。位于上述webappconfig中指定位置的xml作为描述符:
以及servlet本身:
您可以通过运行
mvn jetty:run
来运行服务器,并在http://localhost:9080/jetty-example/hello
检查它此外,当您在芬兰构建项目时,您可以将执行添加到插件部分并启动jetty。无需每次手动
mvn jetty:run
您还可以添加jetty配置文件,我将其用于数据库(用于不同的环境)。您可以在jetty插件的
webAppConfig
中添加文件位置,如下所示:以及码头环境的样本含量。xml:
你应该擅长这个
# 3 楼答案
FWIW,你能用BeyondCompare(Scooter Software)这样的工具进行文件比较吗