Re: TR: java.lang.LinkageError: loader constraint violation: loader
Try to create a small reproducible suite with this problem. In theory what you did is correct and you don't have a duplicate of commons-configuration but it's hard to debug this over email with partial info. Also try looking at the actual build output JARs that you have, I'm not entirely certain nbm-maven-plugin doesn't bundle things differently. I assume you've read stuff like http://www.mojohaus.org/nbm-maven-plugin/#Maven_Dependency_vs._NetBeans_runtime_dependency --emi Original Message On 16 February 2018 11:40 AM, GRYSPEERDT Bastien [CLEMESSY]wrote: > > Hi, > > Yes that is what I think too. > > I changed my architecture since I posted my issue. > > I still have the issue but I think the best is to explain the module > hierarchy : > - I have module A (netbeans module) > > - the module A has a maven dependency to module B > > - the module B has a dependency to a library 1 (maven java project which is > not a Netbeans module). > > - the library 1 has dependencies to maven libraries, including > commons-configuration. > > => The library 1 includes some classes and module A has a class which > inherits from one of this classes. >=> In the super class (in library 1), there is an attribute named >"configuration" (which is a "org.apache.commons.configuration.Configuration"). >=> The issue appends when I call a method of the inherited attribute >"configuration" in the class of module A. > > => in module B, the package "org.apache.commons.configuration" has been > declared as "publicPackage" in the "nbm-maven-plugin" in the POM. >I would have hope that it would be sufficient to avoid that kind of problem, >but it is not. > > The problem must be that module A and module B both add the classes of the > apache "commons-configuration" project to their class loader. > > Bastien > > > -Message d'origine- > De : Emilian Bold [mailto:emilian.b...@protonmail.ch] > Envoyé : jeudi 15 février 2018 13:13 > À : GRYSPEERDT Bastien [CLEMESSY] > Cc : us...@netbeans.incubator.apache.org > Objet : Re: java.lang.LinkageError: loader constraint violation: loader > > My guess is that you are bunding twice > org/apache/commons/configuration/Configuration (ie. commons-configuration). > > Maybe you have two modules that have a library wrapper? Or some other > external JAR that also bundles it in a fat jar? > > --emi > > > Original Message > On 13 February 2018 4:21 PM, GRYSPEERDT Bastien [CLEMESSY] > bastien.gryspee...@eiffage.com wrote: > >>Hi, >>I have an application build on the Netbeans Platform that uses some netbeans >>modules. >>These netbeans modules import some subprojects (that are not Netbeans >> modules). In one of the subproject, I need to call the >> org.apache.configuration.Configuration (from “commons-configuration” Apache >> project) class to check that a parameter is true (if it is, I display some >> field on a HMI). >>To set the Configuration install, I do it like this : >>VariableSelectorGuiManager.setConfiguration(myInstance) è this is passed as >>static. >>Then, The VariableSelectorGui class gets the configuration instance an >>display the fields depending on the parameters of the configuration instance. >>The problem is the following : >>-We have a standard Java HMI (not integrated in Netbeans) in which everything >>works fine. >>-With the Netbeans platform, the >> “VariableSelectorGuiManager.setConfiguration(myInstance)” is done in the >> register method of our “ModuleInstall” class. When we try to display the >> VariableSelectorGui, this error is thrown : >>java.lang.LinkageError: loader constraint violation: loader (instance of >>org/netbeans/StandardModule$OneModuleClassLoader) previously initiated >>loading for a different type with name >>"org/apache/commons/configuration/Configuration" >> at java.lang.ClassLoader.defineClass1(Native Method) >> >> >> at >> >>java.lang.ClassLoader.defineClass(ClassLoader.java:760) >> at >> >>org.netbeans.JarClassLoader.doLoadClass(JarClassLoader.java:311) >> at >> >>org.netbeans.ProxyClassLoader.selfLoadClass(ProxyClassLoader.java:259) >> at >> >>org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:217) >> at >> >>java.lang.ClassLoader.loadClass(ClassLoader.java:357) >> at >> >>fr.variable.selector.component.VariableSelectorGui.getCenterPane(Variab >> leSelectorGui.java:562) >> at >> >>fr.variable.selector.component.VariableSelectorGui.createComponent(Vari >> ableSelectorGui.java:821) >> at >> >>fr.variable.selector.component.VariableSelectorGui.lambda$getComponent$ >> 1(VariableSelectorGui.java:181) >> at >> >>fr.variable.selector.component.VariableSelectorGui$$Lambda$116/70093424 >> 6.run(Unknown Source) >> at >> >>com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.ja >> va:292) >> at >>
TR: java.lang.LinkageError: loader constraint violation: loader
Hi, Yes that is what I think too. I changed my architecture since I posted my issue. I still have the issue but I think the best is to explain the module hierarchy : - I have module A (netbeans module) - the module A has a maven dependency to module B - the module B has a dependency to a library 1 (maven java project which is not a Netbeans module). - the library 1 has dependencies to maven libraries, including commons-configuration. => The library 1 includes some classes and module A has a class which inherits from one of this classes. => In the super class (in library 1), there is an attribute named "configuration" (which is a "org.apache.commons.configuration.Configuration"). => The issue appends when I call a method of the inherited attribute "configuration" in the class of module A. => in module B, the package "org.apache.commons.configuration" has been declared as "publicPackage" in the "nbm-maven-plugin" in the POM. I would have hope that it would be sufficient to avoid that kind of problem, but it is not. The problem must be that module A and module B both add the classes of the apache "commons-configuration" project to their class loader. Bastien -Message d'origine- De : Emilian Bold [mailto:emilian.b...@protonmail.ch] Envoyé : jeudi 15 février 2018 13:13 À : GRYSPEERDT Bastien [CLEMESSY] Cc : us...@netbeans.incubator.apache.org Objet : Re: java.lang.LinkageError: loader constraint violation: loader My guess is that you are bunding twice org/apache/commons/configuration/Configuration (ie. commons-configuration). Maybe you have two modules that have a library wrapper? Or some other external JAR that also bundles it in a fat jar? --emi Original Message On 13 February 2018 4:21 PM, GRYSPEERDT Bastien [CLEMESSY]wrote: > >Hi, > > > > > >I have an application build on the Netbeans Platform that uses some netbeans >modules. > > >These netbeans modules import some subprojects (that are not Netbeans >modules). In one of the subproject, I need to call the >org.apache.configuration.Configuration (from “commons-configuration” Apache >project) class to check that a parameter is true (if it is, I display some >field on a HMI). > > >To set the Configuration install, I do it like this : >VariableSelectorGuiManager.setConfiguration(myInstance) è this is passed as >static. > > >Then, The VariableSelectorGui class gets the configuration instance an display >the fields depending on the parameters of the configuration instance. > > > > > >The problem is the following : > > >-We have a standard Java HMI (not integrated in Netbeans) in which everything >works fine. > > >-With the Netbeans platform, the >“VariableSelectorGuiManager.setConfiguration(myInstance)” is done in the >register method of our “ModuleInstall” class. When we try to display the >VariableSelectorGui, this error is thrown : > > > > > >java.lang.LinkageError: loader constraint violation: loader (instance of >org/netbeans/StandardModule$OneModuleClassLoader) previously initiated loading >for a different type with name "org/apache/commons/configuration/Configuration" > > >at java.lang.ClassLoader.defineClass1(Native Method) > > >at >java.lang.ClassLoader.defineClass(ClassLoader.java:760) > > >at >org.netbeans.JarClassLoader.doLoadClass(JarClassLoader.java:311) > > >at >org.netbeans.ProxyClassLoader.selfLoadClass(ProxyClassLoader.java:259) > > >at >org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:217) > > >at >java.lang.ClassLoader.loadClass(ClassLoader.java:357) > > >at >fr.variable.selector.component.VariableSelectorGui.getCenterPane(Variab >leSelectorGui.java:562) > > >at >fr.variable.selector.component.VariableSelectorGui.createComponent(Vari >ableSelectorGui.java:821) > > >at >fr.variable.selector.component.VariableSelectorGui.lambda$getComponent$ >1(VariableSelectorGui.java:181) > > >at >fr.variable.selector.component.VariableSelectorGui$$Lambda$116/70093424 >6.run(Unknown Source) > > >at >com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.ja >va:292) > > >at >com.sun.javafx.application.PlatformImpl$$Lambda$64/1862576770.run(Unkno >wn Source) > > >at java.security.AccessController.doPrivileged(Native >Method) > > >at >com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImp >l.java:291) > > >at >com.sun.javafx.application.PlatformImpl$$Lambda$63/2029243975.run(Unkno >wn Source) > > >[catch] at >com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher >.java:95) > > >at com.sun.glass.ui.win.WinApplication._runLoop(Native >Method) > > >at >com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java >:102) > > >