java.io.InvalidClassException

调用EJB时出错:
java.io.InvalidClassException: org.dom4j.tree.AbstractNode; local class incompatible: stream classdesc serialVersionUID = 4436254242831845461, local class serialVersionUID = 4188621179618565246
解决:
这个问题出现的原因是ejb客户端和服务端使用的dom4j版本不一致造成的,问题在于如何找到jboss中的dom4j.jar,经查找在C:/jboss-4.0.4.GA/lib目录下有一个dom4j.jar,将该文件换成ear中使用的dom4j-full.jar即可,注意必须重命名为dom4j.jar。
本例通过查找dom4j就可以找到dom4j.jar文件,如果该dom4j.jar名字不明显则找起来就费劲了,所以需要使用工具去找,从网上搜索到一个FindClass.java类实现了从某个目录下查找class文件所在的jar文件的功能,代码如下:
 

import  java.util. * ;

import  java.io. * ;

/** 
 *   

在本地磁盘的jar文件中寻找自己所需要的class

 
 *   

用法,只需要提供本地磁盘路径和所需要的class的全称(包括package等信息)

 
 *   

例如   org.w3c.dom.Document

 
 *   

Copyright:   Copyright   (c)Sinocomm   2002

 
 *   
@author   Gameboy999 
 *   
@version   1.0 
 
*/

public   class  FindClass  {

    
public static int count = 0;

    
public FindClass() {
    }


    
private static void FindClassInLocalSystem(String path, String classname) {
        
if (path.charAt(path.length() - 1!= '/')
            path 
+= '/';
        File file 
= new File(path);
        
if (!file.exists()) {
            System.out
                    .println(
"--------------------------------------------------------");
            System.out
                    .println(
"error:   Path   not   Existed!   Please   Check   it   out!");
            System.out
                    .println(
"--------------------------------------------------------");
            
return;
        }

        String[] filelist 
= file.list();
        
for (int i = 0; i < filelist.length; i++{
            File temp 
= new File(path + filelist[i]);
            
if ((temp.isDirectory() && !temp.isHidden() && temp.exists())) {
                FindClassInLocalSystem(path 
+ filelist[i], classname);
            }
 else {
                
if (filelist[i].endsWith("jar")) {
                    
try {
                        java.util.jar.JarFile jarfile 
= new java.util.jar.JarFile(
                                path 
+ filelist[i]);
                        
for (Enumeration e = jarfile.entries(); e
                                .hasMoreElements();) 
{
                            String name 
= e.nextElement().toString();
                            
if (name.equals(classname)) {
                                System.out
                                        .println(
"--------------------------------------------------------");
                                System.out.println(
"No." + ++FindClass.count);
                                System.out.println(
"jar   package:" + path
                                        
+ filelist[i]);
                                System.out.println(name);
                                System.out
                                        .println(
"--------------------------------------------------------");
                            }

                        }

                    }
 catch (Exception eee) {
                    }

                }

            }

        }


    }


    
static public void main(String[] args) {
        
if (args.length < 2{
            System.out.println(
"Usage:");
            System.out
                    .println(
"the   first   parameter:[path   to   find]   eg.     C:/     d:/Jbuilder       Tip:only   '/'   can   be   used   here");
            System.out
                    .println(
"the   first   parameter:[class   to   find]   eg.   org.w3c.dom.Document");
            
return;
        }

        String absoluteclassname 
= args[1].replace('.''/'+ ".class";

        System.out.println(
"Find   class   [" + args[1+ "]   in   path   ["
                
+ args[0+ "]   results:");
        FindClassInLocalSystem(args[
0], absoluteclassname);
        
if (FindClass.count == 0{
            System.out
                    .println(
"--------------------------------------------------------");
            System.out.println(
"Sorry,No   such   Jar!");
            System.out
                    .println(
"--------------------------------------------------------");
        }

        System.out.println(
"Find   Process   Ended!   Total   Results:"
                
+ FindClass.count);
    }

}

你可能感兴趣的:(J2EE技术)