Issue Details (XML | Word | Printable)

Key: SFOS-927
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: Julio Guijarro
Reporter: Steve Loughran
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
SmartFrog

improve diagnostics on ClassNotFoundExceptions

Created: 28/Jul/08 02:05 PM (BST)   Updated: 04/Feb/09 11:51 AM (GMT)
Component/s: .sfCore
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Issue Links:
Metabug
 

Compatibility: unknown


 Description  « Hide
Because the JVM is so uninformative on ClassNotFoundExceptions, when there is trouble with classpaths, much time can be wasted tracking down the problem.

1. PrimImpl could handle such exceptions by adding in lots more diagnostics.
2., we have a org.smartfrog.services.os.java.LoadClassImpl class to help, but even its diagnostics can be improved.
3. we could have a command line command that could deploy a LoadClass instance to test that a class is present

some ideas for better diagnostics

-Look for the resource, using ClassLoader.findResource() to get (and print) the URL of the .class file -and flagging if that file does not exist
-Advanced: look inside the .class file and get the list of imported classes, then look for every such imported class. This can track down (some) missing dependencies, but is not enough for dependencies of parent/constructed classes.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Olivier Pernet added a comment - 04/Aug/08 12:05 AM (BST)
One annoying instance of this happens when loading a component class that is on the classpath itself, but has a dependency on some other class that isn't.
This gives you a ClassNotFoundException for the first class (even though it is on the classpath), instead of a NoClassDefFoundError for the dependency as it should be.
To reproduce, try for example to load AntWorkflowRun with the sf-ant jar on the classpath, but not the ant jar. Or a Scp component without having the jsch jar.

The LoadClassImpl class only helps when components themselves load classes... which they should do with caution with regard to modularity and the OSGi stuff anyway.
But the problem I was describing is more to do with deployers (even though a quick look at PrimDeployerImpl didn't show a catch(Throwable e) { throw new ClassNotFoundException(e); } that I expected to be the cause of the problem.)
Anyway, I feel like class loading problems often happen when creating component instances, so deployers should be looked at too.