3

When you create a new Web Application Project using the Google-Eclipse plugin, it creates an entire project directory structure for you, including:

src/
    META-INF/
        jdoconfig.xml
        persistence.xml
war/
    WEB-INF/
        lib/
        web.xml
        ...etc.

First off, my understanding was that META-INF/ was only for utility JARs, not for web apps (WARs). So to see src/META-INF/* in the project caught me by surprise. But then I've seen examples of GAE web apps that package like so:

TheWebApp.war/
    WEB-INF/
        lib/
        classes/
            META-INF/
        web.xml
        ...
    blah.jsp
    ...etc/

With WEB-INF/classes/META-INF/! On top of this, I don't see any mention of GAE projects and a MANIFEST.MF directory, which I always see used packaged under META-INF. Now I'm really confused.

So I think I first need confirmation/clarification on what the role of META-INF and WEB-INF are in general, then understand how they can be used together inside the WAR of any web application, and then understand any idiosyncrasies (if they exist) that GAE places on its WAR structures.

Note: I'm not using Maven and don't intend to for at least the next 6 - 12 months (I just don't have time to learn it right now). So if any of the answers to these questions depend on whether you're using a Maven-based buld or not, I'd prefer the non-Maven answers as I'm using Ant/Ivy.

So I ask:

  1. What are the normal contents of a META-INF directory, for utility (library) JARs, executable JARs and WARs? Is a MANIFEST.MF necessary for WARs (GAE- and non-GAE alike), why or why not?
  2. Where am I supposed to put non-web resources so that their available to the runtime classpath? For instance, say I have environment.properties or myapp-custom-resource-config.xml...where do I put these? In WEB-INF/, WEB-INF/classes, WEB-INF/classes/META-INF? Somewhere else?
  3. What are the proper contents of a GAE project's WEB-INF and META-INF directories, and what's the correct way of packaging them?

Thanks in advance.

IAmYourFaja
  • 50,141
  • 159
  • 435
  • 728

1 Answers1

0

Like JAR file META-INF directories, the root-level /META-INF directory contains the application manifest file. It can also contain resources for specific web containers or application servers. For example, Apache Tomcat looks for and uses a context.xml file in this directory to help customize how the application is deployed in Tomcat.

Unlike JAR files, the root-level /META-INF directory is not on the application classpath. You cannot use the ClassLoader to obtain resources in this directory. /WEB-INF/classes/META-INF, however, is on the classpath. You can place any application resources you desire in this directory, and they become accessible through the ClassLoader.

Koray Tugay
  • 20,438
  • 37
  • 155
  • 276