Why would I get ClassCastException when running an applet from the web, but not within the Jbuilder environment?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Simon_Rea
Posted On:   Tuesday, April 15, 2003 08:36 AM

I have a stub application which loads modules on demand using the following code : urlsToLoadFrom = new URL[]{ new URL(strCodeBase) }; myClassLoader = new URLClassLoader(urlsToLoadFrom); Class mainClass = Class.forName(classToLoad, true, myClassLoader); Object obj=(Object)mainClass.newInstance(); Instance = (AppletBase)mainClass.newInstance(); This comes up with a class cast exception casting the new instance as AppletBase (our base class for each module) if you run the app from a web page, but works perfectly if you run the stub from within JBuilder. Does JBuilder use a different paths for loading classes? The interface class defining AppletBase is included in    More>>

I have a stub application which loads modules on demand using the following code :


			
urlsToLoadFrom = new URL[]{ new URL(strCodeBase) };
myClassLoader = new URLClassLoader(urlsToLoadFrom);
Class mainClass = Class.forName(classToLoad, true, myClassLoader);

Object obj=(Object)mainClass.newInstance();
Instance = (AppletBase)mainClass.newInstance();


This comes up with a class cast exception casting the new instance as AppletBase (our base class for each module) if you run the app from a web page, but works perfectly if you run the stub from within JBuilder.


Does JBuilder use a different paths for loading classes? The interface class defining AppletBase is included in each of the module Jar files, as well as the stub Jar file.

   <<Less
About | Sitemap | Contact