Access Module Installer in another package

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Access Module Installer in another package

Thomas Sobieroy

Hey,

 

I’m currently working on a project where I need to access a module Installer from another package. I work in a maven context,

so I generate my manifest.mf in project A (com.mycompany.ideapplication)

<archive>

                                <manifest>

                                    <addClasspath>true</addClasspath>

                                </manifest>

                                <manifestFile>MANIFEST.MF</manifestFile>

                                <manifestEntries>

                                    <Manifest-Version>1.0</Manifest-Version>

                                    <AutoUpdate-Show-In-Client>true</AutoUpdate-Show-In-Client>

                                    <OpenIDE-Module>com.mycompany.ideapplication</OpenIDE-Module>

                                    <OpenIDE-Module-Name>IDE Application</OpenIDE-Module-Name>                                   

                                    <OpenIDE-Module-Install>de/uos/netbeans/Installer.class</OpenIDE-Module-Install>

                                    <OpenIDE-Module-Specification-Version>1.0</OpenIDE-Module-Specification-Version>                                   

                                    <OpenIDE-Module-Requires>

                                        org.openide.windows.WindowManager,                                      

                                    </OpenIDE-Module-Requires>  

                                    <Class-Path>JavaIDEAPIAbstractionLayer-1.0-SNAPSHOT-jar-with-dependencies.jar</Class-Path>

                                    <Archiver-Version>Plexus Archiver</Archiver-Version>

                                    <Build-Time>${maven.build.timestamp}</Build-Time>

                                    <Build-Host>${agent.name}</Build-Host>

                                    <Build-User>${user.name}</Build-User>

                                    <Build-Maven>Maven ${maven.version}</Build-Maven>

                                    <Build-Java>${java.version}</Build-Java>

                                    <Build-OS>${os.name}</Build-OS>

                                    <Build-Label>${project.version}</Build-Label>

                                    <Build-Path>${basedir}</Build-Path>

                                </manifestEntries>

                            </archive>

 

And I want to call Installer in Project B (de.uos.JavaIDEAPIAbstractionLayer):

public class Installer extends ModuleInstall {

 

    private PropertyChangeListener editorChangeListener;

     private static JTextComponent lastFocused = null;

    @Override

    public void restored() {

 

        //Will be called when the active editor changes.

        editorChangeListener = new PropertyChangeListener() {

                (and so on)

 

I’ve a dependency in maven to the library containing the installer. The library itself is no netbeans module.

Adding the library containing the installer to my Class-Path in Manifest.mf results the following errors:

 

First f.y.i. I get a WARNING [org.netbeans.core.startup.InstalledFileLocatorImpl]: module com.mycompany.ideapplication in C:\Users\thoma\Documents\OneDrive\Bachelorarbeit\Project\IDEApplication\target\netbeans_clusters\extra does not own modules/xbean-reflect-3.7.jar at org.netbeans.LocaleVariants.findLogicalPath(LocaleVariants.java:271), because I copy over dependencies in maven

 

Then comes a

java.lang.ClassNotFoundException: org.netbeans.modules.masterfs.MasterURLMapper@ModuleCL@3a71f843[com.mycompany.ideapplication]:jar:file:/C:/Users/thoma/Documents/OneDrive/Bachelorarbeit/Project/IDEApplication/target/netbeans_clusters/extra/modules/org-netbeans-modules-masterfs-RELEASE82.jar!/ not a subclass of [hidden email]$BootClassLoader@21b8d17c:jar:file:/C:/Program%20Files/NetBeans%208.2/platform/core/org-openide-filesystems.jar!/

[catch] at org.openide.util.lookup.MetaInfServicesLookup.search(MetaInfServicesLookup.java:349)

                at org.openide.util.lookup.MetaInfServicesLookup.beforeLookup(MetaInfServicesLookup.java:156)

                at org.openide.util.lookup.MetaInfServicesLookup.beforeLookupResult(MetaInfServicesLookup.java:135)

                at org.openide.util.lookup.AbstractLookup.lookup(AbstractLookup.java:483)

                at org.openide.util.lookup.ProxyLookup$R.lookupChange(ProxyLookup.java:460)

                at org.openide.util.lookup.ProxyLookup.setData(ProxyLookup.java:313)

                at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:152)

                at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:125)

                at org.netbeans.core.startup.MainLookup.changeLookups(MainLookup.java:218)

                at org.netbeans.core.startup.MainLookup.systemClassLoaderChanged(MainLookup.java:118)

                at org.netbeans.core.startup.NbInstaller.classLoaderUp(NbInstaller.java:330)

                at org.netbeans.ModuleManager.enable(ModuleManager.java:1351)

                at org.netbeans.ModuleManager.enable(ModuleManager.java:1170)

                at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:340)

                at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:276)

                at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:301)

                at org.netbeans.core.startup.Main.getModuleSystem(Main.java:181)

                at org.netbeans.core.startup.Main.getModuleSystem(Main.java:150)

                at org.netbeans.core.startup.Main.start(Main.java:307)

                at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:123)

                at java.lang.Thread.run(Thread.java:745)

INFO [org.openide.util.lookup.MetaInfServicesLookup]

 

And then:

java.lang.ClassNotFoundException: Will not load class org.netbeans.modules.settings.convertors.SerialDataConvertor$Provider arbitrarily from one of ModuleCL@298638c1[org.netbeans.modules.settings] and ModuleCL@3a71f843[com.mycompany.ideapplication] starting from SystemClassLoader[519 modules]; see http://wiki.netbeans.org/DevFaqModuleCCE

                at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:204)

                at org.netbeans.ModuleManager$SystemClassLoader.loadClass(ModuleManager.java:779)

                at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

                at java.lang.Class.forName0(Native Method)

                at java.lang.Class.forName(Class.java:348)

                at org.netbeans.core.startup.layers.BinaryFS$AttrImpl.findClass(BinaryFS.java:848)

                at org.netbeans.core.startup.layers.BinaryFS$AttrImpl.methodValue(BinaryFS.java:788)

[catch] at org.netbeans.core.startup.layers.BinaryFS$AttrImpl.getValue(BinaryFS.java:703)

                at org.netbeans.core.startup.layers.BinaryFS$BFSBase.getAttribute(BinaryFS.java:549)

                at org.openide.filesystems.MultiFileObject.getAttribute(MultiFileObject.java:944)

                at org.openide.filesystems.MultiFileObject.getAttribute(MultiFileObject.java:877)

                at org.openide.filesystems.MultiFileObject.getAttribute(MultiFileObject.java:940)

                at org.openide.filesystems.MultiFileObject.getAttribute(MultiFileObject.java:877)

                at org.openide.filesystems.MultiFileObject.getAttribute(MultiFileObject.java:798)

                at org.openide.loaders.InstanceDataObject$Ser.instanceCreate(InstanceDataObject.java:1432)

                at org.openide.loaders.InstanceDataObject.instanceCreate(InstanceDataObject.java:846)

                at org.netbeans.modules.openide.loaders.FileEntityResolver.findLookup(FileEntityResolver.java:198)

                at org.netbeans.modules.openide.loaders.FileEntityResolver.access$200(FileEntityResolver.java:94)

                at org.netbeans.modules.openide.loaders.FileEntityResolver$Lkp.update(FileEntityResolver.java:556)

                at org.netbeans.modules.openide.loaders.FileEntityResolver$Lkp.beforeLookup(FileEntityResolver.java:519)

                at org.openide.util.lookup.ProxyLookup.beforeLookup(ProxyLookup.java:209)

                at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:671)

                at org.openide.util.lookup.ProxyLookup$R.computeResult(ProxyLookup.java:553)

                at org.openide.util.lookup.ProxyLookup$R.allItems(ProxyLookup.java:537)

                at org.openide.util.lookup.ProxyLookup$R.allItems(ProxyLookup.java:532)

                at org.openide.loaders.InstanceDataObject.getCookiesLookup(InstanceDataObject.java:725)

                at org.openide.loaders.InstanceDataObject.getCookiesLookup(InstanceDataObject.java:705)

                at org.openide.loaders.InstanceDataObject.getCookieFromEP(InstanceDataObject.java:622)

                at org.openide.loaders.InstanceDataObject.getCookie(InstanceDataObject.java:652)

                at org.openide.loaders.FolderInstance.acceptDataObject(FolderInstance.java:417)

                at org.openide.loaders.FolderInstance.defaultProcessObjects(FolderInstance.java:798)

                at org.openide.loaders.FolderInstance.access$000(FolderInstance.java:103)

                at org.openide.loaders.FolderInstance$1R.init(FolderInstance.java:693)

                at org.openide.loaders.FolderInstance$1R.run(FolderInstance.java:728)

                at org.openide.loaders.FolderLookup.postCreationTask(FolderLookup.java:260)

                at org.openide.loaders.FolderInstance.processObjects(FolderInstance.java:770)

                at org.openide.loaders.FolderInstance$Listener.finished(FolderInstance.java:1059)

                at org.openide.loaders.FolderList.createBoth(FolderList.java:879)

                at org.openide.loaders.FolderList.getObjects(FolderList.java:564)

                at org.openide.loaders.FolderList.access$600(FolderList.java:77)

                at org.openide.loaders.FolderList$ListTask.computeResult(FolderList.java:963)

                at org.openide.loaders.FolderList$ListTask.run(FolderList.java:939)

                at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)

                at org.openide.util.RequestProcessor$Processor.doEvaluate(RequestProcessor.java:2111)

                at org.openide.util.RequestProcessor$Task.waitFinished(RequestProcessor.java:1675)

                at org.openide.loaders.FolderInstance.waitFinished(FolderInstance.java:332)

                at org.openide.loaders.FolderInstance.instanceCreate(FolderInstance.java:281)

                at org.openide.loaders.FolderLookup.instanceForCookie(FolderLookup.java:222)

                at org.openide.loaders.FolderInstance$HoldInstance.instanceCreate(FolderInstance.java:1157)

                at org.openide.loaders.FolderLookup.createInstance(FolderLookup.java:166)

                at org.openide.loaders.FolderInstance.defaultProcessObjectsFinal(FolderInstance.java:888)

                at org.openide.loaders.FolderInstance$1R.run(FolderInstance.java:730)

                at org.openide.loaders.FolderLookup.postCreationTask(FolderLookup.java:260)

                at org.openide.loaders.FolderInstance.processObjects(FolderInstance.java:770)

                at org.openide.loaders.FolderInstance$Listener.finished(FolderInstance.java:1059)

                at org.openide.loaders.FolderList.createBoth(FolderList.java:879)

                at org.openide.loaders.FolderList.getObjects(FolderList.java:564)

                at org.openide.loaders.FolderList.access$600(FolderList.java:77)

                at org.openide.loaders.FolderList$ListTask.computeResult(FolderList.java:963)

                at org.openide.loaders.FolderList$ListTask.run(FolderList.java:939)

                at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)

                at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)

                at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)

                at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)

There are a lot of similar exceptions.

 

Does anyone have a clue how to deal with that? What I want to achieve is to access the editor object through the jar-library and to set up some PropertyChangeListener and to start all that from my netbeans module.

Is that somehow possible?

 

Best regards & thank you very much

Thomas Sobieroy

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Access Module Installer in another package

Geertjan Wielenga-3



On 15-4-2017 16:52, Thomas Sobieroy wrote:

Hey,

 

I’m currently working on a project where I need to access a module Installer from another package.


The question here is: "why". Probably a better solution is to create some kind of system property that is set via one installer and retrieved via the other installer.

Gj


I work in a maven context,

so I generate my manifest.mf in project A (com.mycompany.ideapplication)

<archive>

                                <manifest>

                                    <addClasspath>true</addClasspath>

                                </manifest>

                                <manifestFile>MANIFEST.MF</manifestFile>

                                <manifestEntries>

                                    <Manifest-Version>1.0</Manifest-Version>

                                    <AutoUpdate-Show-In-Client>true</AutoUpdate-Show-In-Client>

                                    <OpenIDE-Module>com.mycompany.ideapplication</OpenIDE-Module>

                                    <OpenIDE-Module-Name>IDE Application</OpenIDE-Module-Name>                                   

                                    <OpenIDE-Module-Install>de/uos/netbeans/Installer.class</OpenIDE-Module-Install>

                                    <OpenIDE-Module-Specification-Version>1.0</OpenIDE-Module-Specification-Version>                                   

                                    <OpenIDE-Module-Requires>

                                        org.openide.windows.WindowManager,                                      

                                    </OpenIDE-Module-Requires>  

                                    <Class-Path>JavaIDEAPIAbstractionLayer-1.0-SNAPSHOT-jar-with-dependencies.jar</Class-Path>

                                    <Archiver-Version>Plexus Archiver</Archiver-Version>

                                    <Build-Time>${maven.build.timestamp}</Build-Time>

                                    <Build-Host>${agent.name}</Build-Host>

                                    <Build-User>${user.name}</Build-User>

                                    <Build-Maven>Maven ${maven.version}</Build-Maven>

                                    <Build-Java>${java.version}</Build-Java>

                                    <Build-OS>${os.name}</Build-OS>

                                    <Build-Label>${project.version}</Build-Label>

                                    <Build-Path>${basedir}</Build-Path>

                                </manifestEntries>

                            </archive>

 

And I want to call Installer in Project B (de.uos.JavaIDEAPIAbstractionLayer):

public class Installer extends ModuleInstall {

 

    private PropertyChangeListener editorChangeListener;

     private static JTextComponent lastFocused = null;

    @Override

    public void restored() {

 

        //Will be called when the active editor changes.

        editorChangeListener = new PropertyChangeListener() {

                (and so on)

 

I’ve a dependency in maven to the library containing the installer. The library itself is no netbeans module.

Adding the library containing the installer to my Class-Path in Manifest.mf results the following errors:

 

First f.y.i. I get a WARNING [org.netbeans.core.startup.InstalledFileLocatorImpl]: module com.mycompany.ideapplication in C:\Users\thoma\Documents\OneDrive\Bachelorarbeit\Project\IDEApplication\target\netbeans_clusters\extra does not own modules/xbean-reflect-3.7.jar at org.netbeans.LocaleVariants.findLogicalPath(LocaleVariants.java:271), because I copy over dependencies in maven

 

Then comes a

java.lang.ClassNotFoundException: org.netbeans.modules.masterfs.MasterURLMapper@ModuleCL@3a71f843[com.mycompany.ideapplication]:jar:file:/C:/Users/thoma/Documents/OneDrive/Bachelorarbeit/Project/IDEApplication/target/netbeans_clusters/extra/modules/org-netbeans-modules-masterfs-RELEASE82.jar!/ not a subclass of [hidden email]

[catch] at org.openide.util.lookup.MetaInfServicesLookup.search(MetaInfServicesLookup.java:349)

                at org.openide.util.lookup.MetaInfServicesLookup.beforeLookup(MetaInfServicesLookup.java:156)

                at org.openide.util.lookup.MetaInfServicesLookup.beforeLookupResult(MetaInfServicesLookup.java:135)

                at org.openide.util.lookup.AbstractLookup.lookup(AbstractLookup.java:483)

                at org.openide.util.lookup.ProxyLookup$R.lookupChange(ProxyLookup.java:460)

                at org.openide.util.lookup.ProxyLookup.setData(ProxyLookup.java:313)

                at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:152)

                at org.openide.util.lookup.ProxyLookup.setLookups(ProxyLookup.java:125)

                at org.netbeans.core.startup.MainLookup.changeLookups(MainLookup.java:218)

                at org.netbeans.core.startup.MainLookup.systemClassLoaderChanged(MainLookup.java:118)

                at org.netbeans.core.startup.NbInstaller.classLoaderUp(NbInstaller.java:330)

                at org.netbeans.ModuleManager.enable(ModuleManager.java:1351)

                at org.netbeans.ModuleManager.enable(ModuleManager.java:1170)

                at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:340)

                at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:276)

                at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:301)

                at org.netbeans.core.startup.Main.getModuleSystem(Main.java:181)

                at org.netbeans.core.startup.Main.getModuleSystem(Main.java:150)

                at org.netbeans.core.startup.Main.start(Main.java:307)

                at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:123)

                at java.lang.Thread.run(Thread.java:745)

INFO [org.openide.util.lookup.MetaInfServicesLookup]

 

And then:

java.lang.ClassNotFoundException: Will not load class org.netbeans.modules.settings.convertors.SerialDataConvertor$Provider arbitrarily from one of ModuleCL@298638c1[org.netbeans.modules.settings] and ModuleCL@3a71f843[com.mycompany.ideapplication] starting from SystemClassLoader[519 modules]; see http://wiki.netbeans.org/DevFaqModuleCCE

                at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:204)

                at org.netbeans.ModuleManager$SystemClassLoader.loadClass(ModuleManager.java:779)

                at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

                at java.lang.Class.forName0(Native Method)

                at java.lang.Class.forName(Class.java:348)

                at org.netbeans.core.startup.layers.BinaryFS$AttrImpl.findClass(BinaryFS.java:848)

                at org.netbeans.core.startup.layers.BinaryFS$AttrImpl.methodValue(BinaryFS.java:788)

[catch] at org.netbeans.core.startup.layers.BinaryFS$AttrImpl.getValue(BinaryFS.java:703)

                at org.netbeans.core.startup.layers.BinaryFS$BFSBase.getAttribute(BinaryFS.java:549)

                at org.openide.filesystems.MultiFileObject.getAttribute(MultiFileObject.java:944)

                at org.openide.filesystems.MultiFileObject.getAttribute(MultiFileObject.java:877)

                at org.openide.filesystems.MultiFileObject.getAttribute(MultiFileObject.java:940)

                at org.openide.filesystems.MultiFileObject.getAttribute(MultiFileObject.java:877)

                at org.openide.filesystems.MultiFileObject.getAttribute(MultiFileObject.java:798)

                at org.openide.loaders.InstanceDataObject$Ser.instanceCreate(InstanceDataObject.java:1432)

                at org.openide.loaders.InstanceDataObject.instanceCreate(InstanceDataObject.java:846)

                at org.netbeans.modules.openide.loaders.FileEntityResolver.findLookup(FileEntityResolver.java:198)

                at org.netbeans.modules.openide.loaders.FileEntityResolver.access$200(FileEntityResolver.java:94)

                at org.netbeans.modules.openide.loaders.FileEntityResolver$Lkp.update(FileEntityResolver.java:556)

                at org.netbeans.modules.openide.loaders.FileEntityResolver$Lkp.beforeLookup(FileEntityResolver.java:519)

                at org.openide.util.lookup.ProxyLookup.beforeLookup(ProxyLookup.java:209)

                at org.openide.util.lookup.ProxyLookup$R.myBeforeLookup(ProxyLookup.java:671)

                at org.openide.util.lookup.ProxyLookup$R.computeResult(ProxyLookup.java:553)

                at org.openide.util.lookup.ProxyLookup$R.allItems(ProxyLookup.java:537)

                at org.openide.util.lookup.ProxyLookup$R.allItems(ProxyLookup.java:532)

                at org.openide.loaders.InstanceDataObject.getCookiesLookup(InstanceDataObject.java:725)

                at org.openide.loaders.InstanceDataObject.getCookiesLookup(InstanceDataObject.java:705)

                at org.openide.loaders.InstanceDataObject.getCookieFromEP(InstanceDataObject.java:622)

                at org.openide.loaders.InstanceDataObject.getCookie(InstanceDataObject.java:652)

                at org.openide.loaders.FolderInstance.acceptDataObject(FolderInstance.java:417)

                at org.openide.loaders.FolderInstance.defaultProcessObjects(FolderInstance.java:798)

                at org.openide.loaders.FolderInstance.access$000(FolderInstance.java:103)

                at org.openide.loaders.FolderInstance$1R.init(FolderInstance.java:693)

                at org.openide.loaders.FolderInstance$1R.run(FolderInstance.java:728)

                at org.openide.loaders.FolderLookup.postCreationTask(FolderLookup.java:260)

                at org.openide.loaders.FolderInstance.processObjects(FolderInstance.java:770)

                at org.openide.loaders.FolderInstance$Listener.finished(FolderInstance.java:1059)

                at org.openide.loaders.FolderList.createBoth(FolderList.java:879)

                at org.openide.loaders.FolderList.getObjects(FolderList.java:564)

                at org.openide.loaders.FolderList.access$600(FolderList.java:77)

                at org.openide.loaders.FolderList$ListTask.computeResult(FolderList.java:963)

                at org.openide.loaders.FolderList$ListTask.run(FolderList.java:939)

                at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)

                at org.openide.util.RequestProcessor$Processor.doEvaluate(RequestProcessor.java:2111)

                at org.openide.util.RequestProcessor$Task.waitFinished(RequestProcessor.java:1675)

                at org.openide.loaders.FolderInstance.waitFinished(FolderInstance.java:332)

                at org.openide.loaders.FolderInstance.instanceCreate(FolderInstance.java:281)

                at org.openide.loaders.FolderLookup.instanceForCookie(FolderLookup.java:222)

                at org.openide.loaders.FolderInstance$HoldInstance.instanceCreate(FolderInstance.java:1157)

                at org.openide.loaders.FolderLookup.createInstance(FolderLookup.java:166)

                at org.openide.loaders.FolderInstance.defaultProcessObjectsFinal(FolderInstance.java:888)

                at org.openide.loaders.FolderInstance$1R.run(FolderInstance.java:730)

                at org.openide.loaders.FolderLookup.postCreationTask(FolderLookup.java:260)

                at org.openide.loaders.FolderInstance.processObjects(FolderInstance.java:770)

                at org.openide.loaders.FolderInstance$Listener.finished(FolderInstance.java:1059)

                at org.openide.loaders.FolderList.createBoth(FolderList.java:879)

                at org.openide.loaders.FolderList.getObjects(FolderList.java:564)

                at org.openide.loaders.FolderList.access$600(FolderList.java:77)

                at org.openide.loaders.FolderList$ListTask.computeResult(FolderList.java:963)

                at org.openide.loaders.FolderList$ListTask.run(FolderList.java:939)

                at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)

                at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)

                at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)

                at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)

There are a lot of similar exceptions.

 

Does anyone have a clue how to deal with that? What I want to achieve is to access the editor object through the jar-library and to set up some PropertyChangeListener and to start all that from my netbeans module.

Is that somehow possible?

 

Best regards & thank you very much

Thomas Sobieroy

 


Loading...