Dear All,
This chunk of code is working well in my servlet
Class myclass = Class.forName(strMgrApp);
//where strMgrApp actually holds the class TagImportExportMgrApp
TagImportExportMgrApp ob; // any class name
ob = (TagImportExportMgrApp) myclass.newInstance();
oImportExportMgr = (IImportExportMgr) ob;
//IImportExportMgr is interface which TagImportExportMgrApp implements
No runtime error is returned and i can access methods using object
"oImportExportMgr"
But !!!!!!!!!!!!!!!!!!!!!!!!!
whats the problem with this line below :
oImportExportMgr =(IImportExportMgr)
Class.forName(strMgrName).newInstance();
why it generates a runtime error stating :
java.lang.IllegalAccessError: tried to access class
WES.GenericComponents.UploadFile.IImportExportMgr from class
WES.GenericComponents.UploadFile.UploadManager
Any suggestion would be highly obliged
Regards ,
Madni
ricky.clarkson@gmail.com - 19 Dec 2005 19:00 GMT
> java.lang.IllegalAccessError: tried to access class
> WES.GenericComponents.UploadFile.IImportExportMgr from class
> WES.GenericComponents.UploadFile.UploadManager
Try posting a complete test case that we can compile and run, or
examine the API docs for IllegalAccessError:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalAccessError.html
A rebuild will probably fix this.
Of course, you probably didn't paste the exception output properly, so
you probably want to really look at:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalAccessException.html
Note that reflection is generally used to pretend that Java is a
dynamically-typed language. The only valid use I know is for plugins
that are not known about at the time the application is started.