0
votes

I have a static site built using HTML/CSS/JS that I want to wrap up in a .war file and wrap that up in a .ear file to deploy on a Glassfish java server. However I am unsure of how best to generate the .war and .ear files.

Currently I have zipped and renamed / changed the type of containing folders to make the .war and .ear files, creating a META-INF/application.xml in the .ear and a META-INF/MANIFEST.MF and WEB-INF/web.xml inside the .war alongside the build files:

my-app.ear
  --- META-INF
    --- application.xml
  --- my-app.war
    --- META-INF
      --- MANIFEST.MF
    --- WEB-INF
      --- web.xml
    --- website build files (various folders and html/css/js files)

When I deploy the .ear on Glassfish I get no errors however the localhost root only shows the welcome page. I have also tried various different contexts such as localhost/my-app which return 404s (although that is expected given my applicaiton.xml context route is set to '/'.

Is my folder/file structure correct or am I missing something in setting up the .war and .ear files?

Serving the site in this way is a requirement for this project and I am not a regular Java user so I may be have missed something basic.

EDIT:

My application.xml file looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<application id="Application_ID" version="6" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">
 <display-name>my-app</display-name>
 <module>
  <web>
    <web-uri>my-app.war</web-uri>
    <context-root>/</context-root>
  </web>
 </module>
</application>

My web.xml looks as follows:

<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="my-app" version="3.0">
  <display-name>my-app</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
</web-app>
1

1 Answers

1
votes

Use Eclipse / Export / Java EE / EAR file within a dynamic web project. May be a small test project first and then look at differences. There is too much information missing to answer your question without guessing.