Skip to content
This repository has been archived by the owner on Jan 21, 2019. It is now read-only.

Project depends on packages not accessible at runtime #11

Open
forman opened this issue Aug 27, 2015 · 4 comments
Open

Project depends on packages not accessible at runtime #11

forman opened this issue Aug 27, 2015 · 4 comments

Comments

@forman
Copy link

forman commented Aug 27, 2015

My NB platform application has two modules A and B:

  • NB module A has a dependency on a plain JAR which embeds classes whose package paths start with "javax.xml".
  • NB module B has a dependency on NB module A and makes use of classes from "javax.xml.*". Then the NBM build fails.

In the attached(?) show case module A is "private_classes_bug-sample" and module B is "private_classes_bug-sample2". Module A includes jython-standalone.jar which embeds javax.xml.*. Module B makes use of the class javax.xml.transform.TransformerException.

$ cd private_classes_bug
$ mvn clean package
...
[INFO] Private classes referenced in module: [javax.xml.transform.TransformerException]
[ERROR] Project depends on packages not accessible at runtime in module com.mycompany:private_classes_bug-sample:jar:1.0-SNAPSHOT
[INFO]-----------------------------------------------------------------------
...

See also https://netbeans.org/projects/platform/lists/dev/archive/2014-11/message/24

@mkleint
Copy link
Contributor

mkleint commented Aug 28, 2015

do you know what is the reason for shipping classes from jdk as part of a binary? AFAIK you might get weird problems at runtime as well, because A. the base netbeans classloader will contain the class through jdk bootstrap. B. one of the modules will contain the same class but load it though a different classloader (the module one)

@forman
Copy link
Author

forman commented Aug 31, 2015

I guess Jython embeds javax.xml for supporting JRE versions that don't come with javax packages. Maybe I should wrap the Jython library into an NBM so that the javax stuff is truly private for Jython?

@Enkuushka
Copy link

Hello @mkleint I have a problem while writing module which wraps dependencies.

I have 2 modules which both use Library A. But when I add Library A as dependency to each of the modules on the runtime it is showing " LinkageError: loader constraint violation: loader (instance of org/netbeans/StandardModule$OneModuleClassLoader) previously initiated loading for a different type with name "com/org/lib...."

And when I make 1 module which exports Library A as a public package. (Even the button for making public is not available, I just added to the pom.xml directly and it appeared in the Public packages tab)
And still not compiling.

And then I added "OpenIDE-Module-Public-Packages" to the module manifest. But also not working.

Can you provide any working example pom.xml file?

@mkleint
Copy link
Contributor

mkleint commented Jul 31, 2016

@Enkuushka The general approach is to have Module B wrap library A and then have modules C,D,E depend of module B rather than library A. The mentioned module needs to expose public packages of the library though. http://www.mojohaus.org/nbm-maven-plugin/manifest-mojo.html#publicPackages Just verify that the module when build actually has the relevant entry in the jar's manifest. Also check that your nbm file contains the library A binary.

As far as examples go, I have one for public packages - https://bitbucket.org/mkleint/nb-atlassian-dev/src/d8595132353c96bb2b0031d95eb6e0ab625a6439/atlassian-common/pom.xml?at=default&fileviewer=file-view-default but it doesn't do public packages from a library, but that should be irrelevant. Alternatively try searching for sources of other maven netbeans platform apps.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants