justb4 / docker-jmeter

Docker image for Apache JMeter
MIT License
278 stars 310 forks source link

Log file not found / No permission to create #43

Closed TannerGabriel closed 2 years ago

TannerGabriel commented 3 years ago

I'm trying to use the image in Kubernetes to automate Jmeter tests, but I am running into some odd permission problems regarding the Jmeter log files. See the issue in the following example:

Command:

docker run --volume `pwd`:/keptn/jmeter -n  -t /keptn/jmeter/basiccheck.jmx -JSERVER_URL=`printf -- "%s" "${HOST##*/}"` -l /keptn/jmeter/log.jtl

Error Message:

2021-06-22 17:58:11,819 main ERROR FileManager (jmeter.log) java.io.FileNotFoundException: jmeter.log (Permission denied) java.io.FileNotFoundException: jmeter.log (Permission denied)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory.createManager(FileManager.java:434)
    at org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory.createManager(FileManager.java:418)
    at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)
    at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:100)
    at org.apache.logging.log4j.core.appender.FileManager.getFileManager(FileManager.java:182)
    at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:96)
    at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:52)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1002)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:942)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:934)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:552)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:288)
    at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:618)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:691)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:708)
    at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:138)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:45)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:48)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:30)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
    at org.apache.jmeter.JMeter.<clinit>(JMeter.java:124)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.jmeter.NewDriver.main(NewDriver.java:250)

2021-06-22 17:58:11,829 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.FileAppender for element File: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory@c33b74f] unable to create manager for [jmeter.log] with data [org.apache.logging.log4j.core.appender.FileManager$FactoryData@130161f7] java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.FileManager$FileManagerFactory@c33b74f] unable to create manager for [jmeter.log] with data [org.apache.logging.log4j.core.appender.FileManager$FactoryData@130161f7]
    at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:115)
    at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:100)
    at org.apache.logging.log4j.core.appender.FileManager.getFileManager(FileManager.java:182)
    at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:96)
    at org.apache.logging.log4j.core.appender.FileAppender$Builder.build(FileAppender.java:52)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1002)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:942)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:934)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:552)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:288)
    at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:618)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:691)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:708)
    at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:138)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:45)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:48)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:30)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
    at org.apache.jmeter.JMeter.<clinit>(JMeter.java:124)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.jmeter.NewDriver.main(NewDriver.java:250)

2021-06-22 17:58:11,831 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.FileAppender for element File: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.FileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.FileAppender
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:234)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:134)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1002)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:942)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:934)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:552)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:241)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:288)
    at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:618)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:691)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:708)
    at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:263)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:138)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:45)
    at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:48)
    at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:30)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
    at org.apache.jmeter.JMeter.<clinit>(JMeter.java:124)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.jmeter.NewDriver.main(NewDriver.java:250)

2021-06-22 17:58:11,837 main ERROR Null object returned for File in Appenders.
2021-06-22 17:58:11,848 main ERROR Unable to locate appender "jmeter-log" for logger config "root"
Jun 22, 2021 5:58:12 PM java.util.prefs.FileSystemPreferences$1 run
WARNING: Couldn't create user preferences directory. User preferences are unusable.
Jun 22, 2021 5:58:12 PM java.util.prefs.FileSystemPreferences$1 run
WARNING: java.io.IOException: No such file or directory
An error occurred: Unknown arg: null

It looks like the permissions to create the jmeter.log files are missing inside of the container. I also tried to provide a custom path for the log file, giving me a different error.

Command:

docker run --volume `pwd`:/keptn/jmeter justb4/jmeter jmeter -n  -t /keptn/jmeter/basiccheck.jmx -JSERVER_URL=`printf -- "%s" "${HOST##*/}"`  -j /keptn/jmeter/test.log -l /keptn/jmeter/log.jtl

Error message:

Jun 15, 2021 2:36:55 PM java.util.prefs.FileSystemPreferences$1 run
WARNING: Couldn't create user preferences directory. User preferences are unusable.
Jun 15, 2021 2:36:55 PM java.util.prefs.FileSystemPreferences$1 run
WARNING: java.io.IOException: No such file or directory
An error occurred: Unknown arg: null
justb4 commented 2 years ago

Please look at the file test.sh how to pass arguments to the Docker container call in run.sh. For example you don't need to have the jmeter command itself.

TannerGabriel commented 2 years ago

@justb4 Thank you for the reply. I already solved the issue with my own JMeter image.