I'm building a modular web application which has some Spring components packed inside a jar dependency (different module). This jar also contains some JSP resources like:
- Module + src/main/resources/META-INF/resources/module/*.jsp
Now I want to override a specific JSP using the following structure in my application.
- App + src/main/resources/META-INF/resources/module/menu.jsp
When running the application using tomcat7:run
it will sometimes show the overridden menu.jsp
but will any subsequent runs will end up with the old one.
Running with tomcat7:run-war
was more promising. Most of the runs the new menu.jsp is shown. But when deploying the application to another Tomcat 7 instance the old menu is visible once again.
The menu.jsp is include using pageContext.include("/module/menu.jsp");
which is called by a custom tag.
How can I make this overriding of resources more reliable? I'm totally clueless since it seems to be randomly working. I hope somebody can shed some light here.
Not sure if this is relevant but to be able to use component scanning I need to unpack the jar classes with the following plugin configuration.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<overWriteIfNewer>false</overWriteIfNewer>
<artifactItems>
<artifactItem>
<groupId>my.company</groupId>
<artifactId>my-dependency</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<includes>**/*.class</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
After a lot of hair pulling I came to realize I made a very simple mistake. I have now moved
- App + src/main/resources/META-INF/resources/module/menu.jsp
to the location
- App + src/main/webapp/module/menu.jsp
and everything works like expected.