I ran into a baffling error the other day while working with Arquillian. I added Arquillian to a simple project requiring only the Java SE container for some “lite” CDI injection. However, when I went to run the unit tests, they failed:
org.jboss.shrinkwrap.api.exporter.ArchiveExportException: File could not be created: target/test.jar at org.jboss.shrinkwrap.impl.base.exporter.AbstractStreamExporterImpl.getOutputStreamToFile(AbstractStreamExporterImpl.java:95) at org.jboss.shrinkwrap.impl.base.exporter.AbstractStreamExporterImpl.exportTo(AbstractStreamExporterImpl.java:144) at org.jboss.arquillian.container.se.managed.ManagedSEDeployableContainer.materializeArchive(ManagedSEDeployableContainer.java:294) at org.jboss.arquillian.container.se.managed.ManagedSEDeployableContainer.deploy(ManagedSEDeployableContainer.java:191)
This didn’t make any sense as the output directories were all writeable etc. I had another similar project that worked. Comparing both projects, I eventually added a barebones arquillian.xml config file. That did the trick! The magic appears toe be the deploymentExportPath – not sure why this is needed.
<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> <engine> <property name="deploymentExportPath">target/deployments</property> </engine> </arquillian><span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>
Background on project:
- Gradle build
- Arquillian dependencies:
- org.jboss.arquillian:arquillian-bom:1.4.0.Final
- org.jboss.arquillian.junit:arquillian-junit-container:1.4.0.Final
- org.jboss.arquillian.container:container-se-managed:1.0.2.Final