You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Martin McCallion (Created) (JIRA)" <xm...@xml.apache.org> on 2012/01/27 16:00:11 UTC
[jira] [Created] (XMLBEANS-478) NullPointerException in
SchemaType.getEnumJavaClass
NullPointerException in SchemaType.getEnumJavaClass
---------------------------------------------------
Key: XMLBEANS-478
URL: https://issues.apache.org/jira/browse/XMLBEANS-478
Project: XMLBeans
Issue Type: Bug
Components: XmlObject, XPath
Affects Versions: Version 2
Reporter: Martin McCallion
Priority: Minor
I have code like this, where currentElement is an XmlObject:
// Check whether we're dealing with an enumeration.
Class fieldClass;
SchemaType t = currentElement.schemaType();
if (t.getEnumJavaClass() != null) // According the JavaDoc, should return null if it's not an enum.
{
fieldClass = currentElement.schemaType().getEnumJavaClass();
}
else
{
fieldClass = currentElement.getClass();
}
This throws a NullPointerException as follows:
[27/01/12 14:02:27:526 GMT] 00000030 SystemOut O E Exception caught within struts
java.lang.NullPointerException
at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.getEnumJavaClass(SchemaTypeImpl.java:1835)
at com.misys.meridian.runtime.message.XmlMessageImpl.setFieldValue(XmlMessageImpl.java:711)
at com.misys.meridian.runtime.message.XmlMessageImpl.setField(XmlMessageImpl.java:950)
at com.misys.meridian.runtime.message.XmlMessageImpl.setField(XmlMessageImpl.java:989)
...
I found source for SchemaTypeImpl here: http://www.docjar.com/html/api/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java.html. The method in question looks like this (line numbers provided at that link):
1829 public Class getEnumJavaClass()
1830 {
1831 // This field is declared volatile and Class is immutable so this is allowed.
1832 if (_javaEnumClass == null)
1833 {
1834 try
1835 { _javaEnumClass = Class.forName(getBaseEnumType().getFullJavaName() + "$Enum", false, getTypeSystem().getClassLoader()); }
1836 catch (ClassNotFoundException e)
1837 { _javaEnumClass = null; }
1838 }
1839
1840 return _javaEnumClass;
1841 }
Line 1835 could NPE if getBaseEnumType() returns null. And indeed, elsewhere in the same class we see:
1465 public SchemaType getBaseEnumType()
1466 {
1467 return _baseEnumTyperef == null ? null : _baseEnumTyperef.get();
1468 }
Which suggests that that is exactly what's happening.
It is, of course, possible that I have done something wrong in creating my generated classes, such that they are missing some necessary data. But if that is so, there ought to be a more informative Exception. And note that the classes were generated using scomp from an ISO20022 schema.
I'm working around this by checking for a null return on getEnumerationValues() instead.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
[jira] [Commented] (XMLBEANS-478) NullPointerException in
SchemaType.getEnumJavaClass
Posted by "Cezar Andrei (Commented) (JIRA)" <xm...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XMLBEANS-478?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13202942#comment-13202942 ]
Cezar Andrei commented on XMLBEANS-478:
---------------------------------------
Fixed with rev: 1241699. Thanks for your contribution Martin.
> NullPointerException in SchemaType.getEnumJavaClass
> ---------------------------------------------------
>
> Key: XMLBEANS-478
> URL: https://issues.apache.org/jira/browse/XMLBEANS-478
> Project: XMLBeans
> Issue Type: Bug
> Components: XmlObject, XPath
> Affects Versions: Version 2
> Reporter: Martin McCallion
> Assignee: Cezar Andrei
> Priority: Minor
> Labels: nullpointerexception
>
> I have code like this, where currentElement is an XmlObject:
> // Check whether we're dealing with an enumeration.
> Class fieldClass;
> SchemaType t = currentElement.schemaType();
> if (t.getEnumJavaClass() != null) // According the JavaDoc, should return null if it's not an enum.
> {
> fieldClass = currentElement.schemaType().getEnumJavaClass();
> }
> else
> {
> fieldClass = currentElement.getClass();
> }
> This throws a NullPointerException as follows:
> [27/01/12 14:02:27:526 GMT] 00000030 SystemOut O E Exception caught within struts
> java.lang.NullPointerException
> at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.getEnumJavaClass(SchemaTypeImpl.java:1835)
> at com.misys.meridian.runtime.message.XmlMessageImpl.setFieldValue(XmlMessageImpl.java:711)
> at com.misys.meridian.runtime.message.XmlMessageImpl.setField(XmlMessageImpl.java:950)
> at com.misys.meridian.runtime.message.XmlMessageImpl.setField(XmlMessageImpl.java:989)
> ...
> I found source for SchemaTypeImpl here: http://www.docjar.com/html/api/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java.html. The method in question looks like this (line numbers provided at that link):
> 1829 public Class getEnumJavaClass()
> 1830 {
> 1831 // This field is declared volatile and Class is immutable so this is allowed.
> 1832 if (_javaEnumClass == null)
> 1833 {
> 1834 try
> 1835 { _javaEnumClass = Class.forName(getBaseEnumType().getFullJavaName() + "$Enum", false, getTypeSystem().getClassLoader()); }
> 1836 catch (ClassNotFoundException e)
> 1837 { _javaEnumClass = null; }
> 1838 }
> 1839
> 1840 return _javaEnumClass;
> 1841 }
>
> Line 1835 could NPE if getBaseEnumType() returns null. And indeed, elsewhere in the same class we see:
> 1465 public SchemaType getBaseEnumType()
> 1466 {
> 1467 return _baseEnumTyperef == null ? null : _baseEnumTyperef.get();
> 1468 }
> Which suggests that that is exactly what's happening.
> It is, of course, possible that I have done something wrong in creating my generated classes, such that they are missing some necessary data. But if that is so, there ought to be a more informative Exception. And note that the classes were generated using scomp from an ISO20022 schema.
> I'm working around this by checking for a null return on getEnumerationValues() instead.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
[jira] [Resolved] (XMLBEANS-478) NullPointerException in
SchemaType.getEnumJavaClass
Posted by "Cezar Andrei (Resolved) (JIRA)" <xm...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XMLBEANS-478?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Cezar Andrei resolved XMLBEANS-478.
-----------------------------------
Resolution: Fixed
> NullPointerException in SchemaType.getEnumJavaClass
> ---------------------------------------------------
>
> Key: XMLBEANS-478
> URL: https://issues.apache.org/jira/browse/XMLBEANS-478
> Project: XMLBeans
> Issue Type: Bug
> Components: XmlObject, XPath
> Affects Versions: Version 2
> Reporter: Martin McCallion
> Assignee: Cezar Andrei
> Priority: Minor
> Labels: nullpointerexception
>
> I have code like this, where currentElement is an XmlObject:
> // Check whether we're dealing with an enumeration.
> Class fieldClass;
> SchemaType t = currentElement.schemaType();
> if (t.getEnumJavaClass() != null) // According the JavaDoc, should return null if it's not an enum.
> {
> fieldClass = currentElement.schemaType().getEnumJavaClass();
> }
> else
> {
> fieldClass = currentElement.getClass();
> }
> This throws a NullPointerException as follows:
> [27/01/12 14:02:27:526 GMT] 00000030 SystemOut O E Exception caught within struts
> java.lang.NullPointerException
> at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.getEnumJavaClass(SchemaTypeImpl.java:1835)
> at com.misys.meridian.runtime.message.XmlMessageImpl.setFieldValue(XmlMessageImpl.java:711)
> at com.misys.meridian.runtime.message.XmlMessageImpl.setField(XmlMessageImpl.java:950)
> at com.misys.meridian.runtime.message.XmlMessageImpl.setField(XmlMessageImpl.java:989)
> ...
> I found source for SchemaTypeImpl here: http://www.docjar.com/html/api/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java.html. The method in question looks like this (line numbers provided at that link):
> 1829 public Class getEnumJavaClass()
> 1830 {
> 1831 // This field is declared volatile and Class is immutable so this is allowed.
> 1832 if (_javaEnumClass == null)
> 1833 {
> 1834 try
> 1835 { _javaEnumClass = Class.forName(getBaseEnumType().getFullJavaName() + "$Enum", false, getTypeSystem().getClassLoader()); }
> 1836 catch (ClassNotFoundException e)
> 1837 { _javaEnumClass = null; }
> 1838 }
> 1839
> 1840 return _javaEnumClass;
> 1841 }
>
> Line 1835 could NPE if getBaseEnumType() returns null. And indeed, elsewhere in the same class we see:
> 1465 public SchemaType getBaseEnumType()
> 1466 {
> 1467 return _baseEnumTyperef == null ? null : _baseEnumTyperef.get();
> 1468 }
> Which suggests that that is exactly what's happening.
> It is, of course, possible that I have done something wrong in creating my generated classes, such that they are missing some necessary data. But if that is so, there ought to be a more informative Exception. And note that the classes were generated using scomp from an ISO20022 schema.
> I'm working around this by checking for a null return on getEnumerationValues() instead.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
[jira] [Assigned] (XMLBEANS-478) NullPointerException in
SchemaType.getEnumJavaClass
Posted by "Cezar Andrei (Assigned) (JIRA)" <xm...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XMLBEANS-478?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Cezar Andrei reassigned XMLBEANS-478:
-------------------------------------
Assignee: Cezar Andrei
> NullPointerException in SchemaType.getEnumJavaClass
> ---------------------------------------------------
>
> Key: XMLBEANS-478
> URL: https://issues.apache.org/jira/browse/XMLBEANS-478
> Project: XMLBeans
> Issue Type: Bug
> Components: XmlObject, XPath
> Affects Versions: Version 2
> Reporter: Martin McCallion
> Assignee: Cezar Andrei
> Priority: Minor
> Labels: nullpointerexception
>
> I have code like this, where currentElement is an XmlObject:
> // Check whether we're dealing with an enumeration.
> Class fieldClass;
> SchemaType t = currentElement.schemaType();
> if (t.getEnumJavaClass() != null) // According the JavaDoc, should return null if it's not an enum.
> {
> fieldClass = currentElement.schemaType().getEnumJavaClass();
> }
> else
> {
> fieldClass = currentElement.getClass();
> }
> This throws a NullPointerException as follows:
> [27/01/12 14:02:27:526 GMT] 00000030 SystemOut O E Exception caught within struts
> java.lang.NullPointerException
> at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.getEnumJavaClass(SchemaTypeImpl.java:1835)
> at com.misys.meridian.runtime.message.XmlMessageImpl.setFieldValue(XmlMessageImpl.java:711)
> at com.misys.meridian.runtime.message.XmlMessageImpl.setField(XmlMessageImpl.java:950)
> at com.misys.meridian.runtime.message.XmlMessageImpl.setField(XmlMessageImpl.java:989)
> ...
> I found source for SchemaTypeImpl here: http://www.docjar.com/html/api/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java.html. The method in question looks like this (line numbers provided at that link):
> 1829 public Class getEnumJavaClass()
> 1830 {
> 1831 // This field is declared volatile and Class is immutable so this is allowed.
> 1832 if (_javaEnumClass == null)
> 1833 {
> 1834 try
> 1835 { _javaEnumClass = Class.forName(getBaseEnumType().getFullJavaName() + "$Enum", false, getTypeSystem().getClassLoader()); }
> 1836 catch (ClassNotFoundException e)
> 1837 { _javaEnumClass = null; }
> 1838 }
> 1839
> 1840 return _javaEnumClass;
> 1841 }
>
> Line 1835 could NPE if getBaseEnumType() returns null. And indeed, elsewhere in the same class we see:
> 1465 public SchemaType getBaseEnumType()
> 1466 {
> 1467 return _baseEnumTyperef == null ? null : _baseEnumTyperef.get();
> 1468 }
> Which suggests that that is exactly what's happening.
> It is, of course, possible that I have done something wrong in creating my generated classes, such that they are missing some necessary data. But if that is so, there ought to be a more informative Exception. And note that the classes were generated using scomp from an ISO20022 schema.
> I'm working around this by checking for a null return on getEnumerationValues() instead.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org