需要了解 WAR 描述符和结构 - WAR 内的 Flex 项目
我试图了解为什么在我的项目上启动 mvm jetty:run 后无法从 URL 启动 SWF。
项目已经构建成功,并在maven目标目录下生成了Falcon-WAR-0.0.1-SNAPSHOT.war。该文件中包含以下文件 - 并包括从 Flex 项目编译的 .swf 文件。
我的 web.xml 非常简单,包含以下代码:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Falcon Flights</display-name>
<welcome-file-list>
<welcome-file>Falcon-Flights.swf</welcome-file>
</welcome-file-list>
</web-app>
我的应用程序的上下文根是相同的作为 WAR 的工件 ID,因此它是 FALCON-WAR。
当我启动 mvn jetty:run 时,我会在控制台上打印以下内容:
但是,当我尝试导航到 http://localhost:8080/FALCON-WAR 在我的浏览器上,当我希望从 web.xml 定义启动 .swf 文件时,我得到以下内容。
谁能帮我弄清楚我做错了什么?这可以让我更多地了解 Web 容器如何解释 .war 结构 - 但这是我第一次参与 Web 应用程序开发,可以通过推动来完成!
非常感谢。
I am trying to understand why I am not able to launch a SWF from the URL after launching mvm jetty:run on my project.
The project has built successfully and produced a Falcon-WAR-0.0.1-SNAPSHOT.war in the maven target directory. In this file are the following files - and includes the .swf file compiled from the Flex project.
My web.xml is very simple and contains the following code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Falcon Flights</display-name>
<welcome-file-list>
<welcome-file>Falcon-Flights.swf</welcome-file>
</welcome-file-list>
</web-app>
The context root of my application is the same as the artifact ID of the WAR, so it is FALCON-WAR.
When I launch mvn jetty:run, I get the following print to the console:
However when I try to navigate to http://localhost:8080/FALCON-WAR on my browser, I get the following, when I expect to launch the .swf file from the web.xml definition.
Could anyone help me fathom what I am doing wrong? This could me more to do with understanding how web containers interpret .war structures - but this is my first bash at web application development and could do with a nudge!
Many thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我对码头了解不多;但是您在“输出”中看到的内容看起来像是一个网络服务器目录列表。目录中是否还列出了其他内容?您确定 Web 根目录指向您在第一个快照中显示的目录吗? [如果有,meta-inf 目录和 falcon-flights 文件在哪里?如果您将 URL 更改为:
这是否会给您带来 404 错误,或者加载是否正确?
I don't know much about Jetty; but what you're seeing in your "output" looks like a web server directory listing. Is there anything else listed in the directory? Are you sure the web root is pointed at the directory you display in your first snapshot? [If so, where is the meta-inf directory and falcon-flights file? What if you change your URL to this:
Does that give you a 404 error, or does it load properly?
最终我使用了 mvn jetty:run=exploded 目标。该目标指向 WAR 文件的构建目录(问题文本图像中的第一个快照),并且上下文路径随后有效。
仍然不确定为什么 jetty:run 无法正常工作 - 但我已经启动并运行了。
感谢 Flextras 的帮助...
Eventually I used the mvn jetty:run=exploded goal. This goal points to the build directory of the WAR file (the first snapshot in the image from the question text) and the context path was then valid.
Still not sure why the jetty:run was not working correctly - but I am up and running.
Thanks to Flextras for the help...
这是因为
jetty:run
从 Maven 项目的源工作。虽然您已经显示了目标的目录列表,但您的 SWF 是如何到达那里的并不明显 - 我猜测它是您的 WAR 模块的依赖项,而不是保存在src/ 中main/webapp
或类似的。jetty:run-exploded 首先构建目标目录,然后从那里运行应用程序。因此,这样的效果会更好。
另一个选项是 jetty:run-war,它构建 WAR 并从中运行应用程序。但是,这会比 jetty:run-exploded 慢,后者需要少一个构建步骤。
请参阅 http://docs.codehaus.org/display/JETTY/Maven+Jetty+插件了解更多详细信息。
This is because
jetty:run
works from the source of your Maven project. Although you have shown a directory listing of the target, it is not obvious how your SWF got there- I would guess that it is a dependency of your WAR module, rather than held insrc/main/webapp
or similar.jetty:run-exploded
builds the target directory first, then runs the application from there. Therefore this would work better.Another option is
jetty:run-war
, which builds the WAR and runs the application from that. However, this will be slower thanjetty:run-exploded
, which requires one fewer build step.See http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin for more details.