Title: Programmatically Load Classes and Resources in a Deployment Suggestions for improvement: In the "Load a Class File From the Class Loader" subsection change this: InputStream inputStream = TargetClass.class.getResourceAsStream(TargetClass.class.getSimpleName().replace('.', '/') + ".class"); to: InputStream inputStream = TargetClass.class.getResourceAsStream(TargetClass.class.getCanonicalName().replace('.', '/') + ".class");
This is actually incorrect. It *would* be correct if the left hand argument were a class loader, but because it's a class, it will already search in the class' current directory, thus only the simple name should be given. However this does raise a different issue: the .replace() is not actually needed here because there will never be path separator components.
I will change the example to: InputStream inputStream = TargetClass.class.getResourceAsStream(TargetClass.class.getSimpleName() + ".class");
David reviewed the docbuilder version and said it looks much better. Moving to modified.
This is not yet staged.
@dmlloyde: This can be verified on the Customer Portal: https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/6.2/html-single/Development_Guide/index.html#Programmatically_Load_Classes_and_Resources_in_a_Deployment
Fixed in https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/6.2/html-single/Development_Guide/index.html#Programmatically_Load_Classes_and_Resources_in_a_Deployment Revision 2.0-23