我是靠谱客的博主 迷路夏天,最近开发中收集的这篇文章主要介绍关于WAS当中FFDC报告error in opening zip file剖析及解决,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

 http://yulimin.javaeye.com/blog/299956

 

关于WAS当中FFDC报告java.util.zip.ZipException: error in opening zip file剖析及解决

问题:
WAS下FFDC日志目录中出现如下的错误,打开zip文件错误

Java代码 复制代码
  1. FFDC Exception:java.util.zip.ZipException SourceId:com.ibm.ws.classloader.ClassLoaderUtils.addDependents ProbeId:238 Reporter:java.lang.Class@7c537c91  
  2. java.util.zip.ZipException: error in opening zip file   
  3.     at java.util.zip.ZipFile.open(Native Method)   
  4.     at java.util.zip.ZipFile.<init>(ZipFile.java:114)   
  5.     at java.util.jar.JarFile.<init>(JarFile.java:133)   
  6.     at java.util.jar.JarFile.<init>(JarFile.java:70)   
  7.     at com.ibm.ws.classloader.ClassLoaderUtils.addDependents(ClassLoaderUtils.java:96)   
  8.     at com.ibm.ws.classloader.ClassLoaderUtils.addDependents(ClassLoaderUtils.java:143)   
  9.     at com.ibm.ws.classloader.ClassLoaderUtils.addDependentJars(ClassLoaderUtils.java:61)   
  10.     at com.ibm.ws.classloader.ClassGraph.<init>(ClassGraph.java:115)   
  11.     at com.ibm.ws.classloader.ClassLoaderManager.initialize(ClassLoaderManager.java:202)   
  12.     at com.ibm.ws.classloader.ClassLoaderManager.<init>(ClassLoaderManager.java:166)   
  13.     at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:891)   
  14.     at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:740)   
  15.     at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2092)   
  16.     at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:437)   
  17.     at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:122)   
  18.     at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:380)   
  19.     at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$300(CompositionUnitMgrImpl.java:105)   
  20.     at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:928)   
  21.     at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:349)   
  22.     at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)  
FFDC Exception:java.util.zip.ZipException SourceId:com.ibm.ws.classloader.ClassLoaderUtils.addDependents ProbeId:238 Reporter:java.lang.Class@7c537c91
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:133)
at java.util.jar.JarFile.<init>(JarFile.java:70)
at com.ibm.ws.classloader.ClassLoaderUtils.addDependents(ClassLoaderUtils.java:96)
at com.ibm.ws.classloader.ClassLoaderUtils.addDependents(ClassLoaderUtils.java:143)
at com.ibm.ws.classloader.ClassLoaderUtils.addDependentJars(ClassLoaderUtils.java:61)
at com.ibm.ws.classloader.ClassGraph.<init>(ClassGraph.java:115)
at com.ibm.ws.classloader.ClassLoaderManager.initialize(ClassLoaderManager.java:202)
at com.ibm.ws.classloader.ClassLoaderManager.<init>(ClassLoaderManager.java:166)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:891)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:740)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2092)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:437)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:122)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:380)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$300(CompositionUnitMgrImpl.java:105)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:928)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:349)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)


那到底是哪个文件在打开时发生错误了呢?一头雾水了吧,汗。。。估计你会。。。

分析:
1、通过对文件的排查,确认排除了应用程序中引用jar文件损坏的可能性以及由于jar文件权限设置导致无法读取的可能性

2、打开跟踪日志级别进行剖析

Java代码 复制代码
  1. Application servers > memXXX > Logging and Tracing > Change log detail levels  
Application servers > memXXX > Logging and Tracing > Change log detail levels


设置ClassLoaderUtils跟踪级别如下

Java代码 复制代码
  1. *=info: com.ibm.ws.classloader.ClassLoaderUtils=finest  
*=info: com.ibm.ws.classloader.ClassLoaderUtils=finest


重新启动后,在trace.log里可以发现如下信息

Java代码 复制代码
  1.  0000001e ClassLoaderUt >  addDependents Entry   
  2. /home/xxx/lib/struts/commons-logging.jar   
  3.  0000001e ClassLoaderUt 3   dependent classpath detected: log4j.jar log4j-core.jar   
  4.  0000001e ClassLoaderUt 3   adding /home/xxx/lib/struts/log4j.jar   
  5.  0000001e ClassLoaderUt >  addDependents Entry   
  6. /home/xxx/lib/struts/log4j.jar   
  7.  0000001e FfdcProvider  I com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I: FFDC Incident emitted on /usr/IBM/WebSphere/AppServer/profiles/XXX/logs/ffdc/memXXX_f3c3750_08.12.23_16.26.42.85048008.txt com.ibm.ws.classloader.ClassLoaderUtils.addDependents 238  
  8.  0000001e ClassLoaderUt 3   WARNING: could not open /home/xxx/lib/struts/log4j.jar : error in opening zip file   
  9.  0000001e ClassLoaderUt <  addDependents Exit   
  10. /home/xxx/lib/struts/log4j.jar   
  11.  0000001e ClassLoaderUt 3   adding /home/xxx/lib/struts/log4j-core.jar   
  12.  0000001e ClassLoaderUt >  addDependents Entry   
  13. /home/xxx/lib/struts/log4j-core.jar   
  14.  0000001e ClassLoaderUt 3   WARNING: could not open /home/xxx/lib/struts/log4j-core.jar : error in opening zip file   
  15.  0000001e ClassLoaderUt <  addDependents Exit   
  16. /home/xxx/lib/struts/log4j-core.jar   
  17.  0000001e ClassLoaderUt <  addDependents Exit   
  18. /home/xxx/lib/struts/commons-logging.jar   
  19. ......   
  20.  0000001e ClassLoaderUt >  addDependents Entry   
  21. /home/xxx/lib/struts/struts.jar   
  22.  0000001e ClassLoaderUt 3   dependent classpath detected:  commons-beanutils.jar commons-collections.jar commons-digester.jar commons-logging.jar commons-validator.jar jakarta-oro.jar struts-legacy.jar   
  23.  0000001e ClassLoaderUt 3   adding /home/xxx/lib/struts/jakarta-oro.jar   
  24.  0000001e ClassLoaderUt >  addDependents Entry   
  25. /home/xxx/lib/struts/jakarta-oro.jar   
  26.  0000001e ClassLoaderUt 3   WARNING: could not open /home/xxx/lib/struts/jakarta-oro.jar : error in opening zip file   
  27.  0000001e ClassLoaderUt <  addDependents Exit   
  28. /home/xxx/lib/struts/jakarta-oro.jar   
  29.  0000001e ClassLoaderUt 3   adding /home/xxx/lib/struts/struts-legacy.jar   
  30.  0000001e ClassLoaderUt >  addDependents Entry   
  31. /home/xxx/lib/struts/struts-legacy.jar   
  32.  0000001e ClassLoaderUt 3   WARNING: could not open /home/xxx/lib/struts/struts-legacy.jar : error in opening zip file   
  33.  0000001e ClassLoaderUt <  addDependents Exit   
  34. /home/xxx/lib/struts/struts-legacy.jar   
  35.  0000001e ClassLoaderUt <  addDependents Exit   
  36. ......  
 0000001e ClassLoaderUt >
addDependents Entry
/home/xxx/lib/struts/commons-logging.jar
0000001e ClassLoaderUt 3
dependent classpath detected: log4j.jar log4j-core.jar
0000001e ClassLoaderUt 3
adding /home/xxx/lib/struts/log4j.jar
0000001e ClassLoaderUt >
addDependents Entry
/home/xxx/lib/struts/log4j.jar
0000001e FfdcProvider
I com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I: FFDC Incident emitted on /usr/IBM/WebSphere/AppServer/profiles/XXX/logs/ffdc/memXXX_f3c3750_08.12.23_16.26.42.85048008.txt com.ibm.ws.classloader.ClassLoaderUtils.addDependents 238
0000001e ClassLoaderUt 3
WARNING: could not open /home/xxx/lib/struts/log4j.jar : error in opening zip file
0000001e ClassLoaderUt <
addDependents Exit
/home/xxx/lib/struts/log4j.jar
0000001e ClassLoaderUt 3
adding /home/xxx/lib/struts/log4j-core.jar
0000001e ClassLoaderUt >
addDependents Entry
/home/xxx/lib/struts/log4j-core.jar
0000001e ClassLoaderUt 3
WARNING: could not open /home/xxx/lib/struts/log4j-core.jar : error in opening zip file
0000001e ClassLoaderUt <
addDependents Exit
/home/xxx/lib/struts/log4j-core.jar
0000001e ClassLoaderUt <
addDependents Exit
/home/xxx/lib/struts/commons-logging.jar
......
0000001e ClassLoaderUt >
addDependents Entry
/home/xxx/lib/struts/struts.jar
0000001e ClassLoaderUt 3
dependent classpath detected:
commons-beanutils.jar commons-collections.jar commons-digester.jar commons-logging.jar commons-validator.jar jakarta-oro.jar struts-legacy.jar
0000001e ClassLoaderUt 3
adding /home/xxx/lib/struts/jakarta-oro.jar
0000001e ClassLoaderUt >
addDependents Entry
/home/xxx/lib/struts/jakarta-oro.jar
0000001e ClassLoaderUt 3
WARNING: could not open /home/xxx/lib/struts/jakarta-oro.jar : error in opening zip file
0000001e ClassLoaderUt <
addDependents Exit
/home/xxx/lib/struts/jakarta-oro.jar
0000001e ClassLoaderUt 3
adding /home/xxx/lib/struts/struts-legacy.jar
0000001e ClassLoaderUt >
addDependents Entry
/home/xxx/lib/struts/struts-legacy.jar
0000001e ClassLoaderUt 3
WARNING: could not open /home/xxx/lib/struts/struts-legacy.jar : error in opening zip file
0000001e ClassLoaderUt <
addDependents Exit
/home/xxx/lib/struts/struts-legacy.jar
0000001e ClassLoaderUt <
addDependents Exit
......



继续分析:
首先,可以确认的是WARNING所报的是正确的,因为可以通过确认所依赖的log4j.jar log4j-core.jar jakarta-oro.jar struts-legacy.jar之类的文件不存在。
其次,这些不存在的包是由谁依赖并需要加载的,通过日志的层次关系可以知道,commons-logging.jar需要log4j.jar log4j-core.jar,struts.jar需要jakarta-oro.jar struts-legacy.jar
这样唯一的可能就是各自的jar包中META-INF/MANIFEST.MF里声明了这些jar的依赖关系了。

打开commons-logging.jar,发现其中的META-INF/MANIFEST.MF里包含了
Class-Path: log4j.jar log4j-core.jar

打开struts.jar,发现其中的META-INF/MANIFEST.MF里包含了
Class-Path:  commons-beanutils.jar commons-collections.jar commons-dig
ester.jar commons-logging.jar commons-validator.jar jakarta-oro.jar s
truts-legacy.jar

于是真相大白了,解决的办法要么增加相应版本所依赖的jar包,要么就是简单地删除Class-Path,根据应用程序的需要进行确认并使用之,[color=red]建议用前者进行解决。要么就升级这些组件包。[/color]

代码解读

Java代码 复制代码
  1. ClassLoaderUtils.java   
  2. public static String[] addDependentJars(String paths[])   
  3. {   
  4.     ArrayList newPaths = new ArrayList(Arrays.asList(paths));   
  5.     for(int i = 0; i < paths.length; i++)   
  6.         if(paths[i].toLowerCase().endsWith(".jar"))   
  7.             addDependents(paths[i], newPaths);   
  8.   
  9.     String result[] = new String[newPaths.size()];   
  10.     result = (String[])(String[])newPaths.toArray(result);   
  11.     return result;   
  12. }   
  13.   
  14. private static void addDependents(String jarFileName, List classpath)   
  15. {   
  16. // ...省略。。。   
  17. jar = new JarFile(jarFileName);// 错误在这一行   
  18. manifest = jar.getManifest();   
  19. attrs = manifest.getMainAttributes();   
  20. dependents = attrs.getValue(java.util.jar.Attributes.Name.CLASS_PATH);// 获取依赖包路径   
  21. StringTokenizer tokens = new StringTokenizer(dependents, " ");   
  22. do  
  23. {   
  24.     if(!tokens.hasMoreTokens())   
  25.         break;   
  26.     String nextDependent = tokens.nextToken();   
  27.     String nextDependentFullPath = (new StringBuilder()).append(prefix).append(nextDependent).   
  28.     if(PathUtils.listAddNoDup(classpath, nextDependentFullPath))   
  29.     {   
  30.         addDependents(nextDependentFullPath, classpath); // 迭代加载之   
  31.     }   
  32. while(true);   
  33. // ...省略。。。   
  34. catch代码块中   
  35. catch(ZipException ze)   
  36. {   
  37.     Manager.Ffdc.log(ze, ClassLoaderUtils.class"com.ibm.ws.classloader.ClassLoaderUtils.addDependents""238" + jarFileName);   
  38.     if(debugEnabled)   
  39.         Tr.debug(tc, (new StringBuilder()).append("WARNING: could not open ").append(jarFileName).append(" : ").append(ze.getLocalizedMessage()).toString());   
  40. }   
  41. catch(IOException ioe)   
  42. {   
  43.     Manager.Ffdc.log(ioe, ClassLoaderUtils.class"com.ibm.ws.classloader.ClassLoaderUtils.addDependents""246");   
  44.     if(debugEnabled)   
  45.         Tr.debug(tc, (new StringBuilder()).append("WARNING: I/O exception ").append(jarFileName).append(" : ").append(ioe.getLocalizedMessage()).toString());   
  46. }  
ClassLoaderUtils.java
public static String[] addDependentJars(String paths[])
{
ArrayList newPaths = new ArrayList(Arrays.asList(paths));
for(int i = 0; i < paths.length; i++)
if(paths[i].toLowerCase().endsWith(".jar"))
addDependents(paths[i], newPaths);
String result[] = new String[newPaths.size()];
result = (String[])(String[])newPaths.toArray(result);
return result;
}
private static void addDependents(String jarFileName, List classpath)
{
// ...省略。。。
jar = new JarFile(jarFileName);// 错误在这一行
manifest = jar.getManifest();
attrs = manifest.getMainAttributes();
dependents = attrs.getValue(java.util.jar.Attributes.Name.CLASS_PATH);// 获取依赖包路径
StringTokenizer tokens = new StringTokenizer(dependents, " ");
do
{
if(!tokens.hasMoreTokens())
break;
String nextDependent = tokens.nextToken();
String nextDependentFullPath = (new StringBuilder()).append(prefix).append(nextDependent).
if(PathUtils.listAddNoDup(classpath, nextDependentFullPath))
{
addDependents(nextDependentFullPath, classpath); // 迭代加载之
}
} while(true);
// ...省略。。。
在catch代码块中
catch(ZipException ze)
{
Manager.Ffdc.log(ze, ClassLoaderUtils.class, "com.ibm.ws.classloader.ClassLoaderUtils.addDependents", "238" + jarFileName);
if(debugEnabled)
Tr.debug(tc, (new StringBuilder()).append("WARNING: could not open ").append(jarFileName).append(" : ").append(ze.getLocalizedMessage()).toString());
}
catch(IOException ioe)
{
Manager.Ffdc.log(ioe, ClassLoaderUtils.class, "com.ibm.ws.classloader.ClassLoaderUtils.addDependents", "246");
if(debugEnabled)
Tr.debug(tc, (new StringBuilder()).append("WARNING: I/O exception ").append(jarFileName).append(" : ").append(ioe.getLocalizedMessage()).toString());
}



不厚道,在Manager.Ffdc.log里把jarFileName也打印出来,就更容易知道是什么问题了。
可见打印出有意义的信息对于分析问题是多少的重要。。。


附带信息:将commons-logging.jar与struts.jar与Spring 2.5.5发布所带的包进行对比分析,发现Spring带的commons-logging.jar包没有带有Class-Path这个条目。

Java代码 复制代码
  1. Manifest-Version: 1.0  
  2. Created-By: Apache Ant 1.5.1  
  3. Extension-Name: org.apache.commons.logging   
  4. Specification-Vendor: Apache Software Foundation   
  5. Specification-Version: 1.0  
  6. Implementation-Vendor: Apache Software Foundation   
  7. Implementation-Version: 1.0.3  
  8. Class-Path: log4j.jar log4j-core.jar  
Manifest-Version: 1.0
Created-By: Apache Ant 1.5.1
Extension-Name: org.apache.commons.logging
Specification-Vendor: Apache Software Foundation
Specification-Version: 1.0
Implementation-Vendor: Apache Software Foundation
Implementation-Version: 1.0.3
Class-Path: log4j.jar log4j-core.jar



对比

Java代码 复制代码
  1. Manifest-Version: 1.0  
  2. Archiver-Version: Plexus Archiver   
  3. Created-By: Apache Maven   
  4. Built-By: dlg01   
  5. Build-Jdk: 1.4.2_16   
  6. Implementation-Title: Commons Logging   
  7. Implementation-Vendor: Apache Software Foundation   
  8. Implementation-Vendor-Id: org.apache   
  9. Implementation-Version: 1.1.1  
  10. Specification-Title: Commons Logging   
  11. Specification-Vendor: Apache Software Foundation   
  12. Specification-Version: 1.0  
  13. X-Compile-Source-JDK: 1.2  
  14. X-Compile-Target-JDK: 1.1  
  15. Extension-Name: org.apache.commons.logging  
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: dlg01
Build-Jdk: 1.4.2_16
Implementation-Title: Commons Logging
Implementation-Vendor: Apache Software Foundation
Implementation-Vendor-Id: org.apache
Implementation-Version: 1.1.1
Specification-Title: Commons Logging
Specification-Vendor: Apache Software Foundation
Specification-Version: 1.0
X-Compile-Source-JDK: 1.2
X-Compile-Target-JDK: 1.1
Extension-Name: org.apache.commons.logging



注意实现的版本问题是不同的

struct.jar包的条目内容不同

Java代码 复制代码
  1. Manifest-Version: 1.0  
  2. Created-By: Apache Ant 1.5.1  
  3. Extension-Name: Struts Framework   
  4. Specification-Title: Struts Framework   
  5. Specification-Vendor: Apache Software Foundation   
  6. Specification-Version: 1.1  
  7. Implementation-Title: Struts Framework   
  8. Implementation-Vendor: Apache Software Foundation   
  9. Implementation-Vendor-Id: org.apache   
  10. Implementation-Version: 1.1  
  11. Class-Path:  commons-beanutils.jar commons-collections.jar commons-dig   
  12.  ester.jar commons-logging.jar commons-validator.jar jakarta-oro.jar s   
  13.  truts-legacy.jar  
Manifest-Version: 1.0
Created-By: Apache Ant 1.5.1
Extension-Name: Struts Framework
Specification-Title: Struts Framework
Specification-Vendor: Apache Software Foundation
Specification-Version: 1.1
Implementation-Title: Struts Framework
Implementation-Vendor: Apache Software Foundation
Implementation-Vendor-Id: org.apache
Implementation-Version: 1.1
Class-Path:
commons-beanutils.jar commons-collections.jar commons-dig
ester.jar commons-logging.jar commons-validator.jar jakarta-oro.jar s
truts-legacy.jar



对比

Java代码 复制代码
  1. Manifest-Version: 1.0  
  2. Ant-Version: Apache Ant 1.6.1  
  3. Created-By: 1.3.1_04-b02 (Sun Microsystems Inc.)   
  4. Extension-Name: Struts Framework   
  5. Specification-Title: Struts Framework   
  6. Specification-Vendor: The Apache Software Foundation   
  7. Specification-Version: 1.2.9  
  8. Implementation-Title: Struts Framework   
  9. Implementation-Vendor: The Apache Software Foundation   
  10. Implementation-Vendor-Id: org.apache   
  11. Implementation-Version: 1.2.9  
  12. Class-Path:  commons-beanutils.jar commons-digester.jar commons-fileup   
  13.  load.jar commons-logging.jar commons-validator.jar jakarta-oro.jar  
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.1
Created-By: 1.3.1_04-b02 (Sun Microsystems Inc.)
Extension-Name: Struts Framework
Specification-Title: Struts Framework
Specification-Vendor: The Apache Software Foundation
Specification-Version: 1.2.9
Implementation-Title: Struts Framework
Implementation-Vendor: The Apache Software Foundation
Implementation-Vendor-Id: org.apache
Implementation-Version: 1.2.9
Class-Path:
commons-beanutils.jar commons-digester.jar commons-fileup
load.jar commons-logging.jar commons-validator.jar jakarta-oro.jar


也要注意实现的版本问题是不同的

最后

以上就是迷路夏天为你收集整理的关于WAS当中FFDC报告error in opening zip file剖析及解决的全部内容,希望文章能够帮你解决关于WAS当中FFDC报告error in opening zip file剖析及解决所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(57)

评论列表共有 0 条评论

立即
投稿
返回
顶部