Ok thanks for that. I tried your suggestion and gotten to at least load the classes. Now I get InvocationTargetException on the ThirdPartyLauncher.
I talked to the thirdparty support guy and he said there is a way to force their ThirdPartyLauncher classloader to not load my classes by providing mypackage prefix on the command line argument to jvm (really bad in my oponion). Guess what, I tried their suggestion NOT using avalon framework and got the InvocationTargetException. I also tried it, WITHOUT your suggested changes outside of avalon framework, providing the command line argument they suggested, and got ClassNotFoundException. So now I am thinking that their class loader must be doing something funky and unexpected. They assured me that if their class loader can't find my classes, then it would delegate to the parent classloader which should be the default system classloader(CLASSPATH). This doesn't seem to be the case as I am certain that my build directory which contains my classes(non jar format) is in the CLASSPATH. I saw this posting about OpenEJB doing some funky things with their class loader which resulted in the same problem for the poster: http://www.mail-archive.com/[email protected]/msg01387.html except the poster had the luxary of being able to look at the source. I on the other hand can only take their word for it since it is proprietery software. I'll post again once I find out more info from their support. I gave them a distribution that demonstrates my problem and nullifies their recommendation. thanks again. k. On Sun, 2003-02-16 at 23:30, Peter Donald wrote: > Hi, > > On Sun, 16 Feb 2003 18:04, Korosh Afshar wrote: > > |--SAR/lib/myclasses.jar > > |--SAR/lib/thirdparty.jar > > |--SAR/lib/someotherstuff.jar > > |--SAR/assembly.xml > > |--SAR/environment.xml > > |--SAR/config.xml > > The first thing you need to do is place the classes you want to load in a > custom loader in a new location in the .sar file. I would recomend that you > layout your jar like; > > |--SAR-INF/lib/someotherstuff.jar > |--SAR-INF/assembly.xml > |--SAR-INF/environment.xml > |--SAR-INF/config.xml > |--lib/myclasses.jar > |--lib/thirdparty.jar > > (Note that myclasses.jar and thirdparty.jar are in separate lib directory). > > And then in your code you do something like; > > final File base = getBlockContext().getBaseDirectory(); > final URL url1 = new File( base, "lib/myclasses.jar" ).toURL(); > final URL url2 = new File( base, "lib/thirdparty.jar" ).toURL(); > ClassLoader loader = new URLClassLoader( new URL[] {url1, url2} ); > > Class launcher = loader.loadClass( "com.biz.ThirdPartyClassLauncher" ); > Method method = launcher.getMethod( "main", new Class[] { String.class } ); > method.invoke( null, "mypackage.MyClassB" ); > > So the above will create a new ClassLoader that does not have any parent > classloaders (which may fix the problems you are experiencing). It then loads > the launcher class and uses reflection to call appropriate method. > > Without knowing more details about your specifics it is difficult to guess > what else to do. Feel free to ask more here or directly if there is something > else I can help with. > > -- > Cheers, > > Peter Donald > --------------------------------------------------------- > Clarke's Third Law: "Any technology distinguishable from > magic is insufficiently advanced". > --------------------------------------------------------- > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
