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 170047 - NPE in createDiff in standalone app
Summary: NPE in createDiff in standalone app
Status: RESOLVED DUPLICATE of bug 170527
Alias: None
Product: utilities
Classification: Unclassified
Component: Diff (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker with 1 vote (vote)
Assignee: diff-issues@utilities
URL: http://forums.netbeans.org/post-43862...
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-07 15:07 UTC by najmi
Modified: 2009-08-26 08:07 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Standalone minimal test program to reproduce bug. (2.02 KB, text/plain)
2009-08-07 18:13 UTC, najmi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description najmi 2009-08-07 15:07:52 UTC
In my standalone maven app I am trying to use the diff API and getting the following stack trace:

Message:
    java.lang.NullPointerException
Level:
    SEVERE
Stack Trace:
null
    org.netbeans.modules.diff.builtin.visualizer.editable.EditableDiffView$RefreshDiffTask.run(EditableDiffView.java:1003)
    org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:577)
    org.netbeans.modules.diff.builtin.visualizer.editable.EditableDiffView.<init>(EditableDiffView.java:267)
    org.netbeans.modules.diff.builtin.DefaultDiff.createDiff(DefaultDiff.java:138)

The following warning is also logged during the same diff action:

Aug 7, 2009 9:56:50 AM org.openide.util.NbPreferences getPreferencesProvider
WARNING: NetBeans implementation of Preferences not found: java.lang.Exception
        at org.openide.util.NbPreferences.getPreferencesProvider(NbPreferences.java:110)
        at org.openide.util.NbPreferences.forModule(NbPreferences.java:75)
        at org.netbeans.modules.diff.DiffModuleConfig.getPreferences(DiffModuleConfig.java:242)
        at org.netbeans.modules.diff.DiffModuleConfig.getColor(DiffModuleConfig.java:147)
        at org.netbeans.modules.diff.DiffModuleConfig.getDeletedColor(DiffModuleConfig.java:103)
        at org.netbeans.modules.diff.builtin.visualizer.editable.EditableDiffView.initColors(EditableDiffView.java:381)
        at org.netbeans.modules.diff.builtin.visualizer.editable.EditableDiffView.<init>(EditableDiffView.java:163)
        at org.netbeans.modules.diff.builtin.DefaultDiff.createDiff(DefaultDiff.java:138)

It seems that the default Diff provider should handle the case of missing prefs more gracefully and use default prefs.
Can someone please post a workaround that will initialize the module prefernces with reasonable defaults. Thanks.
Comment 1 najmi 2009-08-07 18:13:47 UTC
Created attachment 85981 [details]
Standalone minimal test program to reproduce bug.
Comment 2 najmi 2009-08-07 18:16:19 UTC
Just attached a standlone JUnit test program.
Note that I use maven with following dependencies for my project:

        <dependency>
            <groupId>org.netbeans.api</groupId>
            <artifactId>org-netbeans-modules-diff</artifactId>
            <version>RELEASE67</version>
        </dependency>

        <dependency>
            <groupId>org.netbeans.modules</groupId>
            <artifactId>org-netbeans-modules-editor-errorstripe</artifactId>
            <version>RELEASE67</version>
        </dependency>

Any transitive dependencies of above is hopefully being resolved by maven.
Comment 3 Ondrej Vrabec 2009-08-10 09:55:24 UTC
I am afraid i will disappoint you. The diff module depends on many other netbeans modules (on some directly, on others
indirectly through a lookup). So to make it work you would have to add almost the whole netbeans platform amongst the
dependencies. 

The http://bits.netbeans.org/maven2 repository is primarily used for developing a Maven Netbeans Platform Application
not a simple maven standalone app (i believe the correct new project is New > Maven > Maven Netbeans Platform Archetype). 
So i think you won't be able to make this work.

Here is an article about maven netbeans development: http://mojo.codehaus.org/nbm-maven-plugin/index.html
And here another about the repo:
http://blogs.codehaus.org/people/mkleint/archives/001735_nb_65_artifacts_in_a_maven_repository.html 
Comment 4 najmi 2009-08-10 14:39:45 UTC
I do not understand the last response. Are you actually saying that NB platform cannot be used to build standalone apps?
I find that hard to believe. I will follow-up in the nbusers forum here:

<http://forums.netbeans.org/topic16008.html>

I assume that the Diff API will work given that some minimum set of dependencies are satisfied. Ideally, those
dependencies would be captured in its pom.xml file but lets say even if they are not, the project team should be able to
identify the dependencies.

Thanks for looking into this matter in greater depth a bit longer.

Comment 5 Ondrej Vrabec 2009-08-26 08:07:29 UTC
>Ideally, those dependencies would be captured in its pom.xml file
You'll find dependencies needed to compile, but there are still some runtime dependencies (class implementations
obtained from lookup). I repeat - the repository is intended for maven apps build upon Netbeans Platform (when you're
creating new project, choose Netbeans Platform Archetype).
If you still want to use the diff jat in a standalone swing application, i guess you'll have to add all dependencies
manually (as Petr Dvorak pointed out in the forum), however i can't give you a precise list. However look at issue
170527, you'll find a sample application using the diff module (but build on Netbeans Platform), you can look into its
dependencies and add those to your application.
The issue 170527 refers to a similar problem - a NPE thrown during runtime, the Diff module depends also on the
ide11/Plain Editor module (which is not automatically selected in project properties/Libraries). So add also this module
among the dependencies.

I'm making this a duplicate of 170527 (it has P3 priority (lower than this one), but you'll find all needed dependencies
there, i hope, so i'm lowering this priority, too)  

*** This issue has been marked as a duplicate of 170527 ***