![]() |
| ||
| Class.forName(String ClassName) throwing ClassNotFoundException Hi, My code below :) - Quote:
I go this in the sun's documentation as :-/ => ----------------------------------------------------------------------------- forName Throws: LinkageError - if the linkage fails ExceptionInInitializerError - if the initialization provoked by this method fails ClassNotFoundException - if the class cannot be located ----------------------------------------------------------------------------- So it means if the jvm could not locate the class then it wil throw the class not found exception, but here i can i created the class ans can also see the compiled clasfile for the same, that too in proper directory. So plz help me toi figure out the reason behind this, which has stopped my development work completely.:'( Thanks & regards, Multicoder |
| ||
| Re: Class.forName(String ClassName) throwing ClassNotFoundException The class was loaded in another ClassLoader, seemingly, and now you are trying to load it using the context classloader. That doesn't work. The thread that is doing this will need to use the setContextClassLoader (see Thread) method, and the getClass().getClassLoader() method of the "loaded" class. Then this should work. The real question is, though, why do you need the Class at this point? If this is some sort of plugin architecture, then I can only assume that this Class (the one that is attempting to load the other), is part of the "framework". And, if that is so, it should only be working within the defined interface that the plugin is to adhere to. |
| ||
| Re: Class.forName(String ClassName) throwing ClassNotFoundException thnx masijade! the first immediate and nice reply i got!! I was suspecting it got something to do with classloader, but not sure how to handle this one. Plz look for the post here,m trying to think as u say... |
| ||
| Re: Class.forName(String ClassName) throwing ClassNotFoundException Hi, I checked with setContextClassLoader(), but to tel u i m not creating any extra thread. Only the main thread running all around the execution and the class for which i am trying to load is part of the application framework, But which class to load is passed as cmd param and accordignly need to create the object of that class. So I cant figure out any issue with the class loader..?? plz clarify me...! |
| ||
| Re: Class.forName(String ClassName) throwing ClassNotFoundException Change that catch block to also do a printStackTrace() and then post the complete exception. Also post the "classpath" in use (most likely not the System classpath). Then also post the full path to the class to be loaded. |
| |||
| Re: Class.forName(String ClassName) throwing ClassNotFoundException hi, I believe the exception.printStackTrace() prints the the contents of the system.err to the standard error output system i.e. to cmd so is this right?then this is my output on cmd - Quote:
Quote:
Quote:
waiting for ur reply |
| ||
| Re: Class.forName(String ClassName) throwing ClassNotFoundException Error: Failed to load parserConfigImpl [au.com.allhomes.listing.harvester.parse. Maybe the au. is significant? |
| ||
| Re: Class.forName(String ClassName) throwing ClassNotFoundException The au is definately significant, but the stuff printed is neither the "printstacktrace" that was asked for, nor the classpath, nor the fullpath to the classfile. @OP before you start playing around with classloaders and reflection learn what the classpath is, and how to use it, and learn the "tools" (i.e. java and javac) and the options (and their effects) that affect the classpath. |
| ||
| Re: Class.forName(String ClassName) throwing ClassNotFoundException Quote:
The au seem to be significant here because my mistake in providing the package structure, but its not actually! I configured the project in netbeans again to see it holds the parent directory "au" also. So 'au' is the parent directory for all and inside it starts from 'com'. I executed again but got the same exception. Quote:
I know very wel abt both the tools but m not executing it from netbeans so that i can set the parameters i need to pass each time easily. So at the cmd only moving to project's source directory (which is C:\Harvester) where the netbeans is putting compiled code and not playing around with the classapth. I know the significance of classpath. Plz correct me further?:idea: |
| ||
| Re: Class.forName(String ClassName) throwing ClassNotFoundException Don't know about netbeans, but eclipse uses its own class loader and causes all kinds of problems like yours - except that the prog runs OK if executed via java or javaw. Maybe worth trying outside netbeans? |
| All times are GMT -4. The time now is 2:21 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC