-- xxxxxxxxxxxxxxxxxxxxxxxx Scott Stark Chief Technology Officer JBoss Group, LLC xxxxxxxxxxxxxxxxxxxxxxxx
George Icriverzi wrote:
The same problem appears when I try to define the class inline. I don't explicitly use different class loaders.
If the start of the mbean contains :
Thread t; public void start() throws Exception{ finished = false; homesReady = false; forcing = false;
//==========================================================================
t = new Thread(){ //at this line IllegalAccessError is thrown int timeout = delay;
public void run(){
//some code
} //end run()
} //end new Thread()
}//end start()
So I can't use inline or inner classes. Maybe it's am mbeans' issue. I'll try it on a session. And why would this code involve 2 different classLoaders?
Till then, please reply if you have answers.
import java.io.FileInputStream; import java.util.Enumeration; import java.util.Iterator; import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipInputStream;
/** A little utility that displays the contents of composite jars
*
* @author [EMAIL PROTECTED]
* @version $Revision: 1.2 $
*/
public class ListJar
{
static String[] jarSuffixes = {
".jar", ".zip", ".ear", ".war", ".sar"
};
static String jarPrefix = "+- ";
static String entryPrefix = "| ";
static byte[] buffer = new byte[65535];
static boolean showOnlyArchives = false;
static
{
for(int i = 0; i < 10; i ++)
{
jarPrefix += "+- ";
entryPrefix += "| ";
}
}
static boolean isJar(String name)
{
boolean isJar = false;
for(int s = 0; isJar == false && s < jarSuffixes.length; s ++)
{
String suffix = jarSuffixes[s];
isJar |= name.endsWith(suffix);
}
return isJar;
}
static void processEntry(ZipInputStream zis, ZipEntry entry, int level) throws
Exception
{
String name = entry.getName();
boolean isDirectory = entry.isDirectory();
if( isDirectory == true )
return;
// See if this is a jar archive
if( isJar(name) )
{
System.out.print(jarPrefix.substring(0, 3*level));
System.out.println(name+" (archive)");
try
{
ZipInputStream entryZIS = new ZipInputStream(zis);
processJar(entryZIS, ++ level);
}
catch(Exception e)
{
e.printStackTrace();
}
}
else if( name.endsWith("MANIFEST.MF") )
{
System.out.print(entryPrefix.substring(0, 3*(level-1)));
System.out.print("+- ");
System.out.print(name);
Manifest mf = new Manifest(zis);
Attributes main = mf.getMainAttributes();
String cp = main.getValue(Attributes.Name.CLASS_PATH);
if( cp != null )
{
System.out.print(" Class-Path: ");
System.out.print(cp);
System.out.print(' ');
}
System.out.println();
}
else if( showOnlyArchives == false )
{
System.out.print(entryPrefix.substring(0, 3*(level-1)));
System.out.print("+- ");
System.out.println(name);
}
}
static void processJar(ZipInputStream zis, int level) throws Exception
{
ZipEntry entry;
while( (entry = zis.getNextEntry()) != null )
{
processEntry(zis, entry, level);
}
}
/** List the jar contents
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception
{
String name = args[0];
JarFile jarFile = new JarFile(name);
Manifest mf = jarFile.getManifest();
FileInputStream fis = new FileInputStream(name);
ZipInputStream zis = new ZipInputStream(fis);
System.out.println(name);
processJar(zis, 1);
System.out.println("Done");
}
}
