Details
-
Bug
-
Resolution: Done
-
Major
-
JBossAS-5.0.0.CR2
-
None
Description
Copying from: JBAS-5673
Stan Silvert - 28/Sep/08 04:54 PM
I'm reopening this because the fix can cause a NPE for JSF managed beans. I changed the JSF integration test in the testsuite. If you run org.jboss.test.web.test.JSFIntegrationTestCase you will see the NPE.
I used a JButton as a managed bean in faces-config.xml like this:
<managed-bean>
<description>Use a swing JButton as a simple javabean</description>
<managed-bean-name>myJButton</managed-bean-name>
<managed-bean-class>javax.swing.JButton</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>text</property-name>
<value>Initial Value</value>
</managed-property>
</managed-bean>
Note that this is an odd example. I'm not actually using JButton for anything other than the fact that I can use it as a holder to getText()/setText(). But it is perfectly valid to use a JDK class for this purpose.
The NPE is in TomcatInjectionContainer.isDymanicBean() where it says:
// Check if the object was loaded by a dynamic class loader (e.g. Jasper)
String classLoaderName = object.getClass().getClassLoader().getClass().getName();
if(dynamicClassLoaders.contains(classLoaderName))
return true;
Since JButton is loaded by the bootstrap classloader, object.getClass().getClassLoader() will return null and you get a NPE.