jar - java.lang.ClassCastException: com.ibm.ws.classloader.Handler$ClassLoaderURLConnection incompatible with java.net.JarURLConnection -
how list contents of directory wsjar files?
the code below not working websphere work jboss:
enumeration<url> en = getclass( ).getclassloader( ).getresources( "com/myjars" ); while( en.hasmoreelements( ) ) { url url = en.nextelement( ); if( url.tostring( ).startswith( "jar:file:" ) || url.tostring( ).startswith( "wsjar:file:" ) ) { jarfile jarfile = ( (jarurlconnection)url.openconnection( ) ).getjarfile( ); enumeration<jarentry> eje = jarfile.entries( ); while( eje.hasmoreelements( ) ) { jarentry jarentry = eje.nextelement( ); system.out.println( jarentry.getname( ) ); } } } on websphere, got:
java.lang.classcastexception: com.ibm.ws.classloader.handler$classloaderurlconnection incompatible java.net.jarurlconnection
you might try opening stripping jar:file: url , using zipfile type instead, since you're not interested in jar jar, rather files within jar (which zip file).
so, "jar:file:///foo/bar/baz.jar" becomes "/foo/bar/baz.jar" pass zipfile(string) constructor
Comments
Post a Comment