简体   繁体   中英

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

i am geting this strange exception below:

INFO: Deploying web application archive ZangV3Spring.war
10-Sep-2010 08:46:38 org.apache.catalina.startup.ContextConfig init
SEVERE: Exception fixing docBase for context [/ZangV3Spring] 
java.util.zip.ZipException: error in opening zip file
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:114)
    at java.util.jar.JarFile.<init>(JarFile.java:135)
    at java.util.jar.JarFile.<init>(JarFile.java:72)
    at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:72)
    at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:48)
    at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:80)
    at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:104)
    at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:71)
    at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:110)
    at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:709)
    at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:838)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:331)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:312)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:292)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:100)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:129)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:785)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:763)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:558)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:987)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:540)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1458)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:338)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1186)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1340)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1349)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1329)
    at java.lang.Thread.run(Thread.java:619)
10-Sep-2010 08:46:38 org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Invalid or unreadable WAR file : error in opening zip file
    at org.apache.naming.resources.WARDirContext.setDocBase(WARDirContext.java:141)
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4432)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4582)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:138)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:785)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:763)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:558)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:987)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:778)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:540)
    at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1458)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:338)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1186)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1340)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1349)
    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1329)
    at java.lang.Thread.run(Thread.java:619)

If i remove this bean from my xml it will build and deploy fine:

<bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
    </bean>

The rest of my xml content is this:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/jee
       http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">

    <!-- http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd -->

    <!-- Config properties files -->



    <!-- Hibernate database stuff -->


    <bean id="fileDownload" class="com.kc.models.FileManipulator"></bean>

    <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>properties/jdbc.properties</value>
            </list>
        </property>
    </bean>


    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="${database.driver}" />
        <property name="url" value="${database.url}" />
        <property name="username" value="${database.user}" />
        <property name="password" value="${database.password}" />
        <property name="maxActive" value="${database.maxConnections}" />
    </bean>

    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
    </bean>



    <!--

    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionsFactory" ref="sessionFactory"></property>
    </bean>


     -->
</beans>

I got this same error when tomcat6 was looking for the war file in the wrong location. IMHO very misleading error message. Changed the configuration to point to the right place and it worked.

Once clear all your .jar associated project and then build them on automatically. Now you can start you jboss server which will resolve your problem. This solved at my end.

True, the .war file my be corrupted... OR you may just need to change the permissions on it. I just ran into this as well. Luckily I was upgrading and had the old .war file to compare to.

had -rw-r--r-- on the old one and -rw-r----- on the new one. A quick:

$ sudo chmod 644 <filename>.war 

fixed it right up.

It appears that your war file is corrupted. Try re-creating it. And try opening it with a zip program (like winrar)

have same erorr, but it second error in log, first:

SEVERE: Exception fixing docBase for context [/readfromnet] java.util.zip.ZipException: error in opening zip file

so, i think that Tomcat begin unzip war before it fully uploaded

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM