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 184306 - [69cat] [69cat] AssertionError at org.netbeans.modules.xml.xdm.XDMModel.<init>
Summary: [69cat] [69cat] AssertionError at org.netbeans.modules.xml.xdm.XDMModel.<init>
Status: VERIFIED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: XDM (show other bugs)
Version: 6.x
Hardware: All All
: P2 normal (vote)
Assignee: Nikita Krjukov
URL:
Keywords:
: 172444 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-04-15 20:34 UTC by host
Modified: 2011-11-15 13:49 UTC (History)
10 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 167734


Attachments
stacktrace (998 bytes, text/plain)
2010-04-15 20:35 UTC, host
Details
stacktrace (998 bytes, text/plain)
2010-04-22 19:19 UTC, host
Details
stacktrace (998 bytes, text/plain)
2010-04-26 12:26 UTC, Exceptions Reporter
Details
stacktrace (998 bytes, text/plain)
2010-04-29 04:35 UTC, Baiazid
Details
screenshot_bug184306_modified_faces-config-xml.png (75.30 KB, image/png)
2010-05-27 13:22 UTC, _ alexpetrov
Details
stacktrace (998 bytes, text/plain)
2010-06-01 09:20 UTC, big_al
Details

Note You need to log in before you can comment on or make changes to this bug.
Description host 2010-04-15 20:34:58 UTC
Build: NetBeans IDE Dev (Build 201004150201)
VM: Java HotSpot(TM) 64-Bit Server VM, 14.3-b01-101, Java(TM) SE Runtime Environment, 1.6.0_17-b04-248-10M3025
OS: Mac OS X

Stacktrace: 
java.lang.AssertionError
   at org.netbeans.modules.xml.xdm.XDMModel.<init>(XDMModel.java:100)
   at org.netbeans.modules.xml.xdm.xam.XDMAccess.<init>(XDMAccess.java:85)
   at org.netbeans.modules.xml.xdm.xam.XDMAccessProvider.createModelAccess(XDMAccessProvider.java:69)
   at org.netbeans.modules.xml.xam.dom.AbstractDocumentModel.getAccess(AbstractDocumentModel.java:521)
   at org.netbeans.modules.xml.xam.dom.AbstractDocumentModel.getAccess(AbstractDocumentModel.java:76)
   at org.netbeans.modules.xml.xam.AbstractModel.isAutoSyncActive(AbstractModel.java:640)
Comment 1 host 2010-04-15 20:35:03 UTC
Created attachment 97488 [details]
stacktrace
Comment 2 host 2010-04-22 19:19:50 UTC
Created attachment 97875 [details]
stacktrace
Comment 3 Exceptions Reporter 2010-04-22 19:20:12 UTC
This bug already has 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=167734
Comment 4 Exceptions Reporter 2010-04-26 12:26:07 UTC
Created attachment 98022 [details]
stacktrace

finding string in faces-config.xml
Comment 5 Baiazid 2010-04-29 04:35:17 UTC
Created attachment 98239 [details]
stacktrace

Edit faces-config.xml to add new:

        <resource-bundle>
            <base-name>messages</base-name>
            <var>msg</var>
        </resource-bundle>
Comment 6 Exceptions Reporter 2010-05-03 19:32:18 UTC
This bug already has 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=167734
Comment 7 Exceptions Reporter 2010-05-25 16:25:12 UTC
This bug already has 20 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=167734
Comment 8 Sergey Lunegov 2010-05-25 16:46:51 UTC
Alex, please take a look.
Comment 9 _ alexpetrov 2010-05-27 13:21:48 UTC
I'm not able to reproduce this bug on:
Product Version: NetBeans IDE Dev (Build 201005260001)
Java: 1.6.0_18; Java HotSpot(TM) Client VM 16.0-b13
System: Windows XP version 5.1 running on x86

My steps:
- download and install the plugin "Java Web and EE", including the JSF module
- create a sample JSF project "TravelCenter"
- open its "faces-config.xml" and add at the beginning of this file several XML tags (see the attached "screenshot_bug184306_modified_faces-config-xml.png"):
    <application>
        <resource-bundle>
            <base-name>messages</base-name>
            <var>msg</var>
        </resource-bundle>
    </application>

Result:
- no exceptions were thrown.

Need more info (all details are very important): 
 - attach a JSF project, which is edited
 - describe steps, which allow to reproduce this bug

I've seen that some exception reports (UI Actions XML/Messages Log) contain exception messages:
1. http://statistics.netbeans.org/exceptions/messageslog?id=394662
   Log Session: Wednesday, May 26, 2010 7:03:49 PM CDT
   Product Version         = NetBeans IDE 6.9 Beta (Build 201004200117) <= old build
        <message>Could not lock document</message>
        <exception>
            <message>java.io.IOException: File faces-config.xml is read-only!</message>

java.io.FileNotFoundException: JAR entry com/jaspersoft/ireport/com-jaspersoft-ireport-designer-menu-DatasourcesAction_1.shadow not found in C:\Archivos de programa\NetBeans 6.9 Beta\ireport\modules\com-jaspersoft-ireport.jar

2. http://statistics.netbeans.org/exceptions/messageslog?id=382968
WARNING [org.openide.filesystems.JarFileSystem]: cannot open C:\Documents and Settings\mircea.stanciu\.m2\repository\javax\javaee-api\6.0\javaee-api-6.0-sources.jar
INFO [org.openide.filesystems.JarFileSystem]: error in opening zip file
java.util.zip.ZipException: error in opening zip file

Maybe mentioned troubles cause this bug.
Comment 10 _ alexpetrov 2010-05-27 13:22:54 UTC
Created attachment 99542 [details]
screenshot_bug184306_modified_faces-config-xml.png
Comment 11 Nikita Krjukov 2010-05-28 13:17:00 UTC
It's not clear yet, which part of code is responsible for the Exception. 

The initial reason of exception is absence of an org.netbeans.editor.BaseDocument instance in model's source. The ModelSource object is required for construction of a new XAM-based model or getting an existing model from the internal cache (see AbstractModelFactory class). 

According to ModelSource.getLookup() method's documentation, the lookup has to contain javax.swing.text.Document. The XDMModel requires a BaseDocument instance instead, which is a descendant of Document. There is a contradiction here. And it can cause the exception if some external code put a Document to the lookup instead of a BaseDocument. I'm going to figure out it and maybe do some corrections. But this contradiction doesn't look like the main or the only reason of the Exception. 

Another possible reason can be an incorrect code out of XAM/XDM models, which constructs a ModelSource without required BaseDocument. I don't think that the code does it intentionally. Most likely an exception happens while loading a document and the exception is ignored or processed with a wrong way. It's necessary to analyze logs more detailed. 

Also there is a difficulty, which prevents easily understand real reason. You can see that all stack traces are started from the RequestProcessor. So it's impossible to know which code has requested a XAM model. It would be helpful to have special customizable mode in which the Task class obtains stack trace in its constructor and saves it somewhere inside.
Comment 12 Nikita Krjukov 2010-05-28 19:51:54 UTC
I analyzed different logs (almost all) and it seems I've found a regularity. 
The bug always relates to JSF Config file. It's initiated when the file is being closed - JSFConfigEditorSupport.notifyClosed()

The method seems is called after closing the JSF Config file. The JSF Config model is requested in order to do synch() according to the fix of the issue #116315. It looks like the requested model isn't loaded yet and it tries loading and failed. An IOException happens, but it's caught in the method and lost. 

I suppose the assertion exception maybe is reasonable in such case. It worth to understand what is the reason of IOException first. And it's necessary to uncomment the line, where the exception is lost: 
    } catch (IOException ex) {
        // Logger.getLogger("global").log(Level.INFO, null, ex);
    }

It should be more clear to the owners of corresponding JSF module, why the IOException happens, so I reopen the issue and switch it to them.
Comment 13 Nikita Krjukov 2010-05-28 19:57:35 UTC
I forgot to say that always there is another exception before AssertionError. 
It can be found in any log and it contains line: 

[catch] at org.netbeans.modules.web.jsf.JSFConfigEditorSupport$7.run(JSFConfigEditorSupport.java:378)
Comment 14 Alexey Butenko 2010-05-31 07:13:35 UTC
From debugger I've found that IOException happens in org.netbeans.modules.xml.xam.AbstractModel.sync(). It should be more clear to the owners of corresponding module, why the
IOException happens.
Comment 15 Nikita Krjukov 2010-05-31 18:16:09 UTC
It looks like the mentioned AssertionError and Exception are not hardly related. They rather have the same reason. The AssertionError happens inside of auto-sync procedure. A modification of the JSF Config file makes it so invalid, that it can't be loaded to text document. Because the model for the file is already loaded, it causes the AssertionError when the document is requested again. 
I suppose the same changes can be done not only with JSF Config file, so the problem is more general. 

It's not clear what exactly happens. I know that the JSF Config file is located in a temporary folder and the attempt to load it comes to an IOExceptin with "FileObject is invalid" message. 

The solution I tried to use is throwing an artificial IOExceprion in the method org.netbeans.modules.xml.retriever.catalog.Utilities._getDocument(). It comes to similar results without reproducing the bug itself.
Comment 16 big_al 2010-06-01 09:20:58 UTC
Created attachment 99699 [details]
stacktrace

opened faces-config.xml
Comment 17 Nikita Krjukov 2010-06-01 12:48:13 UTC
Fixed in trunk
http://hg.netbeans.org/main/rev/984778a6953b

Now the XAM model gets NOT_SYNCED status if the underlaying XML document becomes inaccessible.
Comment 18 Quality Engineering 2010-06-03 06:08:58 UTC
Integrated into 'main-golden', will be available in build *201006030001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/984778a6953b
User: supernikita@netbeans.org
Log: #184306 - AssertionError at ...xml.xdm.XDMModel.<init>
Comment 19 Nikita Krjukov 2010-06-18 17:07:02 UTC
There isn't reliable way to reproduce the issue. So it's tested with JUnit tests.
Comment 20 Nikita Krjukov 2010-06-18 17:08:41 UTC
The fix is simple and not dangerous so I'm going to move it to relase691
Comment 21 Nikita Krjukov 2010-06-18 20:22:34 UTC
transplanted modification from trunk to release691 http://hg.netbeans.org/release691/rev/586a34baa795
Comment 22 Svata Dedic 2011-11-15 13:49:28 UTC
*** Bug 172444 has been marked as a duplicate of this bug. ***