Netbeans Platform development with maven: Troubleshooting

Published: 12/01/11 12:28 PM


This article is about common problems in Rich Client development with the Netbeans Platform using maven. I’ll extend this article every now and then, when there’s time for it.

Dependency problems

When you want to install certain modules in your standalone application based on Netbeans RCP-Application, make sure to use <type>jar</type> in order to have it considered transitive. This way, Netbeans will install dependent modules as well. Otherwise, (e.g. when using <type>nbm</type>) you’ll end up adding tons of modules required by other modules directly, which is time-consuming (run-time trial-error), annoying and less maintainable.

When you get errors on startup, saying “Could not install xyz”, make sure to check the file target/userdir/var/log/messages.log of your application in order to get more useful error-messages.

Nullpointer Exception when dealing with Schema Aware Code Completion

Errormessage:

java.lang.NullPointerException
    at
org.netbeans.modules.xml.schema.completion.util.CompletionUtil.isDTDBasedDocument(CompletionUtil.java:669)
    at
org.netbeans.modules.xml.schema.completion.util.CompletionUtil.canProvideCompletion(CompletionUtil.java:769)
    at
org.netbeans.modules.xml.schema.completion.SchemaBasedCompletionProvider.getAutoQueryTypes(SchemaBasedCompletionProvider.java:80)
    at
org.netbeans.modules.editor.completion.CompletionImpl.insertUpdate(CompletionImpl.java:320)
    at
org.netbeans.lib.editor.util.swing.PriorityDocumentListenerList.insertUpdate(PriorityDocumentListenerList.java:85)
    at
javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:185)
    at
org.netbeans.editor.BaseDocument.fireInsertUpdate(BaseDocument.java:1670)
    at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:816)
    at
org.netbeans.editor.BaseKit$DefaultKeyTypedAction.insertString(BaseKit.java:1198)
    at
org.netbeans.editor.BaseKit$DefaultKeyTypedAction.performTextInsertion(BaseKit.java:1264)
    at
org.netbeans.editor.BaseKit$DefaultKeyTypedAction.access$100(BaseKit.java:1077)
    at
org.netbeans.editor.BaseKit$DefaultKeyTypedAction$1.run(BaseKit.java:1137)
    at
org.netbeans.editor.GuardedDocument.runAtomicAsUser(GuardedDocument.java:344)
    at
org.netbeans.editor.BaseKit$DefaultKeyTypedAction.actionPerformed(BaseKit.java:1130)
    at
org.netbeans.editor.ext.ExtKit$ExtDefaultKeyTypedAction.actionPerformed(ExtKit.java:1068)
    at org.netbeans.editor.BaseAction.actionPerformed(BaseAction.java:339)

Solution:

It is actually a bug in CompletionUtil.isDTDBasedDocument, because it doesn’t check for the reasonable return value null. But the source of the problem is that there’s no appropriate LanguageProvider registered.
Add the Dependency org.netbeans.modules : org-netbans-modules-lexer-nbbridge, which provides org.netbeans.modules.lexer.nbbridge.MimeLookupLanguageProvider.

No module providing the capability org.netbeans.modules.editor.actions could be found

dependencies defined:

<dependency>
	<groupId>org.netbeans.api</groupId>
	<artifactId>org-netbeans-modules-editor</artifactId>
	<version>RELEASE71-BETA</version>
	<type>jar</type>
</dependency>

Errormessage:

Warning - could not install some modules:
	org.netbeans.modules.editor.lib2 - No module providing the capability org.netbeans.modules.editor.actions could be found.
	org.netbeans.modules.editor.lib2 - The module org.netbeans.modules.editor.settings would also need to be installed.
	org.netbeans.modules.editor.settings - No module providing the capability org.netbeans.api.editor.settings.implementation could be found.
	org.netbeans.modules.editor.indent - The module org.netbeans.modules.editor.lib2 would also need to be installed.
	org.netbeans.modules.editor.indent - The module org.netbeans.modules.editor.settings would also need to be installed.
	org.netbeans.modules.editor.fold - The module org.netbeans.modules.editor.lib2 would also need to be installed.
	org.netbeans.modules.editor.fold - The module org.netbeans.modules.editor.settings would also need to be installed.

Solution:

Add following dependency (this will not be sufficient. you’ll need to add org-netbeans-modules-editor-settings-storage as well. See solution below):

<dependency>
	<groupId>org.netbeans.modules</groupId>
	<artifactId>org-netbeans-modules-editor-actions</artifactId>
	<version>RELEASE71-BETA</version>
	<type>jar</type>
</dependency>

No module providing the capability org.netbeans.api.editor.settings.implementation could be found.

dependencies defined:

<dependency>
	<groupId>org.netbeans.api</groupId>
	<artifactId>org-netbeans-modules-editor</artifactId>
	<version>RELEASE71-BETA</version>
	<type>jar</type>
</dependency>
<dependency>
	<groupId>org.netbeans.modules</groupId>
	<artifactId>org-netbeans-modules-editor-actions</artifactId>
	<version>RELEASE71-BETA</version>
	<type>jar</type>
</dependency>

Errormessage:

Warning - could not install some modules:
	org.netbeans.modules.editor.fold - The module org.netbeans.modules.editor.lib2 would also need to be installed.
	org.netbeans.modules.editor.fold - The module org.netbeans.modules.editor.settings would also need to be installed.
	org.netbeans.modules.editor.settings - No module providing the capability org.netbeans.api.editor.settings.implementation could be found.
	org.netbeans.modules.editor.lib2 - None of the modules providing the capability org.netbeans.modules.editor.actions could be installed.
	org.netbeans.modules.editor.lib2 - The module org.netbeans.modules.editor.settings would also need to be installed.
	org.netbeans.modules.editor.indent - The module org.netbeans.modules.editor.lib2 would also need to be installed.
	org.netbeans.modules.editor.indent - The module org.netbeans.modules.editor.settings would also need to be installed.
	org.netbeans.modules.editor.actions - The module org.netbeans.modules.editor.lib2 would also need to be installed.
	org.netbeans.modules.editor.actions - The module org.netbeans.modules.editor.lib would also need to be installed.
	org.netbeans.modules.editor.actions - The module org.netbeans.modules.editor.settings would also need to be installed.
	org.netbeans.modules.editor.lib - The module org.netbeans.modules.editor.fold would also need to be installed.
	org.netbeans.modules.editor.lib - The module org.netbeans.modules.editor.indent would also need to be installed.
	org.netbeans.modules.editor.lib - The module org.netbeans.modules.editor.lib2 would also need to be installed.
	org.netbeans.modules.editor.lib - The module org.netbeans.modules.editor.settings would also need to be installed.

Solution:

Add following dependency:

<dependency>
	<groupId>org.netbeans.modules</groupId>
	<artifactId>org-netbeans-modules-editor-settings-storage</artifactId>
	<version>RELEASE71-BETA</version>
	<type>jar</type>
</dependency>

java.lang.ClassCastException: org.openide.text.FilterDocument cannot be cast to javax.swing.text.AbstractDocument

This bug might appear when you’re dealing with the XML-Schema-Module. In my case, it appeared when I was trying to get a Xam-based-approach working with MultiViewEditor. I copied sourcecode from the Schema-Module in the first place in order to get a glance on how that works.

Hint for Solution

Thanks to Jesse Glick from the nbdev mailinglist: Make sure the editor-related modules are enabled in your app. The resulting BaseDocument should be assignable to AbstractDocument.

Module dependency has friend dependency on org.netbeans.bootstrapbut is not listed as friend.

Description

When dealing with org.netbeans.modules.xml.xam.ModelSource. (But appears in other constellations as well, so transfer the solution to your constellation. Debugging by temporarily adding the implementation-dependencies helps a lot.)
I had this problem in a submodule that used ModelSource. As soon as ModelSource was used somewhere, this error-message appeared when compiling.
In order to resolve the issue, I added implementation-dependencies in the first place. It was not sufficient to only add org-netbeans-bootstrap, but core-startup and netbeans-core would be neccessary too.
Note: This is not the solution but the way I went:
I modified src/main/nbm/module.xml and added these to the <dependencies> section:

<dependency>
	<id>org.netbeans.modules:org-netbeans-bootstrap</id>
	<type>impl</type>
	<explicitValue>org.netbeans.bootstrap/1 = 201109252201</explicitValue>
</dependency>
<dependency>
	<id>org.netbeans.modules:org-netbeans-core-startup</id>
	<type>impl</type>
	<explicitValue>org.netbeans.core.startup/1 = 201109252201</explicitValue>
</dependency>
<dependency>
	<id>org.netbeans.modules:org-netbeans-core</id>
	<type>impl</type>
	<explicitValue>org.netbeans.core/2 = 201109252201</explicitValue>
</dependency>

Then the actual error-message occured when compiled:
“Project uses classes from transitive module org.netbeans.api:org-netbeans-modules-xml-xam:jar:RELEASE71-BETA which will not be accessible at runtime.”
Which basically means that you have to add this module as a direct dependency:

Solution

Add this to the dependencies-section of your pom.xml:

<dependency>
	<artifactId>org-netbeans-modules-xml-xam</artifactId>
	<groupId>org.netbeans.api</groupId>
	<type>jar</type>
	<version>RELEASE71-BETA</version>
</dependency>

Afterwards, you should remove the previously added implementation-dependencies from src/main/nbm/module.xml if you followed my debugging steps.


Kommentieren Sie diesen Artikel

kultur.lich.de heißt nun kultur-lich.de