6

When running mvn verify I am getting below message:

enter image description here

I already put the log4j2.xml under src/test/resources (but not in src/main/resources because I do not want it to ship with actual app) as suggested here to no avail.

enter image description here

The HTML report is generated, the log file is written, and the build is successful as seen above. I am unsure where the error is coming from.

k_rollo
  • 5,304
  • 16
  • 63
  • 95
  • Is it the same message if you add the following dependency in the pom -> org.apache.logging.log4j log4j-api 2.10.0 – Mr Cas Mar 20 '18 at 15:58
  • @MrCas Still the same error message after adding `log4j-api`. After all, it is a transient dependency of `log4j-core` so it shouldn't matter whether it's specified in the pom.xml or not. – k_rollo Mar 24 '18 at 04:05
  • 1
    have you tried `-Dlog4j.configurationFile=file:///path/to/your/log4j2.xml`? – Ivan Mar 30 '18 at 19:31

5 Answers5

4

According http://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticConfiguration adding log4j2.xml to classpath should help.

If a JSON file cannot be located the XML ConfigurationFactory will try to locate log4j2.xml on the classpath.

So if you still get ERROR message problem not with your sources. It looks like problem in maven-cucumber-reporting plugin. As described here http://maven.apache.org/guides/mini/guide-maven-classloading.html

Please note that the plugin classloader does neither contain the dependencies of the current project nor its build output.

If maven plugin cannot find any log4j configuration in its own classpath (which is not including your sources/resources) you will see error messages. So yes, the only solution wait for release with fix https://github.com/damianszczepanik/cucumber-reporting/issues/675

Yuriy Alevohin
  • 941
  • 7
  • 18
  • Sorry I forgot about this bounty but this is impressive detective work. Acceptable explanation and marked as answer. – k_rollo Apr 09 '18 at 13:46
2

You use the latest Cucumber version 3.15.0 (at the time of writing this). Your problem was resolved as issue #675. There was a commit from a pull request meant to fix this problem, but probably you have to wait until the next version is released in order to profit from it - or build a snapshot version locally and see if it also fixes the problem for you.

kriegaex
  • 63,017
  • 15
  • 111
  • 202
  • Well, you can un-accept the other one and accept mine. My answer has been written 4 days before the accepted one and is correct. The other answer does not add value and even points to the very same ticket mine pointed to before. First come, first serve. – kriegaex Apr 09 '18 at 14:52
1

Run -> Run Configurations -> Classpath -> User entries -> Advanced Optiones -> Add Folders -> Then add your folder,in your case src/test/resources -> apply

It must work now :D

acochavosdi
  • 91
  • 1
  • 1
  • 7
  • Thank you but the src/test/resources is already marked as a source folder. Everything in it already goes to the target classpath. – k_rollo Apr 09 '18 at 13:27
1

You are receiving this error because cucumber or its dependencies are using log4j for logging and since there is no log4j configuration file so log4j is printing such message.

If there is no log4j configuration file, log4j uses configuration similar to below -

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configuration>

<Configuration status="warn" name="xml_configuration">

    <Appenders>
        <Console name="consoleLogger" target="SYSTEM_OUT">
            <PatternLayout
                pattern="[%level] %m%n" />
        </Console>
    </Appenders>

    <Loggers>
        <Root level="error" additivity="false">
            <appender-ref ref="consoleLogger" />
        </Root>
    </Loggers>
</Configuration>

Adding above configuration in /src/main/resources/log4j2.xml will have same result as having no log4j2.xml file.

Another way to try is to pass log4j2.xml file to maven directly without putting it in project classpath. Something like below -

set MAVEN_OPTS="-Dlog4j.configurationFile=file:///path/to/log4j2.xml"
mvn verify
Vikas Sachdeva
  • 5,633
  • 2
  • 17
  • 26
  • Hi, I do have the config file in the classpath. Turns out, this was a known defect in the `maven-cucumber-reporting` plugin itself that was not fixed until recently. – k_rollo Apr 09 '18 at 13:56
0

according to their documentation, you can use 'joranConfigurator' and load the configuration from a specified file

documentation link

Elarbi Mohamed Aymen
  • 1,617
  • 2
  • 14
  • 26