jspc-maven-plugin
jspc-maven-plugin copied to clipboard
Error with web.xml that need to be filtered
Hi, I'm trying to use jspc but I can't figure out how to make it work due to an error during web.xml parsing.
My web.xml need to be filtered, it's done in maven-war-plugin. One of the field that need to be parsed is the session-timeout.
When I try to use jspc, I got an error as the web.xml is parsed and my session timeout "${session-config.session-timeout}", so I got a NumberformatException.
I try to execute it during package phase using the web.xml in /target but it didn't work.
If someone can help, it will be great.
Here is my conf of jspc in case:
Hi
Do you provide your code or full pom.xml please?
Hello Frederic (J'avais pas vu que c'était toi, Lorraine Jug power :) )
I think maven-war-plugin should be run before jspc, and then jspc must take elements in target folder to have filtered elements.
So the maven configuration should be like that (in efluid project we do things like that)
- jspc execution on package phase
- Adding webAppSourceDirectory and webXml to refer to maven-war-plugin output
<build>
<finalName>poc</finalName>
<filters>
<filter>${project.basedir}/configuration/filter.properties</filter>
</filters>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<directory>${project.basedir}/src/main/webapp</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
<plugin>
<groupId>io.leonard.maven.plugins</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>jspc</id>
<goals>
<goal>compile</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<webAppSourceDirectory>${project.build.directory}/${project.artifactId}</webAppSourceDirectory>
<webXml>${project.build.directory}/${project.artifactId}/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
I hope this is good for you
Salut Thomas, j'avais pas vu non plus, le monde est petit
the web.xml is now generated but at the source of /target and is not included in the war.
Not included in the war? You have it at both places no ?
after running mvn package I've this result target __poc ___WEB-INF ___web.xml (not modified) \web.xml (modified) \webfrag.xml \poc.war (with the unmodified web.xml inside)
So I need to figure out how to "replace" the web.xml in my war with the jspc updated one
Can you give me entire pom.xml and entire log please?
poc.zip Here they are
Don't you miss previous configuration of maven war plugin in this new version of pom.xml ?
<webResources>
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/webapp</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
indeed, but I had removed the filter section to see if it was the problem.
If the pom include webResources it's the same result (web.xml created at /target and the web.xml in .war is the unmodified one)
JSPC does not change the war archive, so if you have a problem it's with maven war plugin
Look at this pom file, that I have taken from your version last time, it works fine I think
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>poc</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>poc Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>poc</finalName>
<filters>
<filter>${basedir}/configuration/filter.properties</filter>
</filters>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/webapp</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
<plugin>
<groupId>io.leonard.maven.plugins</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>jspc</id>
<goals>
<goal>compile</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<webAppSourceDirectory>${project.build.directory}/${project.artifactId}</webAppSourceDirectory>
<webXml>${project.build.directory}/${project.artifactId}/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
I'm in holliday but I'll give a try to your solution asap.
Thanks for all your help