question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Confusing/misleading error creating FileOutputStream for plugin

See original GitHub issue

Someone contacted me with the following stack trace:

FAILED CONFIGURATION: @BeforeClass setUpClass
java.lang.IllegalArgumentException: Couldn't create a file output stream for target\cucumber\cucumberReport.json.
Make sure the the file isn't a directory.
The details are in the stack trace below:
at io.cucumber.core.plugin.PluginFactory.createFileOutputStream(PluginFactory.java:209)
at io.cucumber.core.plugin.PluginFactory.openStream(PluginFactory.java:197)
at io.cucumber.core.plugin.PluginFactory.convert(PluginFactory.java:164)
at io.cucumber.core.plugin.PluginFactory.instantiate(PluginFactory.java:97)
at io.cucumber.core.plugin.PluginFactory.create(PluginFactory.java:62)
at io.cucumber.core.plugin.Plugins.createPlugins(Plugins.java:32)
at io.cucumber.core.plugin.Plugins.<init>(Plugins.java:25)
at io.cucumber.testng.TestNGCucumberRunner.<init>(TestNGCucumberRunner.java:92)
at io.cucumber.testng.AbstractTestNGCucumberTests.setUpClass(AbstractTestNGCucumberTests.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:63)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:348)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:302)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:176)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:122)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at org.testng.TestRunner.privateRun(TestRunner.java:766)
at org.testng.TestRunner.run(TestRunner.java:587)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1109)
at org.testng.TestNG.runSuites(TestNG.java:1039)
at org.testng.TestNG.run(TestNG.java:1007)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.io.FileNotFoundException: target\cucumber\cucumberReport.json (The system cannot find the path specified)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
at io.cucumber.core.plugin.PluginFactory.createFileOutputStream(PluginFactory.java:207)
... 34 more
  • Cucumber-JVM 6.6.0
  • JDK 1.8.0_261
  • Windows

Some theories what might be wrong (without having looked at the code or tried to reproduce it):

  • The path is a directory (unlikely)
  • We’re not doing mkdir -p
  • Something to do with backslashes?
  • File permissions (unlikely on windows?)

In any case we should inspect the file system more closely when an error occurs so we can provide a better error message.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:19 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
mpkorstanjecommented, Oct 16, 2020

Can you try: html:target/report/cucumber.html. Note the extension.

2reactions
mvallecommented, Sep 18, 2020

I’m still facing this issue with 6.7.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cucumber Exception Failed to create directory - Stack Overflow
From what I have found, it seems that the plugin object is trying to create 2 directories called "cucumber" when what you want...
Read more >
Cucumber Exception Failed To Create Directory - ADocLib
IllegalArgumentException: Couldn't create a file output stream for Confusing/misleading error creating FileOutputStream for plugin #2108.
Read more >
FileOutputStream (Java Platform SE 7 ) - Oracle Help Center
Creates a file output stream to write to the specified file descriptor, which represents an existing connection to an actual file in the...
Read more >
Issue Collector Cannot Attach File in IE9 or IE10 - Jira - Atlassian
<init>(FileOutputStream.java:194) at java.io.FileOutputStream.<init>(FileOutputStream.java:145) at com.atlassian.jira.collector.plugin.rest.
Read more >
[JDK-8278848] A problem occurs when entering a specific file ...
When you try to create a file with specific words in FileOutputStream, ... of the file extension, and both relative and absolute paths...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found