Maven Jetty plugin daemon element not allowed here
Asked Answered
R

2

8

I am trying to configure a project's pom.xml file. I want it to start Jetty server in testing phase. In order to do it I should add "daemon" element to Jetty plugin as I did below, but IntelliJ warns me with "Element daemon is not allowed here." Can you please help me? What is the reason?

<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.11.v20150529</version>
            <configuration>
                <httpConnector>
                    <port>8083</port>
                </httpConnector>
            </configuration>
            <executions>
                <execution>
                    <id>start-jetty</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <scanIntervalSeconds>0</scanIntervalSeconds>
                        <daemon>true</daemon>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-jetty</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
Ryter answered 25/1, 2016 at 15:23 Comment(0)
F
18

It's actually a IntelliJ Idea's bug. It sometimes doesn't recognize some of configuration properties correctly. The plugin does have this property, so you don't really have other option than to just ignore the error in IDE. The plugin will work as expected.

Fluorescent answered 25/1, 2016 at 15:49 Comment(2)
Is there a reference for this bug that we could upvote? It is really annoying to have an unjustified error, but I don't want to disable the schema validation for my pom.xml.Foursome
Are you sure daemon is an allowed config on the run goal? I only see it on the deploy-war goal. eclipse.org/jetty/documentation/9.4.x/…Perren
S
2

I know I am four years late, but I am investigating on the same issue.

If you update Jetty's dependency to 10.0.0, the error is solved: daemon does not produce that error anymore.

However, things get weird if you update to 11.0.0 (latest, on Maven Central):

  • daemon starts producing error again,
  • scanIntervalSeconds produces error too, whereas it previously never did.

So, I made some researches.

I suspect you took your code from using jetty and maven-failsafe-plugin.

I read some of the Jetty 11 Programming Guide, and found this paragraph:

Here is an example, which turns on scanning for changes every ten seconds, and sets the webapp context path to /test:

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>{VERSION}</version>
  <configuration>
    <scan>10</scan>
    <webApp>
      <contextPath>/test</contextPath>
    </webApp>
  </configuration>
</plugin>

Also, I found this other paragraph:

Here’s an example of using the pre-integration-test and post-integration-test Maven build phases to trigger the execution and termination of Jetty:

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>{VERSION}</version>
  <configuration>
    <scan>10</scan>
    <stopKey>foo</stopKey>
    <stopPort>9999</stopPort>
  </configuration>
  <executions>
    <execution>
      <id>start-jetty</id>
      <phase>pre-integration-test</phase>
      <goals>
        <goal>start</goal>
      </goals>
      <configuration>
        <scan>0</scan>
      </configuration>
    </execution>
    <execution>
      <id>stop-jetty</id>
      <phase>post-integration-test</phase>
       <goals>
         <goal>stop</goal>
       </goals>
     </execution>
  </executions>
</plugin>

Thus, I replaced the scanIntervalSeconds occurrences with scan. As result of this, IntelliJ didn't signal any error for the first occurrence anymore. However, the second occurrence still produces error.

As far as daemon is concerned...

On the old Jetty 9 documentation:

For example, you can configure the plugin to start your webapp at the beginning of your unit tests and stop at the end. To do this, you need to set up a couple of execution scenarios for the Jetty plugin. You use the pre-integration-test and post-integration-test Maven build phases to trigger the execution and termination of Jetty:

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>{VERSION}</version>
  <configuration>
    <scanIntervalSeconds>10</scanIntervalSeconds>
    <stopKey>foo</stopKey>
    <stopPort>9999</stopPort>
  </configuration>
  <executions>
    <execution>
      <id>start-jetty</id>
      <phase>pre-integration-test</phase>
      <goals>
        <goal>start</goal>
      </goals>
      <configuration>
        <scanIntervalSeconds>0</scanIntervalSeconds>
      </configuration>
    </execution>
    <execution>
      <id>stop-jetty</id>
      <phase>post-integration-test</phase>
       <goals>
         <goal>stop</goal>
       </goals>
     </execution>
  </executions>
</plugin>

The daemon is not even mentioned here. So, it is possible that Failsafe's documentation has an error, and daemon is not really needed.

To conclude:

  • I have no clue why daemon worked on 10 and doesn't anymore in 11.
  • It seems it is not even necessary...
Shawna answered 5/1, 2021 at 1:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.