laut Servlet Spezifikation können sich unterhalb des WEB-INF zwei Verweichnisse befinden:
classes und lib.
Im Lib Verzeichnis können nach der Spezifikation Bibliotheken mit der Endung JAR untergebracht und genutzt werden. Einen Hinweis auf eine nötige Konfiguration habe ich nicht finden können.
Leider hat das nicht so funktioniert.
Geht das überhaupt mit Tomcat (3.2) oder muss ich doch irgendow einen Hinweis auf die JARS geben?
Ich habe keine Bedenken, dass das funktionieren wird.
Mir geht es aber auch um das Deployment meiner Anwendung. Das heisst in meiner WAR-Datei habe ich ebenfalls diesen Ordner lib und hätte ihn auch gerne dort gelassen, ohne dessen Inhalt erst verschieben zu müssen, damit ich die Funktionalität nutzen kann.
laut Servlet Spezifikation können sich unterhalb des WEB-INF
zwei Verweichnisse befinden:
classes und lib.
Im Lib Verzeichnis können nach der Spezifikation Bibliotheken
mit der Endung JAR untergebracht und genutzt werden. Einen
Hinweis auf eine nötige Konfiguration habe ich nicht finden
können.
Leider hat das nicht so funktioniert.
Geht das überhaupt mit Tomcat (3.2) oder muss ich doch
irgendow einen Hinweis auf die JARS geben?
Normalerweise funktioniert das mit Tomcat 3.2, dass die JARs unter WEB-INF/lib liegen. Eigentlich könnte es nur an Kleinigkeiten, wie z.B. Gross- und Kleinschreibung bei UNIX-Systemen und Verzeichnisstruktur innerhalb der JARs liegen.
Ein Workaround, falls es gar nicht klappen sollte, wäre, die JARs nach WEB-INF/classes zu entpacken, dann ist das Problem umgangen und das Deployment bleibt simpel.
Normalerweise funktioniert das mit Tomcat 3.2, dass die JARs
unter WEB-INF/lib liegen. Eigentlich könnte es nur an
Kleinigkeiten, wie z.B. Gross- und Kleinschreibung bei
UNIX-Systemen und Verzeichnisstruktur innerhalb der JARs
liegen.
Ich arbeite auf einem Windows System. Da sollte dieses Problem nicht auftauchen. Aber ich habe da, meiner Ansicht nach, keinen Fehler.
Die Struktur ist da bei mir etwas anders. Vielleicht habe ich das nicht so ganz deutlich machen können.
Ich rede von einem WEB-INF-Verzeichnis unterhalb der Applikation.
Ich meine das lib-Verzeichnis, das unter Application steht.
Habe ich da vielleicht etwas missverstanden und dieses lib gibt es nicht?
In einer WAR-Datei kann es durchaus so existieren und TOMCAT entpackt die Struktur auch genau wie oben beschrieben.
Ein Workaround, falls es gar nicht klappen sollte, wäre, die
JARs nach WEB-INF/classes zu entpacken, dann ist das Problem
umgangen und das Deployment bleibt simpel.
So mache ich es derzeit. Ist halt der geringste Aufwand und es funktioniert.
Ich meine das lib-Verzeichnis, das unter Application steht.
Habe ich da vielleicht etwas missverstanden und dieses lib
gibt es nicht?
So wie ich die Spezifikation (Java-Servlet) verstanden habe gibt es das WEB-INF unter Application nicht, es ist mir nicht bekannt,
das es überhaupt ein Application-Verzeichnis gibt. Das Verzeichnis mit dem Namen der App unter webapps stellt die App meines Wissens nach dar. Oder ist das etwas aus der J2EE? Davon hab ich nicht soviel Ahnung.
Jedenfalls funktioniert das automatische Laden der libs aus
public_html/WEB-INF/lib. Lädt er die Klassen bei dir wirklich aus
public_html/WEB-INF/Application/classes oder liegen die auch in public_html/WEB-INF/classes? Würd mich interessieren falls es auch unter Application geht.
In einer WAR-Datei kann es durchaus so existieren und TOMCAT
entpackt die Struktur auch genau wie oben beschrieben.
Tomcat entpackt immer das ganze WAR, die Struktur darin spielt dabei keine Rolle.
So wie ich die Spezifikation (Java-Servlet) verstanden habe
gibt es das WEB-INF unter Application nicht, es ist mir nicht
bekannt,
das es überhaupt ein Application-Verzeichnis gibt. Das
Verzeichnis mit dem Namen der App unter webapps stellt die App
meines Wissens nach dar. Oder ist das etwas aus der J2EE?
Davon hab ich nicht soviel Ahnung.
Eigentlich nicht. Folgendes steht in der Spezifikation (Kapitel 9.4):
_Java™ Servlet Specification Version 2.2 43
Directory Structure
A web application exists as a structured hierarchy of directories. The root of this hierarchy serves as
a document root for serving files that are part of this context. For example, for a web application
located at /catalog in a web server, the index.html file located at the base of the web
application hierarchy can be served to satisfy a request to /catalog/index.html.
See the JavaServer Pages specification available from http://java.sun.com/products/jsp.ഊWeb Applications
A special directory exists within the application hierarchy named “WEB-INF”. This directory
contains all things related to the application that aren’t in the document root of the application. It is
important to note that the WEB-INF node is not part of the public document tree of the application.
No file contained in the WEB-INF directory may be served directly to a client.
The contents of the WEB-INF directory are:
• /WEB-INF/web.xml deployment descriptor
• /WEB-INF/classes/* directory for servlet and utility classes. The classes in this directory
are used by the application class loader to load classes from.
• /WEB-INF/lib/*.jar area for Java ARchive files which contain servlets, beans, and other
utility classes useful to the web application. All such archive files are used by the web
application class loader to load classes from._
Demnach sollte das doch, wie oben geschildert gehen, oder?
Jedenfalls funktioniert das automatische Laden der libs aus
public_html/WEB-INF/lib. Lädt er die Klassen bei dir wirklich
aus
public_html/WEB-INF/Application/classes oder liegen die auch
in public_html/WEB-INF/classes? Würd mich interessieren falls
es auch unter Application geht.
Ja, genau das tut er. Und das ist ja das schöne für das verteilen der Anwendung.
In einer WAR-Datei kann es durchaus so existieren und TOMCAT
entpackt die Struktur auch genau wie oben beschrieben.
Tomcat entpackt immer das ganze WAR, die Struktur darin spielt
dabei keine Rolle.
Ist richtig: das LIB sthet im WAR natürlich schon da, wo es später hin soll.
_Java™ Servlet Specification Version 2.2 43
Directory Structure
A web application exists as a structured hierarchy of
directories. The root of this hierarchy serves as
a document root for serving files that are part of this
context. For example, for a web application
located at /catalog in a web server, the index.html file
located at the base of the web
application hierarchy can be served to satisfy a request to
/catalog/index.html.
See the JavaServer Pages specification available from http://java.sun.com/products/jsp.Web Applications
A special directory exists within the application hierarchy
named “WEB-INF”. This directory
contains all things related to the application that aren’t in
the document root of the application. It is
important to note that the WEB-INF node is not part of the
public document tree of the application.
No file contained in the WEB-INF directory may be served
directly to a client.
The contents of the WEB-INF directory are:
• /WEB-INF/web.xml deployment descriptor
• /WEB-INF/classes/* directory for servlet and utility
classes. The classes in this directory
are used by the application class loader to load classes from.
• /WEB-INF/lib/*.jar area for Java ARchive files which contain
servlets, beans, and other
utility classes useful to the web application. All such
archive files are used by the web
application class loader to load classes from._
Davon bin ich auch ausgegangen, aber vorerst eine Frage zur Klärung von eventuellen Missverständnissen: Mit public_html meinst du das root-Verzeichnis der Webapp, also z.B. /webapps/test und nicht das WebApp-Verzeichnis von Tomcat /webapps, oder?
Davon bin ich auch ausgegangen, aber vorerst eine Frage zur
Klärung von eventuellen Missverständnissen: Mit public_html
meinst du das root-Verzeichnis der Webapp, also z.B.
/webapps/test und nicht das WebApp-Verzeichnis von Tomcat
/webapps, oder?
Ich habe hier schon von letzterem geredet. Das ist ja auch das Verzeichnis, in dem die WAR-Dateien erkannt und entpackt werden.
Zusätzlich habe ich noch einen entsprechenen Eintrag zum neuen Context in der server.xml vorgenommen.