maven builds fails inside ubuntu vagrant machine as well as docker instance

I am developing an api using jaxb. The maven build (using jdk-7) works on my local windows machine. Now if I try to build it on my vagrant box (ubuntu/trusty64) after setting up maven and openjdk7 on the vm, I get following error on performing mvn clean install:

java.io.FileNotFoundException (operation not permitted)

  • Jacoco agent - no output
  • Why does pushing a Docker image fail with “dial tcp: lookup cdn-registry-1.docker.io on 192.168.1.1:53: read udp 192.168.1.1:53: i/o timeout”?
  • how to set docker_opts on windows
  • How to create a base CoreOS image and build custom parent images based on it
  • the docker's host machine cannot connect internet
  • Cannot add controller replica to the existing UCP cluster
  • There are in all 5 projects as part of my pom.xml, the first 3 (business and projects) gets built successfully, only the 4th one (which generates the war) file fails with this error when it is trying to generate the war file. Maven was successful in copying other files into the target folder for other projects.

    Also, I am able to do perform maven builds on the same machine without errors on simple java projects (from https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html)

    My guess is the Vagrant Virtualbox VM is not is not able to allocate required resources to JVM but i am clueless on how i could do it. I did try to increase the memory footprint by setting the maven properties on my vm

    export MAVEN_OPTS=”-Xms1024m -Xmx4096m -XX:PermSize=1024m”

    Detailed error:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project '<app>' : Could not copy webapp classes [/usr/src/<app>/target/classes]: /usr/src/<app>/target/<app>-03.00.00.01-SNAPSHOT/WEB-INF/classes/<my-app-src>/rest/config/ResourceConfig.class (Operation not permitted) -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project <my-app>: Could not copy webapp classes [/vagrant_data/<my-app-src>/<my-app>/target/classes]
    [/vagrant_data/<my-app-src>/<my-app>/target/classes]
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:622)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    Caused by: org.apache.maven.plugin.MojoExecutionException: Could not copy webapp classes [/vagrant_data/<my-apps-src>/target/classes]
        at org.apache.maven.plugin.war.packaging.ClassesPackagingTask.performPackaging(ClassesPackagingTask.java:80)
        at org.apache.maven.plugin.war.packaging.WarProjectPackagingTask.handleClassesDirectory(WarProjectPackagingTask.java:207)
        at org.apache.maven.plugin.war.packaging.WarProjectPackagingTask.performPackaging(WarProjectPackagingTask.java:104)
        at org.apache.maven.plugin.war.AbstractWarMojo.buildWebapp(AbstractWarMojo.java:505)
        at org.apache.maven.plugin.war.AbstractWarMojo.buildExplodedWebapp(AbstractWarMojo.java:433)
        at org.apache.maven.plugin.war.WarMojo.performPackaging(WarMojo.java:213)
        at org.apache.maven.plugin.war.WarMojo.execute(WarMojo.java:175)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 more
    Caused by: java.io.FileNotFoundException: /vagrant_data/<my-apps-src>/target/<my-app>-03.00.00.01-SNAPSHOT/WEB-INF/classes/<my-app-src>/rest/config/ResourceConfig.class (Operation not permitted)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:160)
        at org.codehaus.plexus.util.FileUtils.doCopyFile(FileUtils.java:1068)
        at org.codehaus.plexus.util.FileUtils.copyFile(FileUtils.java:1049)
        at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask.copyFile(AbstractWarPackagingTask.java:334)
        at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask$1.registered(AbstractWarPackagingTask.java:154)
        at org.apache.maven.plugin.war.util.WebappStructure.registerFile(WebappStructure.java:207)
        at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask.copyFile(AbstractWarPackagingTask.java:149)
        at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask.copyFiles(AbstractWarPackagingTask.java:104)
        at org.apache.maven.plugin.war.packaging.ClassesPackagingTask.performPackaging(ClassesPackagingTask.java:75)
        ... 27 more
    

  • How does the Docker network feature provide service discovery?
  • Postfix in Docker container can't resolve MX unless it gets restarted once
  • TravisCI Docker Permissions
  • Why did my Docker Container did not work when the container UID is missing on the host?
  • How do you share privileged information with a docker container deployed as a worker on elastic beanstalk?
  • Rethinkdb race conditions creating table
  • One Solution collect form web for “maven builds fails inside ubuntu vagrant machine as well as docker instance”

    it seems that you don’t have permision to write in that folder.
    you could try using chmod 777 . -R in the vagrant shared folder. Also before doing this you could check if you can create a new file in the target directory by “touch target/newFile”.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.