This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 161033

Summary: [67cat] ClassCastException: org.netbeans.modules.html.editor.gsf.HtmlParserResult
Product: editor Reporter: ki4ngel <ki4ngel>
Component: Parsing & IndexingAssignee: Jan Jancura <jjancura>
Status: RESOLVED FIXED    
Severity: blocker CC: anobbe, blakenzoe, camilo_u, dancehands, dark4832, encripted, georgechongzhi, grafi, hugheba, inkubus08, ivansidorkin, jarod51, jjancura, jkovalsky, jonast, jordao, jvandemerwe, kganfield, laurin1, limptwiglet, lqqkout4elfy, mfukala, microugly, mjreged, mmirilovic, monguz, mpapis, ndwolf, pachico, paulanormannz, pjiricka, pluszak, pribyl, qingyue, rbrink, reynirh, rmatous, robert_h, rohitbrai, salahaa1, sandange, sternix, tprochazka, tslota, typhos, westleyd
Priority: P1 Keywords: RANDOM
Version: 6.x   
Hardware: All   
OS: All   
URL: http://statistics.netbeans.org/exceptions/detail.do?id=148002
Issue Type: DEFECT Exception Reporter: 148002
Attachments: stacktrace
stacktrace
stacktrace
stacktrace
stacktrace
stacktrace
stacktrace
stacktrace
stacktrace

Description ki4ngel 2009-03-24 15:07:56 UTC
Build: NetBeans IDE Dev (Build 200903231401)
VM: Java HotSpot(TM) Client VM, 1.5.0_16-133, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_16-b06-284
OS: Mac OS X, 10.5.6, i386

User Comments:
ndwolf: inserting text in editor



Stacktrace: 
java.lang.ClassCastException: org.netbeans.modules.html.editor.gsf.HtmlParserResult
        at org.netbeans.modules.php.editor.parser.SemanticAnalysis.run(SemanticAnalysis.java:92)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter.process(SemanticHighlighter.java:306)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter.access$000(SemanticHighlighter.java:80)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter$1.run(SemanticHighlighter.java:139)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter$1.run(SemanticHighlighter.java:148)
        at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:128)
Comment 1 ki4ngel 2009-03-24 15:08:12 UTC
Created attachment 78754 [details]
stacktrace
Comment 2 Exceptions Reporter 2009-03-24 17:12:02 UTC
Build: NetBeans IDE Dev (Build 200903231401)
VM: Java HotSpot(TM) Client VM, 11.2-b01, Java(TM) SE Runtime Environment, 1.6.0_12-b04
OS: Linux, 2.6.28.7-blac2-mx-core2, i386

User Comments: 


Stacktrace: 
java.lang.ClassCastException: org.netbeans.modules.html.editor.gsf.HtmlParserResult cannot be cast to org.netbeans.modules.php.editor.parser.PHPParseResult
        at org.netbeans.modules.php.editor.parser.SemanticAnalysis.run(SemanticAnalysis.java:92)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter.process(SemanticHighlighter.java:306)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter.access$000(SemanticHighlighter.java:80)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter$1.run(SemanticHighlighter.java:139)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter$1.run(SemanticHighlighter.java:148)
        at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:128)
Comment 3 Exceptions Reporter 2009-03-24 17:12:11 UTC
Created attachment 78771 [details]
stacktrace
Comment 4 Tomasz Slota 2009-03-24 18:09:53 UTC
Is there anything specific about the file where it occurred? E.g. was it html file renamed to PHP or something like that? Did you customize the mime type 
settings?
Comment 5 ndwolf 2009-03-24 19:05:11 UTC
the file is a phtml with html and a few php lines 
no customized mime.
Comment 6 Tomasz Slota 2009-03-25 05:24:19 UTC
I was just able to reproduce it myself when editing html sections in a regular PHP file.

Upgrading to P2. The exception is related to CLS migration
Comment 7 Marek Fukala 2009-03-25 14:42:48 UTC
I'll look at it.
Comment 8 Marek Fukala 2009-03-25 14:54:28 UTC
Can be either a bug of LanguageRegistry.getInstance().getLanguageByMimeType(mimeType) returning PHPLanguage for
text/html mimetype or more likely an issue in ResultIterator resp. its SourceCache returning a ParserResult not
generated by parser registered to ResultIterator.getSnapshot().getMimeType() mimetype.

I'll add some debug messages. Any steps to reproduce are welcomed!
Comment 9 Marek Fukala 2009-03-25 15:05:41 UTC
debug code added in web-main#e37aeb86d5c1
Comment 10 Tomasz Slota 2009-03-25 19:50:35 UTC
*** Issue 161159 has been marked as a duplicate of this issue. ***
Comment 11 Quality Engineering 2009-03-26 14:28:54 UTC
Integrated into 'main-golden', will be available in build *200903260733* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/e37aeb86d5c1
User: Marek Fukala <mfukala@netbeans.org>
Log: #161033 debug
Comment 12 Marek Fukala 2009-03-26 15:01:59 UTC
*** Issue 161167 has been marked as a duplicate of this issue. ***
Comment 13 Marek Fukala 2009-03-26 15:19:15 UTC
*** Issue 160754 has been marked as a duplicate of this issue. ***
Comment 14 rmatous 2009-03-27 15:59:31 UTC
This issue happened to me and no IllegalStateException was thrown. 
Comment 15 Kenneth Ganfield 2009-03-27 17:16:54 UTC
Build: NetBeans IDE Dev (Build 20090327091525)
VM: Java HotSpot(TM) 64-Bit Server VM, 1.6.0_07-b06-57, Java(TM) SE Runtime Environment, 1.6.0_07-b06-153
OS: Mac OS X, 10.5.6, x86_64

User Comments: 
typing in html document

Stacktrace: 
java.lang.ClassCastException: org.netbeans.modules.css.gsf.api.CssParserResult cannot be cast to org.netbeans.modules.html.editor.gsf.HtmlParserResult
        at org.netbeans.modules.html.editor.gsf.HtmlSemanticAnalyzer.run(HtmlSemanticAnalyzer.java:89)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter.process(SemanticHighlighter.java:315)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter.access$000(SemanticHighlighter.java:80)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter$1.run(SemanticHighlighter.java:148)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter$1.run(SemanticHighlighter.java:157)
        at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:131)
Comment 16 Kenneth Ganfield 2009-03-27 17:17:06 UTC
Created attachment 78989 [details]
stacktrace
Comment 17 Marek Fukala 2009-03-27 17:57:55 UTC
hmm, that means that the CCE happens even if 

resultIterator.getSnapshot().getMimeType().equals(resultIterator.getParserResult().getSnapshot().getMimeType());

Comment 18 Marek Fukala 2009-03-27 18:04:32 UTC
I wonder why the extra message is not logged:

SemanticHiglighter:314:

try {
        task.run(result, null);   //here the CCE happens
    } catch (Exception ex) {
            LOG.log(Level.WARNING, "SemanticAnalyzer = " + 
                    task + "; Language = " + language +
                    " (mimetype = " + language.getMimeType() +
                    "; ParserResult = " + result +
                    "(mimepath = " + result.getSnapshot().getMimePath() + ")", ex);
        }

???

this should log some more info when the CCE happens AFAIK.
Comment 19 encripted 2009-03-27 19:39:05 UTC
t
Comment 20 Marek Fukala 2009-03-27 22:42:11 UTC
mistakenly closed by encripted???
Comment 21 Marek Fukala 2009-03-27 22:44:39 UTC
I just got a user report containing the recently added debug information:

WARNING
[org.netbeans.modules.html.editor.gsf.embedding.CssEmbeddingProvider]:
Unexpected snapshot type: 'text/x-php5'; expecting 'text/html'
WARNING [org.netbeans.modules.csl.hints.infrastructure.HintsTask]
java.lang.ClassCastException:
org.netbeans.modules.html.editor.gsf.HtmlParserResult cannot be cast to
org.netbeans.modules.php.editor.parser.PHPParseResult
    at
org.netbeans.modules.php.editor.verification.PHPHintsProvider.computeHin
ts(PHPHintsProvider.java:133)
...
Comment 22 pribyl 2009-04-01 15:21:39 UTC
Build: NetBeans IDE Dev (Build 200904010000)
VM: Java HotSpot(TM) Client VM, 11.3-b02, Java(TM) SE Runtime Environment, 1.6.0_13-b03
OS: Windows XP, 5.1, x86

User Comments: 
Editing PHP file. To be honest, I dont know exactely what triggered this :-/ I only replaced double quotes for single quote on a line with error

Stacktrace: 
org.netbeans.modules.parsing.spi.ParseException
        at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:190)
        at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:101)
        at org.netbeans.modules.csl.hints.infrastructure.HintsTask.run(HintsTask.java:85)
        at org.netbeans.modules.csl.hints.infrastructure.HintsTask.run(HintsTask.java:71)
        at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:681)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
Comment 23 pribyl 2009-04-01 15:21:49 UTC
Created attachment 79227 [details]
stacktrace
Comment 24 Marek Fukala 2009-04-03 11:36:30 UTC
WARNUNG [org.netbeans.modules.csl.editor.semantic.SemanticHighlighter]: SemanticAnalyzer =
org.netbeans.modules.php.editor.parser.SemanticAnalysis@1e9fcf8; Language =
org.netbeans.modules.csl.core.Language@104ee8[text/x-php5 (mimetype = text/x-php5; ParserResult =
org.netbeans.modules.html.editor.gsf.HtmlParserResult@df28d2(mimepath = MimePath[text/x-php5])

According to the logged debug messages it looks like the problem is that the
HtmlParserResult.getSnapshot().getMimePath() returns (text/x-php5) instead of (.../text/html)

There are also many warnings from both Css and Javascript embeddings providers complaining that the given snapshot is
not of the expected type.

Please not that the embeddings providers are registered to all mimetypes, but the factories creates EP instance only for
text/html snapshot. So the assumption is that subsequent calls to EP.getEmbeddings(Snapshot s) will happen only for
snapshot of the same (text/html) type.

Please also note that most of the reports complains about text/x-php5 mimetype. The PhpEmbeddingProvider is registered
to text/x-php5 mimetype and then the factory.create() method makes EP instances regardless on the given snapshot.

Reassigning to Hanz since this looks like a race condition in parsing.api.

Please looks the recent exception reports messages log, for example:
http://statistics.netbeans.org/exceptions/messageslog?id=185229

The issue is random, but already we have 102 duplicate exception reports.
Comment 25 rohitbrai 2009-04-05 19:26:29 UTC
Build: NetBeans IDE Dev (Build 200904011705)
VM: Java HotSpot(TM) 64-Bit Server VM, 11.0-b16, Java(TM) SE Runtime Environment, 1.6.0_11-b03
OS: Windows Vista, 6.0, amd64

User Comments: 
Editing a comment in HTML file

Stacktrace: 
java.lang.ClassCastException: org.netbeans.modules.css.gsf.api.CssParserResult cannot be cast to org.netbeans.modules.html.editor.gsf.HtmlParserResult
        at org.netbeans.modules.html.editor.gsf.HtmlSemanticAnalyzer.run(HtmlSemanticAnalyzer.java:89)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter.process(SemanticHighlighter.java:315)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter.access$000(SemanticHighlighter.java:80)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter$1.run(SemanticHighlighter.java:148)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter$1.run(SemanticHighlighter.java:157)
        at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:131)
Comment 26 rohitbrai 2009-04-05 19:26:38 UTC
Created attachment 79478 [details]
stacktrace
Comment 27 rohitbrai 2009-04-05 19:29:27 UTC
Build: NetBeans IDE Dev (Build 200904011705)
VM: Java HotSpot(TM) 64-Bit Server VM, 11.0-b16, Java(TM) SE Runtime Environment, 1.6.0_11-b03
OS: Windows Vista, 6.0, amd64

User Comments: 
Editing comment in html file

Stacktrace: 
org.netbeans.modules.parsing.spi.ParseException
        at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:190)
        at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:101)
        at org.netbeans.modules.csl.editor.fold.GsfFoldManager$JavaElementFoldTask.gsfFoldScan(GsfFoldManager.java:377)
        at org.netbeans.modules.csl.editor.fold.GsfFoldManager$JavaElementFoldTask.run(GsfFoldManager.java:353)
        at org.netbeans.modules.csl.editor.fold.GsfFoldManager$JavaElementFoldTask.run(GsfFoldManager.java:298)
        at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:681)
Comment 28 rohitbrai 2009-04-05 19:29:32 UTC
Created attachment 79480 [details]
stacktrace
Comment 29 Marek Fukala 2009-04-06 09:08:53 UTC
*** Issue 161909 has been marked as a duplicate of this issue. ***
Comment 30 Marek Fukala 2009-04-06 09:11:07 UTC
*** Issue 161909 has been marked as a duplicate of this issue. ***
Comment 31 Marek Fukala 2009-04-06 09:11:37 UTC
*** Issue 161909 has been marked as a duplicate of this issue. ***
Comment 32 Tomasz Slota 2009-04-06 09:32:04 UTC
*** Issue 161958 has been marked as a duplicate of this issue. ***
Comment 33 Petr Jiricka 2009-04-06 15:30:25 UTC
Wow, lots of duplicates, I'd say this is a P1.
Comment 34 rmatous 2009-04-06 17:13:03 UTC
Build: NetBeans IDE Dev (Build 090406)
VM: Java HotSpot(TM) Client VM, 1.5.0_16-b02, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_16-b02
OS: Linux, 2.6.24-23-generic, i386

User Comments: 


Stacktrace: 
java.lang.ClassCastException: org.netbeans.modules.html.editor.gsf.HtmlParserResult
        at org.netbeans.modules.php.editor.parser.SemanticAnalysis.run(SemanticAnalysis.java:92)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter.process(SemanticHighlighter.java:315)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter.access$000(SemanticHighlighter.java:80)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter$1.run(SemanticHighlighter.java:148)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter$1.run(SemanticHighlighter.java:157)
        at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:129)
Comment 35 rmatous 2009-04-06 17:13:19 UTC
Created attachment 79548 [details]
stacktrace
Comment 36 Jan Jancura 2009-04-08 09:05:21 UTC
I can not reproduce it. Yes, there are many duplicates. On the other hand - its RANDOM, no data loss. So, P2 is more
accurate, I think.
Comment 37 Jan Jancura 2009-04-08 12:43:50 UTC
*** Issue 161014 has been marked as a duplicate of this issue. ***
Comment 38 Exceptions Reporter 2009-04-09 08:19:50 UTC
This issue has already 250 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=148002
Comment 39 rmatous 2009-04-09 09:36:02 UTC
Happens very often to me. I'm ready to run NB with logging enabled and I'm sure I will be able to trap it very soon
again. So, is it possible to provide some logging aiming to find the cause?
Comment 40 Jan Jancura 2009-04-09 10:08:45 UTC
I have found reproducible usecase, so I will fix it soon. Thanks for your offer.
Comment 41 Jan Jancura 2009-04-09 12:48:08 UTC
looks like its fixed in 0fcec879498e
Comment 42 Erno Mononen 2009-04-09 14:17:46 UTC
*** Issue 161372 has been marked as a duplicate of this issue. ***
Comment 43 Erno Mononen 2009-04-09 14:19:12 UTC
*** Issue 161855 has been marked as a duplicate of this issue. ***
Comment 44 Quality Engineering 2009-04-10 07:34:40 UTC
Integrated into 'main-golden', will be available in build *200904100201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/0fcec879498e
User: Jan Jancura <jjancura@netbeans.org>
Log: #161033:[67cat] ClassCastException: org.netbeans.modules.html.editor
Comment 45 Erno Mononen 2009-04-14 08:56:46 UTC
*** Issue 162483 has been marked as a duplicate of this issue. ***
Comment 46 Ivan Sidorkin 2009-04-18 14:26:51 UTC
Build: NetBeans IDE Dev (Build 200903231401)
VM: Java HotSpot(TM) Client VM, 1.5.0_16-133, Java(TM) 2 Runtime Environment, Standard Edition, 1.5.0_16-b06-284
OS: Mac OS X, 10.5.6, i386

User Comments: 


Stacktrace: 
org.netbeans.modules.parsing.spi.ParseException
        at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:190)
        at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:98)
        at org.netbeans.modules.csl.hints.infrastructure.HintsTask.run(HintsTask.java:85)
        at org.netbeans.modules.csl.hints.infrastructure.HintsTask.run(HintsTask.java:71)
        at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:681)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
Comment 47 Ivan Sidorkin 2009-04-18 14:27:01 UTC
Created attachment 80411 [details]
stacktrace
Comment 48 Kenneth Ganfield 2009-04-24 13:46:52 UTC
Build: NetBeans IDE Dev (Build 200904011705)
VM: Java HotSpot(TM) 64-Bit Server VM, 1.6.0_07-b06-57, Java(TM) SE Runtime Environment, 1.6.0_07-b06-153
OS: Mac OS X, 10.5.6, x86_64

User Comments: 


Stacktrace: 
java.lang.ClassCastException: org.netbeans.modules.css.gsf.api.CssParserResult cannot be cast to org.netbeans.modules.html.editor.gsf.HtmlParserResult
        at org.netbeans.modules.html.editor.gsf.HtmlSemanticAnalyzer.run(HtmlSemanticAnalyzer.java:89)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter.process(SemanticHighlighter.java:315)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter.access$000(SemanticHighlighter.java:80)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter$1.run(SemanticHighlighter.java:148)
        at org.netbeans.modules.csl.editor.semantic.SemanticHighlighter$1.run(SemanticHighlighter.java:157)
        at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:131)
Comment 49 Kenneth Ganfield 2009-04-24 13:47:02 UTC
Created attachment 80850 [details]
stacktrace
Comment 50 rmatous 2009-05-19 14:54:43 UTC
*** Issue 165496 has been marked as a duplicate of this issue. ***