我有一个网络应用程序(实际上是一个 gwt 应用程序),我想将它部署到 Jetty 服务器进行硒测试,我使用了 maven、maven-jetty-plugin、gwt-maven-plugin 和 selenium-maven-plugin,我终于得到了jetty 和 selenium 服务器正在运行,但 selenium 测试由于著名的 404 错误而失败:
com.thoughtworks.selenium.SeleniumException: XHR ERROR: URL = http://127.0.0.1:8080/index.html Response_Code = 404 Error_Message = Not Found
我不确定我的码头配置是否正确,因为我对它有点陌生,这是它(maven-jetty-plugin):
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<contextPath>/sample-console</contextPath>
<webAppSourceDirectory>${basedir}/target/${project.artifactId}-${project.version}</webAppSourceDirectory>
<webXml>${basedir}/target/${project.artifactId}-${project.version}/WEB-INF/web.xml</webXml>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integraion-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
当我运行 mvn clean install 时,我可以看到命令窗口的输出:
[INFO] Configuring Jetty for project: DYI sample Console
[INFO] Webapp source directory = /Users/dyi/Documents/workspace/sample/console/target/sample-console-0.1-SNAPSHOT
[INFO] Reload Mechanic: automatic
[INFO] Classes = /Users/dyi/Documents/workspace/sample/console/target/classes
log4j:WARN No appenders could be found for logger (org.mortbay.log).
log4j:WARN Please initialize the log4j system properly.
[INFO] Context path = /sample-console
[INFO] Tmp directory = determined at runtime
[INFO] Web defaults = org/mortbay/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = /Users/dyi/Documents/workspace/sample/console/target/sample-console-0.1-SNAPSHOT/WEB-INF/web.xml
[INFO] Webapp directory = /Users/dyi/Documents/workspace/sample/console/target/sample-console-0.1-SNAPSHOT
[INFO] Starting jetty 6.1.22 ...
[INFO] Started Jetty Server
[INFO] [selenium:start-server {execution: start}]
我的文件夹结构如下所示:
--sample/
-- console/
-- src/
-- target/
-- classes/
-- sample-console-0.1-SNAPSHOT/
-- css/
-- images/
-- img/
-- index.html
-- js/
-- META-INF/
-- security/
-- test.html
-- WEB-INF/
-- classes/
-- lib/
-- web.xml
我不明白的是我可以看到 index.html 页面就在文件夹“sample-console-0.1-SNAPSHOT”中,为什么找不到它?那是因为我设置了“上下文路径”错误吗?我尝试将其设置为“/”,然后出现 503 服务不可用错误。有人可以帮忙吗?非常感谢!!