struts icon indicating copy to clipboard operation
struts copied to clipboard

[WW-5233] Include Apache Tiles code base in the Tiles plugin

Open lukaszlenart opened this issue 3 years ago • 1 comments

Fixes WW-5233

lukaszlenart avatar Oct 01 '22 14:10 lukaszlenart

SonarCloud Quality Gate failed.    Quality Gate failed

Bug B 2 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 158 Code Smells

62.6% 62.6% Coverage
3.8% 3.8% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

sonarqubecloud[bot] avatar Jul 30 '23 06:07 sonarqubecloud[bot]

@gregh3269 @JCgH4164838Gh792C124B5 @kusalk any objections to merge this and release a new version?

lukaszlenart avatar Jul 30 '23 08:07 lukaszlenart

We are not using Tiles or these plugins so no objections here :)

kusalk avatar Jul 30 '23 08:07 kusalk

+1. But then i am standard wrt tiles.

gregh3269 avatar Jul 30 '23 09:07 gregh3269

Is there some instructions how to migrate to 6.3.0 when using Tiles? After upgrading from 6.2.0 to 6.3.0, a web app (which worked fine on 6.2.0) fails to start due to an error:

java.lang.ClassNotFoundException: org.apache.tiles.extras.complete.CompleteAutoloadTilesListener

This comes from having this in web.xml:

<listener> <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class> </listener>

The pom.xml has e.g.:

<dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-tiles-plugin</artifactId> <version>6.3.0</version> </dependency>

and

<dependency> <groupId>org.apache.tiles</groupId> <artifactId>tiles-core</artifactId> <version>3.0.8</version> </dependency>

Removing this last dependency (as the 6.3.0 release notes instruct to do?) does not help.

HittiGubbi avatar Sep 20 '23 09:09 HittiGubbi

@ HittiGubbi what is org.apache.tiles.extras.complete.CompleteAutoloadTilesListener used for?

Would use

web.xml
<listener>
	<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
// So the ROOT##.war naming works 
<context-param>
	<param-name>org.apache.tiles.definition.DefinitionsFactory.DEFINITIONS_CONFIG</param-name>
	<param-value>
		/WEB-INF/tiles.xml
	</param-value>
</context-param>

pom.xml
<dependency>
	<groupId>org.apache.struts</groupId>
	<artifactId>struts2-tiles-plugin</artifactId>
	<version>${org.apache.struts.version}</version>
</dependency>

gregh3269 avatar Sep 20 '23 09:09 gregh3269

Yes that listener is from the old deprecated plugin - see here for updated instructions

kusalk avatar Sep 20 '23 09:09 kusalk

Thank you. I tried this but now get the error:

java.lang.NoSuchMethodError: 'void org.apache.commons.digester.Digester.setXIncludeAware(boolean) at org.apache.tiles.core.definition.digester.DigesterDefinitionsReader.<init> (DigesterDefinitionsReader.java:270)

HittiGubbi avatar Sep 20 '23 10:09 HittiGubbi

Looks like you're using a different version of commons-digester to the one included by Struts

kusalk avatar Sep 20 '23 10:09 kusalk

..By using the org.apache.tiles.extras.complete.CompleteAutoloadTilesListener you get Wild Cards, EL, OGNL, MVEL support in your tiles.xml

https://stackoverflow.com/questions/10050433/ognl-and-wildcards-working-in-tiles-definitions-with-struts2-tiles-plugin/10067367#10067367

Can you share your tiles.xml please?

gregh3269 avatar Sep 20 '23 10:09 gregh3269

Can you try dropping the struts2-tiles-plugin and replace with tiles extras as it does not look like you are using the struts2 tiles plugin ie StrutsTilesListener.

<dependency>
   	<groupId>org.apache.tiles</groupId>
    	<artifactId>tiles-extras</artifactId>
    	<version>3.0.8</version>
</dependency>

I tested this and it will start, but it brings a very old velocity 1.6, which won't work for me.

In the struts2-tiles-plugin <6.2.0 it had only a few classes, possibly none were being used, and was used to bring the tiles jars needed by your app.

gregh3269 avatar Sep 21 '23 06:09 gregh3269

Thank you all for the advice. The web app seems to be working now after changing to use org.apache.struts2.tiles.StrutsTilesListener and removing transitively included package dependency declarations from pom.xml :).

HittiGubbi avatar Sep 24 '23 12:09 HittiGubbi