I put them default_options in a custom app.conf file using https://bits.netbeans.org/mavenutilities/nbm-maven-plugin/nbm-maven-plugin/cluster-app-mojo.html#etcConfFile .
Maybe we should consider adding the minimum required from what the Wizards generates to the default file? This will also require another PR for the harness used by nbm-maven-plugin. https://github.com/apache/netbeans/blob/master/harness/apisupport.harness/release/etc/app.conf --Christian On Thu, Feb 16, 2023 at 11:58 AM Claudio Rosati <claudio.ros...@mac.com.invalid> wrote: > Thank you Michael for your answer. > > I have imagined that some “--add-opens” and “--add-exports” should have > been added. The real problem was where add these flags. The jms-config link > was anyway very useful to have a set of flags ready to be copyed. > > However, digging a bit here and there I’ve found where to hadd the flags > for the Ant-based RCP app, and for the Maven based too. I’ll add > instructions here for completeness (possibly the following instructions > should be added to the “NetBeans Platform Quick Start” and “NetBeans > Platform Quick Start Using Maven” documentation pages). > > > Ant-based RCP app > ----------------- > > In the application module's “project.properties” file add the > “--add-opens” and “--add-exports” directives to the “run.args.extra” > property, in my specific situation the following was enough: > > run.args.extra=\ > -J--add-opens=java.base/java.net=ALL-UNNAMED \ > -J--add-opens=java.desktop/javax.swing=ALL-UNNAMED \ > -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED > > > Maven-based RCP app > ------------------- > > Maven-based RCP apps require a little more work. > > In the application module’s “pom.xml” file add the “netbeans.run.params” > property with all “--add-opens” and “--add-exports” directives prefixed by > “-J”: > > <properties> > ... > <netbeans.run.params>-J--add-opens=java.base/java.net=ALL-UNNAMED > -J--add-opens=java.desktop/javax.swing=ALL-UNNAMED > -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED</netbeans.run.params> > </properties> > > The change will allow running the application without problems. Instead > building will fails because the application is run as a > maven-surefire-plugin test, and the added property is not applied, moreover > when the application is run normally the “-Djava.security.manager=allow” is > set, but not when launched in a test. > > To fis those problems, in the same “pom.xml” locate the definition of the > “maven-surefire-plugin”, and to its configuration add the “argLine” > parameter containing “-Djava.security.manager=allow”, and all the > “--add-opens” and “--add-exports” directives without the “-J” prefix: > > <build> > <plugins> > ... > <!-- Permits NbModuleSuite to be run in integration-test phase: --> > <plugin> > <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-surefire-plugin</artifactId> > <version>2.12.2</version> > <configuration> > <argLine>-Djava.security.manager=allow > --add-opens=java.base/java.net=ALL-UNNAMED > --add-opens=java.desktop/javax.swing=ALL-UNNAMED > --add-exports=java.desktop/sun.awt=ALL-UNNAMED</argLine> > ... > </configuration> > </plugin> > ... > </plugins> > </build> > > > I think that the missing “-Djava.security.manager=allow” parameter to the > maven-surefire-plugin should be fixed in the following release of NetBeans, > while some tools to transparently easily allow the user to add/remove > “--add-opens” and “--add-exports” directives could be added in the module > node’s Properties dialog. > > Best regards, > Claudio > > > _____________________________ > > Claudio Rosati > > Calle Tamara 7 > Villa Jinámar > 35220 Telde, Gran Canaria > España > Skype: claudio.rosati > Phone: +34 638 579 990 (mobile) > E-mail: claudio.ros...@mac.com > _____________________________ > > EMAIL CONFIDENTIALITY NOTICE > This message is private and confidential. > If you have received this message in error, > please notify me and remove it from your system. > _____________________________ > > > > > > On 16 Feb 2023, at 10:47, Michael Bien <mbie...@gmail.com> wrote: > > > > this is caused by encapsulation violations of the java module system, > see JEP 396. If you run it on JDK 15 or older, you should see warnings, > anything after that will throw exceptions. > > > > Some NetBeans modules need direct access to JDK modules. > > > > NetBeans-the-IDE sets the following flags: > > https://github.com/apache/netbeans/tree/master/nbbuild/jms-config > > > > NetBeans RCP apps won't need all of those flags, since they usually use > a subset of the modules NetBeans uses. > > > > there should be many blog entries online about this topic since it isn't > really NB specific, > > > > best regards, > > michael > > > > > > On 16.02.23 11:34, Claudio Rosati wrote: > >> Hello all, > >> > >> After some years not using NetBeans RCP (only de IDE), I’ve tried to > follow the "NetBeans Platform Quick Start Using Maven” using NetBeans 16 > with Java 19. > >> > >> When I try to "Build with Dependencies” the app the following error > appears at compilation time: > >> > >> Running es.intellectusetanima.mavenplatformwordapp.ApplicationTest > >> Feb 14, 2023 1:09:17 PM org.netbeans.ProxyURLStreamHandlerFactory > register > >> SEVERE: No way to find original stream handler for jar protocol > >> java.lang.reflect.InaccessibleObjectException: Unable to make field > transient java.net.URLStreamHandler java.net.URL.handler accessible: module > java.base does not "opens java.net" to unnamed module @7e0ea639 > >> at > java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387) > >> at > java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363) > >> at > java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311) > >> at > java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:180) > >> at java.base/java.lang.reflect.Field.setAccessible(Field.java:174) > >> at > org.netbeans.ProxyURLStreamHandlerFactory.register(ProxyURLStreamHandlerFactory.java:59) > >> at org.netbeans.JarClassLoader.<clinit>(JarClassLoader.java:142) > >> at org.netbeans.MainImpl.execute(MainImpl.java:153) > >> at org.netbeans.MainImpl.main(MainImpl.java:60) > >> at org.netbeans.Main.main(Main.java:58) > >> at > java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) > >> at java.base/java.lang.reflect.Method.invoke(Method.java:578) > >> at > org.netbeans.junit.NbModuleSuite$S.runInRuntimeContainer(NbModuleSuite.java:906) > >> at > org.netbeans.junit.NbModuleSuite$S.access$100(NbModuleSuite.java:661) > >> at > org.netbeans.junit.NbModuleSuite$S$1.protect(NbModuleSuite.java:682) > >> at junit.framework.TestResult.runProtected(TestResult.java:142) > >> at org.netbeans.junit.NbModuleSuite$S.run(NbModuleSuite.java:678) > >> at > org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90) > >> at > org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) > >> at > org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) > >> at > org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) > >> at > java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) > >> at java.base/java.lang.reflect.Method.invoke(Method.java:578) > >> at > org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) > >> at > org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) > >> at > org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) > >> at > org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:113) > >> at > org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) > >> > >> If I try to run the app, I have the previous error plus the following: > >> > >> java.lang.IllegalAccessException: class org.netbeans.TopSecurityManager > cannot access class sun.awt.AppContext (in module java.desktop) because > module java.desktop does not export sun.awt to unnamed module @5cc73178 > >> at > java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:420) > >> at > java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:709) > >> at java.base/java.lang.reflect.Method.invoke(Method.java:569) > >> at > org.netbeans.TopSecurityManager.makeSwingUseSpecialClipboard(TopSecurityManager.java:714) > >> at > org.netbeans.core.NbLifecycleManager.advancePolicy(NbLifecycleManager.java:71) > >> at org.netbeans.core.GuiRunLevel.run(GuiRunLevel.java:84) > >> at org.netbeans.core.startup.Main.start(Main.java:316) > >> at > org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:98) > >> at java.base/java.lang.Thread.run(Thread.java:1589) > >> > >> Anyway, the application starts. > >> > >> The same happens using the alternative way of building an RCP app (i.e. > using Ant-based development, as in NetBeans Platform Quick Start for > NetBeans Platform). > >> > >> Now, how can I get rid of these errors? Do I need a moodule-info.java > file? If yes, where? Otherwise? > >> > >> Claudio > >> > >> > >> _____________________________ > >> > >> Claudio Rosati > >> > >> Calle Tamara 7 > >> Villa Jinámar > >> 35220 Telde, Gran Canaria > >> España > >> Skype: claudio.rosati > >> Phone: +34 638 579 990 (mobile) > >> E-mail: claudio.ros...@mac.com > >> _____________________________ > >> > >> EMAIL CONFIDENTIALITY NOTICE > >> This message is private and confidential. > >> If you have received this message in error, > >> please notify me and remove it from your system. > >> _____________________________ > >> > >> > >> > >> > >> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscr...@netbeans.apache.org > > For additional commands, e-mail: dev-h...@netbeans.apache.org > > > > For further information about the NetBeans mailing lists, visit: > > https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists > > > > > > > >