Community
Participate
Working Groups
Hi, I have a Java+Maven project with the following dependencies: > <dependency> > <groupId>jakarta.json</groupId> > <artifactId>jakarta.json-api</artifactId> > <version>1.1.6</version> > <scope>provided</scope> > </dependency> > <dependency> > <groupId>org.glassfish</groupId> > <artifactId>jakarta.json</artifactId> > <version>1.1.6</version> > <scope>runtime</scope> > </dependency> With the idea being that only the json-api is available at compile time (preventing me from depending on any implementation classes), and then the full implementation at runtime. In my module-info.java, when I declare 'requires transitive java.json;', Eclipse gives me an error 'java.json cannot be resolved to a module'. If I change my pom.xml to remove the json-api dependency and simply contain: > <dependency> > <groupId>org.glassfish</groupId> > <artifactId>jakarta.json</artifactId> > <version>1.1.6</version> > <scope>compile</scope> > </dependency> The error message goes away. FYI: The json-api jar has a module-info.class declaring 'module java.json', but the glassfish jakarta.json jar does not contain a module-info.class, and has 'Automatic-Module-Name: java.json' in it's MANIFEST.MF file. Version: 2020-03 (4.15.0) Build id: 20200313-1211 Much Thanks!
I tried the following on the command line: $ cat > module-info.java module bug563444 { requires transitive java.json; } $ wget -q https://repo1.maven.org/maven2/jakarta/json/jakarta.json-api/1.1.6/jakarta.json-api-1.1.6.jar $ ecj -9 --module-path jakarta.json-api-1.1.6.jar module-info.java $ ecj -9 -classpath jakarta.json-api-1.1.6.jar module-info.java ---------- 1. ERROR in /tmp/module-info.java (at line 2) requires transitive java.json; ^^^^^^^^^ java.json cannot be resolved to a module ---------- 1 problem (1 error) As you can see, the reported error is raised iff ecj finds the library on the classpath, because then it is not considered as a module. Please inspect your Java Build Path, and check the Maven Dependencies library: is it shown on the Module Path? Can you drill into details of jakarta.json-api? If so, does it have a child-node "Is Modular"?
(In reply to Stephan Herrmann from comment #1) > Please inspect your Java Build Path, and check the Maven Dependencies > library: is it shown on the Module Path? Can you drill into details of > jakarta.json-api? If so, does it have a child-node "Is Modular"? In my project properties "Java Build Path" section... "Libraries" tab: "Modulepath" contains only "JRE System Library" and "Classpath" contains "Maven Dependencies", which has both libraries listed. The json-api says "Is not modular - non modifiable" (visible only for test sources "no"). The glassfish one says "Is modular - non modifiable" (visible only for test sources "yes"). I deleted all the Eclipse related files and re-imported from the pom.xml and it is the same. As far as I know, I have not modified what Maven setup.
Moving to m2e as it is Maven business to infer correct configuration from pom. As for now, try moving "Maven Dependencies" from Classpath to Modulepath, which should fix the problem, until you let m2e refresh the configuration.
Eclipse m2e is moving away from this bugs.eclipse.org issue tracker to https://github.com/eclipse-m2e/m2e-core/issues/ instead. If this issue is relevant to you, your action is required. 0. Verify this issue is still happening with latest Eclipse Platform and m2e release if issue has disappeared, please change status of this issue to "CLOSED WORKFORME" with some details about your testing environment and how you did verify the issue; and you're done if issue is still present when latest release: * Create a new issue at https://github.com/eclipse-m2e/m2e-core/issues/ ** Use as title in GitHub the title of this Bugzilla ticket (may include the bug number or not, at your own convenience) ** In the GitHub description, start with a link to this bugzilla ticket ** Optionally add new content to the description if it can helps towards resolution ** Submit GitHub issue * Update bugzilla ticket ** Add to "See also" property (up right column) the link to the newly created GitHub issue ** Add a comment "Migrated to <link-to-newly-created-GitHub-issue>" ** Set status as CLOSED MOVED ** Submit All issues that remain open will be automatically closed next week or so. Then the m2e component for m2e will be made read-only.
Moved to https://github.com/eclipse-m2e/m2e-core/issues/