Pergunta

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.

enter image description here

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: enter image description here

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.

enter image description here

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.

Foi útil?

Solução 2

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...

Outras dicas

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:

http://localhost:8080/FALCON-WAR/Falcon-Flights.swf

Does that give you a 404 error, or does it load properly?

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 in src/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 than jetty:run-exploded, which requires one fewer build step.

See http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin for more details.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top