[jboss-user] [JBossWS] - NullPointerException deploying JSR 181 EJB3 endpoint

mrooney do-not-reply at jboss.com
Wed Oct 4 19:04:31 EDT 2006


I'm using JBoss 4.0.4 GA with EJB3-RC9-FD and JBossWS 1.0.3. NPE is thrown by org.jboss.ws.tools.schema.SchemaTypeCreator.java:578 during deployment. 

After digging through the code I found Introspector, BeanInfo and PropertyDescriptor were causing the problem while analyzing one of my EJB methods. The method signature is:

  | public MyComplexType getMyComplexType();
  | 

This apparently causes the Introspector to analyze the MyComplexType class which contains a method with the signature:

  | public int getCodeCount(int type);
  | 
The BeanInfo then contains a PropertyDescriptor with the name "codeCount" but the PropertyDescriptor.getPropertyType() method returns null. As per the javadoc, this method may return null if this is an indexed property that does not support non-indexed access.  However, the return value is not checked before it is used.

In short, SchemaTypeCreator.java line 578 should be changed from:

  |          if (fieldType.equals(ParameterWrapping.WrapperType.class))
  | 
to:

  |          if (fieldType != null && fieldType.equals(ParameterWrapping.WrapperType.class))
  |             continue;
  | 

The following is a complete class that demonstrates the problem using the relevant code taken directly from SchemaTypeCreator.java:

  | import java.beans.BeanInfo;
  | import java.beans.Introspector;
  | import java.beans.PropertyDescriptor;
  | 
  | import javax.ejb.SessionBean;
  | 
  | public class TestIt
  | {
  |    public int getCodeCount(int type)
  |    {
  |       return 1;
  |    }
  |    
  |    public static void main(String[] args)
  |    {
  |       try {
  | 
  |          Class javaType = TestIt.class;
  |          
  |          // taken from SchemaTypeCreator.java
  | 
  |          BeanInfo beanInfo = Introspector.getBeanInfo(javaType, Object.class);
  |          PropertyDescriptor[] props = beanInfo.getPropertyDescriptors();
  |          int len = props != null ? props.length : 0;
  | 
  |          for (int i = 0; i < len && SessionBean.class.isAssignableFrom(javaType) == false; i++)
  |          {
  |             PropertyDescriptor prop = props;
  |             String fieldname = prop.getName();
  |             Class fieldType = prop.getPropertyType();
  | 
  |             // End of borrowed code...the next line throws NPE
  | 
  |             System.out.println(fieldType.getName());
  |          }
  | 
  |       } catch(Exception ex) {
  |          ex.printStackTrace();
  |       }
  |    }
  | }
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976192#3976192

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976192



More information about the jboss-user mailing list