mercredi 6 décembre 2017

One page web application (Ember.js) deployed to Java EE server: 404 Not found when not accessing through thr root URL

I have an Ember.js application which I need to deploy to a Java EE application server. I already have a setup, so that I can generate a war with maven, I have pom.xml and static.xml, see them at the bottom of the post. The war only includes the static files of the Ember.js app.

The Ember.js app is deployed and reachable on a contextroot /myapp/. If I start on this root URL (http://localhost:8080/myapp), the app is working fine. I can even navigate through links in the app to any other route, for example http://localhost:8080/myapp/subroute. In this case Ember.js itself is handling the routing just fine.

However when I try to access the app directly on said URL, then I get a 404 Not Found error.

My setup is clearly not enough, something is missing. Note: There is an exception written for WEB-INF in the static.xml file, but I don't actually have a WEB-INF directory.

pom.xml:

<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU"
  xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/HBk9RF">
  <modelVersion>4.0.0</modelVersion>
  <groupId>hu.dbx</groupId>
  <artifactId>MyApp</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>MyApp</name>
  <url>http://ift.tt/19pvvEY;
  <build>
    <finalName>myapp</finalName>
    <plugins>
      <plugin>
        <!-- assamble static content -->
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <descriptors>
            <descriptor>static.xml</descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

static.xml

<?xml version="1.0" encoding="UTF-8"?>
<assembly>
  <id>static</id>
  <formats>
    <format>war</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>dist</directory>
      <includes>
        <include>**</include>
      </includes>
      <excludes>
        <exclude>WEB-INF/*</exclude>
      </excludes>
      <outputDirectory>/</outputDirectory>
    </fileSet>
  </fileSets>
</assembly>




Aucun commentaire:

Enregistrer un commentaire