[jboss-jira] [JBoss JIRA] Created: (JBAS-6002) NPE for JSF managed beans.

Emanuel Muckenhuber (JIRA) jira-events at lists.jboss.org
Mon Sep 29 03:06:20 EDT 2008


NPE for JSF managed beans. 
---------------------------

                 Key: JBAS-6002
                 URL: https://jira.jboss.org/jira/browse/JBAS-6002
             Project: JBoss Application Server
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: Web (Tomcat) service
    Affects Versions: JBossAS-5.0.0.CR2
            Reporter: Emanuel Muckenhuber
            Assignee: Emanuel Muckenhuber
             Fix For: JBossAS-5.0.0.GA


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. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list