Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with web.xml that need to be filtered #58

Open
f-renout opened this issue Dec 11, 2020 · 12 comments
Open

Error with web.xml that need to be filtered #58

f-renout opened this issue Dec 11, 2020 · 12 comments

Comments

@f-renout
Copy link

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:

io.leonard.maven.plugins
jspc-maven-plugin
3.2.0


jspc

compile

package

${basedir}/target/simuweb-web/WEB-INF/web.xml



@tcollignon
Copy link
Collaborator

Hi

Do you provide your code or full pom.xml please?

@f-renout
Copy link
Author

poc.zip

Here is a minimum project that reproduce the problem.
launch mvn clean install

@tcollignon
Copy link
Collaborator

tcollignon commented Dec 15, 2020

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

@f-renout
Copy link
Author

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.

@tcollignon
Copy link
Collaborator

Not included in the war? You have it at both places no ?

@f-renout
Copy link
Author

f-renout commented Dec 16, 2020

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

@tcollignon
Copy link
Collaborator

Can you give me entire pom.xml and entire log please?

@f-renout
Copy link
Author

poc.zip
Here they are

@tcollignon
Copy link
Collaborator

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>

@f-renout
Copy link
Author

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)

@tcollignon
Copy link
Collaborator

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>

@f-renout
Copy link
Author

I'm in holliday but I'll give a try to your solution asap.

Thanks for all your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants