Java.util.zip.ZipException: error in opening zip file

I’m getting this during “gradle build” with Gradle 1.6:

Unable to obtain resource from C:\Users\ask\.gradle\caches\artifacts-24\filestore\javax.xml\saaj-api.3\pom\c1a67ab98154ee9a2068b5d3c8b7dbfe120441d\s
aaj-api-1.3.pom: java.util.zip.ZipException: error in opening zip file
Unable to obtain resource from C:\Users\ask\.gradle\caches\artifacts-24\filestore\javax.xml\saaj-api.3\pom\c1a67ab98154ee9a2068b5d3c8b7dbfe120441d\s
aaj-api-1.3.pom: java.util.zip.ZipException: error in opening zip file
:webui:widgetset FAILED

I see this dependency in one of my build.gradle files:

compile(group: ‘javax.xml’, name: ‘saaj-api’, version: ‘1.3’, ext: ‘pom’) {

transitive = true

}

and here’s my webui/build.gradle script:

/*
  Can also use this Vaadin plugin. See https://github.com/johndevs/gradle-vaadin-plugin#readme
  apply from: 'http://plugins.jasoft.fi/vaadin.plugin'
  vaadin {
    version = vaadinVersion
    widgetset = 'com.taskadapter.webui.widgetset.Vaadin1Widgetset'
}
   */
apply plugin: 'war'
  dependencies {
    compile "org.apache.httpcomponents:httpclient:$httpClientVersion"
    compile "org.apache.httpcomponents:httpcore:$httpClientVersion"
      compile "com.vaadin:vaadin-server:$vaadinVersion"
    compile "com.vaadin:vaadin-client-compiled:$vaadinVersion"
    compile "com.vaadin:vaadin-themes:$vaadinVersion"
    compile 'org.vaadin.addons:googleanalyticstracker:2.0.0'
      // for widgetset compilation
    compile "com.vaadin:vaadin-client-compiler:$vaadinVersion"
      compile libraries.slf4j
      compile project(":common")
    compile project(":mainapp")
    compile project(":webshared")
      compile project(":connectors:connector-msp")
      compile project(":connectors-editors:basecamp-editor")
    compile project(":connectors-editors:github-editor")
    compile project(":connectors-editors:jira-editor")
    compile project(":connectors-editors:mantis-editor")
    compile project(":connectors-editors:msp-editor")
    compile project(":connectors-editors:redmine-editor")
      testCompile project(":test-utilities")
}
  dependencies{
    compile group:'com.google.gwt',
   name:'gwt-user',
  version:'2.5.0'
    compile group:'com.google.gwt',
   name:'gwt-dev',
   version:'2.5.0'
}
  ext {
    webAppDirName = "src/main/webapp"
    vaadinDir = webAppDirName + '/VAADIN'
    gwtBuildDir = vaadinDir + '/widgetsets'
    widgetsetClass = 'com.taskadapter.webui.widgetset.Vaadin1Widgetset'
}
  task widgetset << {
    // Create widgetset directory (if needed)
    def created = (new File(gwtBuildDir)).mkdirs()
      // Compile
    ant.java(classname: 'com.google.gwt.dev.Compiler', failOnError: 'yes', /*fork: 'true', */ maxmemory: '1000m')
            {
                classpath {
                    pathElement(path: configurations.compile.asPath)
                    pathElement(path: sourceSets.main.runtimeClasspath.asPath)
                    sourceSets.main.java.srcDirs.each {
                        pathelement(location: it.absolutePath)
                    }
                }
                  arg(line: '-war ' + gwtBuildDir)
                arg(line: '-logLevel INFO')
                arg(line: '-style OBF')
                arg(line: '-localWorkers 2')
                arg(line: widgetsetClass)
  //
              jvmarg(value: '-Djava.awt.headless=true')
//
              jvmarg(value: '-XX:MaxPermSize=256M')
//
              jvmarg(value: '-Xmx500M')
            }
}
  // Require widgetset compilation before WAR is built
war.dependsOn widgetset

Can you please try creating a small self contained build that exhibits the problem that I can run to reproduce.

I was able to reproduce this issue with a very basic setup. just three files, no java source code. let me know if you want me to send you a zip file.

build.gradle (root folder):

ext {
    vaadinVersion = '7.0.5'
}
  subprojects {
      apply plugin: 'java'
      sourceCompatibility = 1.6
    targetCompatibility = 1.6
      repositories {
        mavenCentral()
          maven {
            url 'http://maven.vaadin.com/vaadin-addons'
        }
    }
  }

settings.gradle (root folder)

include "webui"

build.gradle (in “webui” folder)

apply plugin: 'war'
  dependencies {
    providedCompile "javax.servlet:servlet-api:2.4"
    providedCompile "com.vaadin:vaadin-client:$vaadinVersion"
      compile(group: 'javax.xml', name: 'saaj-api', version: '1.3', ext: 'pom') {
        transitive = true
    }
}
  ext {
    webAppDirName = "src/main/webapp"
    gwtBuildDirInWebRoot = 'VAADIN/widgetsets'
    vaadinDir = webAppDirName + '/' + gwtBuildDirInWebRoot
    widgetsetClass = 'my.Vaadin1Widgetset'
}
  dependencies{
    compile group:'com.google.gwt',
   name:'gwt-user',
  version:'2.4.0'
    compile group:'com.google.gwt',
   name:'gwt-dev',
   version:'2.4.0'
}
  task widgetset << {
    // Create widgetset directory (if needed)
    def created = (new File(vaadinDir)).mkdirs()
      // Compile
    ant.java(classname: 'com.google.gwt.dev.Compiler', failOnError: 'yes',
maxmemory: '1000m') //fork: 'true'
            {
                classpath {
                    pathElement(path: configurations.compile.asPath)
                    pathElement(path: sourceSets.main.runtimeClasspath.asPath)
                    sourceSets.main.java.srcDirs.each {
                        pathelement(location: it.absolutePath)
                    }
                }
                  arg(line: '-war ' + vaadinDir)
                arg(line: '-logLevel INFO')
                arg(line: '-style OBF')
                arg(line: '-localWorkers 2')
                arg(line: widgetsetClass)
            }
}
  // Require widgetset compilation before WAR is built
war.dependsOn widgetset

hey guys, any plans to fix this in Gradle 1.7?

same problem with Gradle 1.7 and Gradle 1.8

It’s a bug in your build script. You are putting a POM file (‘group: ‘javax.xml’, name: ‘saaj-api’, version: ‘1.3’, ext: ‘pom’’) on the class path of the ‘java’ Ant task, which can’t deal with this.

interesting… this was ported from the old pom.xml file where it was (apparently) used:

<dependencies>
        <dependency>
            <groupId>com.taskadapter</groupId>
            <artifactId>mantis-java-api</artifactId>
            <version>0.0.5</version>
        </dependency>
          <dependency>
            <groupId>javax.xml</groupId>
            <artifactId>saaj-api</artifactId>
            <version>1.3</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis-jaxrpc</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
            <version>1.5.1</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>commons-discovery</groupId>
            <artifactId>commons-discovery</artifactId>
            <version>0.2</version>
        </dependency>
    </dependencies>

The build and the application distributive seem to work fine without this in build.gradle:

compile(group: 'javax.xml', name: 'saaj-api', version: '1.3', ext: 'pom') {
      transitive = true
  }

so I guess that part was just ported from Maven incorrectly.