Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 157342 - ClassCastException: java.math.BigDecimal cannot be cast to java.lang.String
ClassCastException: java.math.BigDecimal cannot be cast to java.lang.String
Status: RESOLVED FIXED
Product: xml
Classification: Unclassified
Component: Schema Tools
6.x
Macintosh All
: P3 (vote)
: 6.x
Assigned To: _ alexpetrov
issues@xml
http://statistics.netbeans.org/except...
EXCEPTIONS_REPORT
: NETFIX
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-01-23 00:26 UTC by theshadow27
Modified: 2010-04-20 05:11 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
proposed patch (1.54 KB, patch)
2010-03-30 22:07 UTC, dynamite
Details | Diff
Step1_NewElement.PNG (63.87 KB, image/png)
2010-04-15 19:39 UTC, _ alexpetrov
Details
Step2_NewAttr_MinOccurs.PNG (58.06 KB, image/png)
2010-04-15 19:40 UTC, _ alexpetrov
Details
Step3_MinOccursValue_Ctrl-Space.PNG (53.60 KB, image/png)
2010-04-15 19:40 UTC, _ alexpetrov
Details
Step4_NewAttr_MaxOccurs.PNG (58.93 KB, image/png)
2010-04-15 19:41 UTC, _ alexpetrov
Details
Step5_MaxOccursValue_Ctrl-Space.PNG (53.82 KB, image/png)
2010-04-15 19:42 UTC, _ alexpetrov
Details
show problem (462 bytes, application/xml)
2010-04-16 21:33 UTC, dynamite
Details

Note You need to log in before you can comment on or make changes to this bug.
Description theshadow27 2009-01-23 00:26:05 UTC
Second time this has come up doing the same thing. While manually editing an XSD (XML Schema file; File -> new -> xml -> Schema) after entering text 
between double quotes inserted by the autocomplete, advancing the cursor using the right arrow throws the BigDecimal cast exception. Should be a quick 
fix. JSD

PS: I don't know where this came from but this isn't my stack trace (close thought):
Build: NetBeans IDE 6.5 (Build 200811100001)
VM: Java HotSpot(TM) Client VM, 11.0-b15, Java(TM) SE Runtime Environment, 1.6.0_10-b33
OS: Windows XP, 5.1, x86
User comments: 
STACKTRACE: (first 10 lines)
java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.String
        at org.netbeans.modules.xml.schema.completion.util.CompletionUtil.getAttributeValues(CompletionUtil.java:316)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.getCompletionItems(CompletionQuery.java:122)
        at org.netbeans.modules.xml.schema.completion.CompletionQuery.query(CompletionQuery.java:87)
        at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:218)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
Comment 1 Exceptions Reporter 2009-09-09 21:57:38 UTC
This issue already has 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=144357
Comment 2 Exceptions Reporter 2009-11-10 14:27:06 UTC
This issue already has 13 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=144357
Comment 3 Exceptions Reporter 2009-11-10 14:36:06 UTC
This issue already has 14 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=144357
Comment 4 Sergey Lunegov 2009-11-11 01:28:57 UTC
Alex, please take a look
Comment 5 dynamite 2010-03-30 22:00:16 UTC
I'd like to NetFIX [1] this bug. Is it possible? [1] http://wiki.netbeans.org/NetFIX

The bug seems to be because some attributes such as minOccurs are integers.
Comment 6 dynamite 2010-03-30 22:03:31 UTC
I'd like to NetFIX [1] this bug. Is it possible? [1] http://wiki.netbeans.org/NetFIX

The bug seems to be because some attributes such as minOccurs are integers.
Comment 7 dynamite 2010-03-30 22:07:12 UTC
Created attachment 96386 [details]
proposed patch
Comment 8 Jiri Kovalsky 2010-04-02 10:29:05 UTC
Alex, can you please review & integrate this patch? Thanks a lot!
Comment 9 _ alexpetrov 2010-04-14 18:03:37 UTC
I've looked at the proposed patch - it's very simple and clear.
But before integration of this patch into repository I'd like to reproduce this bug.
Unfortunately now I'm not able to reproduce it on the latest NB 6.9 build (http://smetiste.czech.sun.com/builds/netbeans/trunk/daily/latest).

It seems that the original scenario doesn't work now: "While manually editing an
XSD (XML Schema file; File -> new -> xml -> Schema) after entering text 
between double quotes inserted by the autocomplete, advancing the cursor using
the right arrow throws the BigDecimal cast exception."

I was able to:
1. Create new project, add new XML Schema file and open it
2. In the source editor add new element via code completion (for example, <xsd:element name="Item" minOccurs="0" maxOccurs="unbounded">)
3. Type any values inside "" for all attributes and move the caret to the right by the key [->]

I didn't get any exception.

Please provide a correct scenario for reproducing of this bug.
Comment 10 theshadow27 2010-04-14 19:27:37 UTC
@alexpetrov: I do not see " File -> new -> xml -> Schema" in version 6.8 or 6.1M1. Has this feature been removed?
Comment 11 dynamite 2010-04-14 19:50:38 UTC
Still fails for me against a newly updated and clean main-silver.  Pick say an empty string inside minOccurs="".  Put the caret between the quotes and then ctrl-space.

@theshadow27: You'll need to install the "Xml Schema and WSDL" module to get the new -> xml -> schema.  Note that this module is unusual in that it installs in the IDE's installed directory rather than the user directory and so you'll need to re-install this module every time you install a new version of NB.
Comment 12 theshadow27 2010-04-14 20:09:19 UTC
@dynamite: Thanks - I have installed the plugin on a fresh install of 6.9M1, and I can not reproduce the error either. I did however run up against IZ 181266 while trying to reproduce it (unrelated, AFICT)
Comment 13 _ alexpetrov 2010-04-15 19:38:59 UTC
I've tried to reproduce this bug on the build:
    Product Version: NetBeans IDE Dev (Build 201004140201)
    Java: 1.6.0_18; Java HotSpot(TM) Client VM 16.0-b13
    System: Windows XP version 5.1 running on x86;
(the latest build is available on http://smetiste.czech.sun.com/builds/netbeans/trunk/daily/latest)

I've attached screen shots related to my steps:
1. Create new project (a simple empty Java project), create new XML schema by using the appropriate NB wizard.
   Open this schema in the source editor.
   Add new XML schema element by using code completion (see the screen shot Step1_NewElement.PNG).
2. Add new attribute minOccurs to this element. Put the caret inside quotes ("") and press Ctrl-Space.
   (see screen shots Step2_NewAttr_MinOccurs.PNG, Step3_MinOccursValue_Ctrl-Space.PNG).
3. Add new attribute maxOccurs to this element. Put the caret inside quotes ("") and press Ctrl-Space.
   (see screen shots Step4_NewAttr_MaxOccurs.PNG, Step5_MaxOccursValue_Ctrl-Space.PNG).

I didn't get any exception.   

If you're still able to reproduce this bug, please provide info about:
- used NB build
- all steps for bug reproducing (all details are important, for example, prefixes "xsd:" or "xs:", etc.)
Comment 14 _ alexpetrov 2010-04-15 19:39:53 UTC
Created attachment 97481 [details]
Step1_NewElement.PNG
Comment 15 _ alexpetrov 2010-04-15 19:40:29 UTC
Created attachment 97482 [details]
Step2_NewAttr_MinOccurs.PNG
Comment 16 _ alexpetrov 2010-04-15 19:40:56 UTC
Created attachment 97483 [details]
Step3_MinOccursValue_Ctrl-Space.PNG
Comment 17 _ alexpetrov 2010-04-15 19:41:36 UTC
Created attachment 97484 [details]
Step4_NewAttr_MaxOccurs.PNG
Comment 18 _ alexpetrov 2010-04-15 19:42:07 UTC
Created attachment 97485 [details]
Step5_MaxOccursValue_Ctrl-Space.PNG
Comment 19 _ alexpetrov 2010-04-15 19:44:00 UTC
If you're still able to reproduce this bug, please attach a screen shot with an exception dialog and the related stack trace.
Comment 20 Michel Graciano 2010-04-16 19:41:00 UTC
Well, to try to reproduce it I installed the plugin XML Schema and WSDL from update center. I tried to reproduce it with no success. You need to send us more details about your xsd file to make possible reproduce it. I will continue to try to reproduce but no success for now :(
Comment 21 Michel Graciano 2010-04-16 19:41:27 UTC
Product Version: NetBeans IDE Dev (Build 100416-9f404f994006)
Java: 1.6.0_19; Java HotSpot(TM) Client VM 16.2-b04
System: Linux version 2.6.31-21-generic-pae running on i386; UTF-8; pt_BR (nb)
Comment 22 dynamite 2010-04-16 21:33:02 UTC
Created attachment 97555 [details]
show problem
Comment 23 dynamite 2010-04-16 21:37:59 UTC
I have attached a simplified file that shows the issue for me.  It seems that the element needs to be nested under <xsd:complexType><xsd:all>.  <xsd:sequence> will not show the issue, and hence the difficulty in reproducing it.
Comment 24 _ alexpetrov 2010-04-17 19:55:18 UTC
OK, now I've reproduce this bug on the following XML file:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://xml.netbeans.org/schema/bugXmlSchema"
    xmlns:tns="http://xml.netbeans.org/schema/bugXmlSchema"
    elementFormDefault="qualified">

    <xsd:element name="el">
        <xsd:complexType>
            <xsd:all>
                <xsd:element minOccurs=""/>
            </xsd:all>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

Put the caret inside quotes in the attribute minOccurs="|" and press Ctrl-Space.

Stack trace:
java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.String
	at org.netbeans.modules.xml.schema.completion.util.CompletionUtil.getAttributeValues(CompletionUtil.java:317)
	at org.netbeans.modules.xml.schema.completion.CompletionQuery.getCompletionItems(CompletionQuery.java:125)
	at org.netbeans.modules.xml.schema.completion.CompletionQuery.query(CompletionQuery.java:81)
	at org.netbeans.spi.editor.completion.support.AsyncCompletionTask.run(AsyncCompletionTask.java:220)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1417)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1955)

I'll integrate the proposed patch into the trunk repository on Monday (Apr, 19th).
Comment 25 theshadow27 2010-04-18 17:28:07 UTC
I was also able to duplicate the issue with the "show_problem" code - good test case dynamite!
Comment 26 Jiri Kovalsky 2010-04-19 08:41:22 UTC
Great, so can the patch be applied now? Thanks Alex!
Comment 27 _ alexpetrov 2010-04-19 13:42:56 UTC
Fixed in trunk: http://hg.netbeans.org/main/rev/b5a2509b92cd
Comment 28 Michel Graciano 2010-04-19 16:23:04 UTC
I can reproduce it without the patch with the proposed use case and the Alex push fixed the problem for me.
Comment 29 Jiri Kovalsky 2010-04-19 18:44:01 UTC
Great, thank you Alex for review & integration and special thanks to Daniel for your persistence in giving us a patch and then a scenario it was fixing! :-)
Comment 30 Quality Engineering 2010-04-20 05:11:37 UTC
Integrated into 'main-golden', will be available in build *201004200200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/b5a2509b92cd
User: Alex Petrov <alexpetrov@netbeans.org>
Log: Fix for issue [#157342]. ClassCastException: java.math.BigDecimal cannot be cast to java.lang.String


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo