In a Java EE project, I moved all the libraries from the WAR/WEB-INF/lib
to the EAR/lib
.
Opening a JSP, now I get this error:
Struts has detected an unhandled exception:
Messages:
File "/struts-tags" not found
File: org/apache/jasper/compiler/DefaultErrorHandler.java
Line number: 51Stacktraces org.apache.jasper.JasperException: File "/struts-tags" not found ........... ...........
How to resolve this problem ?
Moving the libraries from the WAR to the EAR may be very useful, e.g. if you have more than one WAR* inside one EAR, to avoid redundancy of libraries.
* Note: With multiple WAR in Struts2, you may encounter problems in some application server: read more on the official documentation.
To make a Skinny WAR (a WAR without libraries) work, the conditions are:
The WAR's
META-INF/MANIFEST.MF
must contain a Class-Path property linking your libraries:The EAR's
application.xml
must contain:<library-directory>lib</library-directory>
.To achieve this conditions on Maven, without the need of declaring the dependency of each library of WAR's POM.xml in EAR's POM.xml, you can use this amazing trick.
That said, the problem reported in the question is given by the fact that the
TLD
lookup is performed on the WAR only, the EAR is out of scope (AFAIK, there is no way to lookup a TLD in the EAR, but I'd like to be proven wrong).The solution:
extract the
struts-tags.tld
fromstruts2-core-2.3.x.x.jar
, and place it under (each)WAR/WEB-INF
folder. This is related to any kind of TLD file inside a JAR, not only to Struts2.In JSP: