Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two Meta-Inf folders - normal structure?

I just "discovered" that we have two Meta-Inf folders ... In eclipse and also in the War file.

The First one is (in the war):

/META-INF/

The Second, and weird one ist:

/WEB-INF/classes/META-INF/

In the second folder is a persistance.xml and a something.taglib.xml...

If i move the files into the first meta-inf folder i get exceptions from hibernate..

What is the purpose of this second and oddly placed meta-inf folder ?

Is this a normal folder structure ?

like image 507
Nick Russler Avatar asked Nov 05 '12 19:11

Nick Russler


People also ask

What is the META-INF folder?

The META-INF folder is the home for the MANIFEST. MF file. This file contains meta data about the contents of the JAR. For example, there is an entry called Main-Class that specifies the name of the Java class with the static main() for executable JAR files.

What is META-INF maven folder?

By default, Maven generated archives include the META-INF/maven directory, which contains the pom. xml file used to build the archive, and a pom. properties file that includes some basic properties in a small, easier to read format.

What is the difference between META-INF and Web INF?

The META-INF directory is private and can't be accessed from the outside. On the other hand, it also contains the WEB-INF public directory with all the static web resources, including HTML pages, images, and JS files. Moreover, it contains the web. xml file, servlet classes, and libraries.

What is META-inf in Android?

Jar files are used by all types of java applications, they have a specific structure – the META-INF folder contains the manifest information and other metadata about the java package carried by the jar file.


1 Answers

The "weird one" location is correct; JSR-220/JSR-317 (Java Persistence API 1.0/2.0) in section 6.2/8.2 say:

The jar file or directory whose META-INF directory contains the persistence.xml file is termed the root of the persistence unit. In Java EE, the root of a persistence unit may be one of the following:

  • an EJB-JAR file
  • the WEB-INF/classes directory of a WAR file
  • a jar file in the WEB-INF/lib directory of a WAR file
  • a jar file in the root of the EAR*
  • a jar file in the EAR library directory
  • an application client jar file.

*) Only valid for JPA 1.0

So, directly in a WAR file, the only correct location is WEB-INF/classes/META-INF/.

like image 109
MaDa Avatar answered Oct 04 '22 05:10

MaDa