How to add maven dependencies of json to modules in >= Java 9 - java

in java 8 projects you simply add the following dependencys in maven
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1</version>
</dependency>
Using OpenJDK, Eclipse 2018-12
and maven module, it results in getting a error in the module-info.java:
The package javax.json.stream is accessible from more than one module:
java.json, org.glassfish.java.json
So in both dependency projects there is a package called javax.json.stream and due to jigsaw module system this is not allowed anymore?
How to fix this?
EDIT:
I updated the maven dependency to 1.1.4 and put them on the classpath.
The javax.json-api has a module-info.java file and is working fine, eclipse shows no more errors.
But now the packages of the implementation javax.json (org.glassfish) are not found, resulting in a ClassNotFoundException: org.glassfish.json.JsonProviderImpl
What more can I do?
EDIT:
Its working now, i forgot to generate a module-info.java in this project.

So in both dependency projects there is a package called
javax.json.stream and due to jigsaw module system this is not allowed
anymore?
This is still allowed, but with both those dependencies getting resolved on the classpath instead of modulepath i.e. in the unnamed module.
Another alternative to fix this while you create your library as modular is to make sure to fix the downstream libraries exporting the same package which would require a bottom-up migration and you might have to wait for them to fix it in their latest update(or check if one is already out) and then to rely on them.

Related

How do I use MediaView and WebView in java fxml? There's no option to import them anymore [duplicate]

I am trying to build a virtual piano app where i need the MediaPlayer class to play the notes, my project is a modular maven project with fxml, javafx 11.0.2 and java 14.
The problem that i can not import the MediaPlayer class, i tried to add requires javafx.media; to my module-info.java but it doesn't recognize it anyways.
Here is my module-info.java
module org.project {
requires javafx.controls;
requires javafx.fxml;
opens org.project to javafx.fxml;
exports org.project;
}
Also tried to download the library jar but it is empty.
Also tried to add a maven dependency in the pom.xml file as following:
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx.media -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx.media</artifactId>
<version>11.0.0-ea1</version>
<type>pom</type>
</dependency>
My pom.xml dependencies:
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx.media -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx.media</artifactId>
<version>15</version>
<type>pom</type>
</dependency>
</dependencies>
and it shows that the repository is not found.
Note: This answer applies to other JavaFX modules such as fxml and web, as well.
javafx.media is a module, you need to require it in your module-info.java like you do for javafx.controls and javafx.fxml.
module org.project {
requires javafx.controls;
requires javafx.fxml;
requires javafx.media;
opens org.project to javafx.fxml;
exports org.project;
}
There may be other issues, but that is a likely one.
I don't recommend using the 11.0.0-ea1 release, there are later more stable versions. Latest stable release of JavaFX is 15 https://mvnrepository.com/artifact/org.openjfx/javafx-media/15, so I would advise you use that for all of your JavaFX dependencies.
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx.media -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>15</version>
<type>pom</type>
</dependency>
For later readers referring to this post, please use the most up to date non-early access release you can find using mvnrepository or a similar search tool.
tried to download the library jar but it is empty
Don't do this for JavaFX dependencies. JavaFX needs to include both native libraries and Java libraries. Just downloading Jar files may not work for you as you may be missing required stuff. Plus there may be transitive imports for libraries required which, again, just downloading a single jar won't pick up. You are already using a dependency hierarchy build tool in Maven, just configure and use it correctly and let it do its job.
Additionally, I think the javafx.media artifact was incorrectly named, configured and uploaded to maven central, which is why it only existed there as a 11.0.0-ea1 version. It should have been named javafx-media, which it is on subsequent uploads, so use the correct name for the artifact and then the most recent versions are there which include all the correct artifact data in the maven central repository.
My pom.xml dependencies
Your pom.xml dependencies mix JavaFX versions for different JavaFX dependencies. Don't do this, the different versions won't be compatible. Use the same version for all JavaFX dependencies.
i went to file> project structure > libraries > add library "java", opened the path where i installed my javafx > lib and chose javafx.media, then module-info.java could recognize it.
You should have your IDE re-import the updated maven project and auto-resolve the dependencies, not add the libraries manually to the IDE project.
For Idea, see:
How can I make IntelliJ IDEA update my dependencies from Maven?
For other IDEs the procedure will differ.
If you want to use WebView, or FXML or Controls, then use the sample module and dependency names here.
All steps for usage of these modules are the same as for the javafx.media module, only the names change.
Sample module names:
javafx.web
javafx.swing
javafx.fxml
javafx.media
javafx.controls
Sample dependency artifact names:
javafx-web
javafx-swing
javafx-fxml
javafx-media
javafx-controls
I found my mistake, i needed to add javafx.media from directory where i installed javafx, like this C:\Program Files\openjfx-14.0.2.1_windows-x64_bin-sdk\javafx-sdk-14.0.2.1\lib
to achieve that i needed to go to file > project structure
then i chose the javafx.media.jar
after doing this module-info.java could recognize the module.

Maven modules use different versions of same library and parent compile gives error

I have a springboot project which uses package javax.servlet from org.apache.tomcat.embed:tomcat-ember-core9.0.34. (this is coming from springboot)
I have another maven project (API project) which uses this javax.servlet but with version 2.3
Now I have created a parent maven project which includes above 2 projects as modules.
When I individually compile the springboot project, everything is fine.
But when I compile the parent project, it takes the javax.servlet.api version 2.3 to compile the springboot project and gives error, since a method is not available in 2.3 which is being used by springboot.
How to solve this?
Please find a sample source code here: https://github.com/abmjunaed/maven-multi-project-error
I have added very minimal code to reproduce the scenario so that you can have a look and help!
In the External Libraries of IntelliJ, I can see both libs and maven from the parent project is taking the javax-servlet-api:2.3 to compile the springBoot project and giving the error
You should put the correct version of the javax.servlet dependency in the parent module's pom.This will override the javax.servlet dependency mentioned in the api project. To find the correct version you will have to hit and try with javax.servlet versions , the latest spring boot package for this should support version 2.3. Give it a try!!
Found the solution and I can't believe it!
Dependency to spring-boot-starter-web was after the dependency of the library project and that was causing the problem.
Now I have added
spring-boot-starter-web
as the first dependency and
lib-project
as the 2nd dependency and everything works fine!
<dependencies>
<dependency> <!--1st dependency-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>library</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>
</dependencies>

Eclipse is confused by imports ("accessible from more than one module")

When referencing simple .jar files, Eclipse shows an error stating:
The package java.awt is accessible from more than one module: <unnamed>, java.desktop
This happens for instance when javax.awt or javax.swing is included in the .jar files.
The simplest example would be the following:
package test;
import javax.swing.JDialog;
public class Test {
public static void main(String[] args) {
new JDialog();
}
}
Adding a .jar file to the classpath with only the folder structure javax/swing (no files needed) will cause the error to appear. I'm using JDK 10/12 (neither works). Setting the compiler compliance to 1.8 makes the whole thing work again.
On another machine with Eclipse 2018-09 this works with compiler compliance set to 10.
I'm on Eclipse 2019-03, on a (for testing purposes) freshly installed Eclipse 2018-09 it works fine. Why?
Edit June/2020 (Solution)
As the answers correctly stated, this is a restriction built into Java ages ago and only recently was forced upon us. I came into contact with it while migrating a big project with dozens of dependencies to Maven. There were libraries from around the year 2000! There were 'meta libraries' which consisted of several libraries packaged together.
So there was no other way than to identify what was still needed (into the trash with the rest!), update libraries which violate the rules or find replacements for them. This took me many, many hours.
In the end it worked out and we've got a nice Maven project to work with.
This is caused by
a JAR on the Classpath that contains the package java.awt that also exists in the system library but the
JRE System Library is on the Modulepath
In the Java Platform Module System (JPMS) it is not allowed to use the same package in more than one module. If the Modulepath and the Classpath is used, everything on the Classpath is handled as the <unnamed> module (in your case the package java.awt exists in the system module java.desktop and also via the JAR on the Classpath in the module <unnamed>).
Since the JRE System Library cannot be moved from the Modulepath to the Classpath (see this answer by Stephan Herrmann for details), you only have the following options:
Set the compiler compliance to 1.8 (as you already mentioned)
Rebuilt the JAR to avoid Java system library package names inside the JAR (if reflection is used, additional code changes may be necessary):
If you have the source code, change the package names (e.g. change the package and subpackae java to java_util and javax to javax_util) and recreate the JAR
If you have only the .class files you have to decompile the .class files first
Since I'll bet lots of people will be running into this problem with modular Java, I'll help and give the real answer.
This error happens when
you have a dependency in your project
that contains code
using packages
that are also in the modules
being referenced by your project
If your project has set the source compatibility to something like Java 12, it will start enforcing the rule, that has been there all along in Java:
"Don't use packages that belong to the JDK in your own code."
Unfortunately, lots of developers and vendors have done that over the years. Can't do that anymore.
If you set your project to Java 12 source compatibility, Eclipse adds the JDK modules which include everything "java.*" and "javax.*" and even "jdk.*", "org.w3c.*". These packages may be in use by your dependencies or their transitive dependencies.
How to fix
You need to:
look at which package its complaining about
and expand the "Projects and External Dependencies" node in the Package Explorer.
Find out which dependency is using that package.
Then you can simply exclude that dependency from your project.
Or you could get the source of that dependency, if available, and rebuild the jar with changed packages. Otherwise you have to remove that dependency and find a replacement for that technology. Pain huh?
If its a transitive dependency you can often just exclude it. Here is an example of that for Gradle based projects.
GradleConfig.xml:
configurations {
all*.exclude group: 'xml-apis'
}
In my case, it was because I included a dependency (Apache Tika) in the POM.xml file.
I had to force the exclusion of the module that contained the classes with errors while imported at that dependency:
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>1.24.1</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
It worked for me that way.
I found a simple solution to troubleshoot this in Eclipse. Hit Ctrl + Shift + T in Eclipse to open the Open Type prompt. Then type the name of the package that is causing the issue. For me, it was org.w3c.dom. Now the search results will show all the locations from where this package is being loaded. Remove every JAR from the classpath that comes in the result other than the JDK 11 library.
My project being a legacy one, I had to remove a lot of JARs from the build path. Also, my project does not use Maven. So removing the JARs was a fairly straightforward step. The steps might vary for other build tools like ANT, Maven, Gradle, etc. I have just explained the troubleshooting steps above.
See also: The package org.w3c.dom is accessible from more than one module: <unnamed>, java.xml where I answered:
Disappointingly I don't see any compiler flags to show what jar the problem is with
Even -Xlint:module doesn't seem to show up anything useful and eclipse doesn't shed any light on the issue
Instead to find where java.awt comes from I've been using this script:
mvn dependency:copy-dependencies -DincludeScope=test -DoutputDirectory=deps
for i in deps/*.jar; do if unzip -l $i| grep -q java.awt; then echo $i; fi ; done
Strictly you don't have to specify the scope test as that's the default but I've included it as you might want to use compile instead
I think my flavour of the problem might be useful.
I got this error for classes under javax.xml.stream, by old Maven projects that depend on artifacts like xml-apis, stax-api, or geronimo-stax-api.
Technically, the problem is what others have already said: those artifacts expose the javax.xml.* package without any awareness of Java modules (they were invented later), so the package is automatically assigned to the unnamed module, which conflicts with the same package being included in the JDK's most recent versions, where the package has its own module name, and therefore the same package results in two different modules, which is forbidden.
That said, the practical solution is essentially to work with Maven exclusions to remove those dependencies from your project and let it use the JDK version instead (or, of course, remove them as direct dependencies, if that's your case). Use the equivalent if you're working with another build system.
In theory, the more recent flavours of these packages offered by the JDK might be non backward-compatible, in practice, I doubt such JSR specifications changed much over the years and so far, I haven't seen any issue with their replacement.
Since this is ranks quite high on Google I'm going to drop this here in case it's helpful for someone.
I've found some interesting behaviour with Java 11 and the xmlbeans library. The xmlbeans library is a transitive dependency of Apache POI, a very popular library for working with Microsoft Office documents, it is used to handle the internal XML structures of the newer Office formats. I've tested it with Apache POI 3.9 and it works perfectly fine, despite the error shown by Eclipse. So, I guess in Java 11 this rule it's not fully enforced.
For Apache POI version 5.0.0 using Maven, in the pom.xml:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.0.0</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
Fixed: "The package javax.xml.parsers is accessible from more than one module"
I met a similar issue with the eclipse IDE while upgrading JDK from 1.8 to 11, "The package org.w3c.dom is accessible from more than one module: , java.xml". upgrading eclipse from 2019 to 2021 and setting system JDK home to 11 does not solve it. I don't think it's caused by "org.w3c.dom" existing in different jars of the classpath,dut to "Order and Export" should ordered the search sequence.
After several hours of searching and investigating, this issue is fixed by setting the Java Compiler - Compiler compliance level to 1.8(default is 11).
You can do what other people suggest which is to exclude xml-apis which worked fine with me, but if your are using and an old jaxb-api replace them with jakarta.xml.bind-api:
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
and of course upgrade your jaxb-impl to match the same api:
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.3</version>
</dependency>
Steps below helped me,
Right click Eclipse project > Properties > Java Build Path
In Libraries tab, remove all the external jar files under Modulepath and add them under Classpath (you can just select all the jars and drag them under Classpath)
Click Apply and Close
Hope it help you too.
Wow, this was a tough one!
Some helpful tips (a summary of my journey through this maze):
This started when I migrated from Java 1.8 to 11.0.11
Right out of the gate this caused problems. I needed to change the syntax for how to specify the Java version for the maven build plug in as shown below:
Before
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
After
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
After that, everything compiled at a command prompt. However, when opening the project in Eclipse, I got a bunch of errors as shown in the next section.
Getting "<class> cannot be resolved to a type" errors
When I got errors in Eclipse and not at the command line I immediately started looking at configuration settings in Eclipse to no avail. After some googling I came to this post. The post at https://www.eclipse.org/forums/index.php/t/1110036/ was also very helpful.
Finding what resources were the problem
The answer to this post by #Anu suggesting using <shift><ctrl>T to bring up the type search window was very helpful using this I was able to see what resources were causing the problem (i.e. any resource that is also included in the JDK, in my case it was the ErrorHandler in the xml-apis jar). Type the name of one of the resources giving a "cannot be resolved to type" to see the name of the jar file, in my case the jar is xml-apis-1.4.01.jar.
All of this is shown in the screen shot below (click on the image to get a cleaner view).
Finding the Dependency that contains the offending jar
We can now use the information from https://www.eclipse.org/forums/index.php/t/1110036/ to find the dependency in our pom.xml file that contains the offending resource.
Open the pom.xml file in Eclipse and select the "Dependency Hierarchy". In the filter type the name of the jar file we found in the previous step (in my case it was xml-apis).
This will pull up the dependencies creating the problem. A screen shot of the Dependencies Hierarchy filtered for "xml-apis". From this we can see the offending dependencies in our pom.xml file are xercesImpl and xlsx-streamer.
Solving the problem
We can now add exclusions to these dependencies that will resolve the problem as shown below.
<dependency>
<groupId>com.monitorjbl</groupId>
<artifactId>xlsx-streamer</artifactId>
<version>2.1.0</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.12.0</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
And this fixes the current problem.
For anyone who suffer with this problem when refering to the org.w3c or javax.xml imports, be careful with this one module dependency: xml-apis it conflicts with java default xml classes.
One big project who references it is called DynamicJasper
Here's the image of my app
It seems to me the real problem here is that the JDK (in my case, JDK-19) has org.w3c.dom embedded in it, so everything else that was doing the correct thing by referencing libraries from external-lib, rather than embedding is now broken. I removed xml-apis and xerces, but it still complains about org.w3c.dom. the only place it is referenced in my project is the JDK.
Removing jar files, (xml-apis.jar and xerces_2_5_0.jar) Does not fix the issue. I cannot remove batik, project depends upon it.
I have a standard Java build, no maven. There is no decompiling/removing a valid reference that can be done with 3rd party software like batik.
Any suggestions on how to remove the embedded org.w3c.dom from JDK-19 so I can build?
I had this problem with the Stanford Core NLP package. As mentioned above adding an exclusion in the pom.xml solved the problem:
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>4.5.2</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
First of all, make sure your pom is actually correct by running
mvn install
if that works, and eclipse still complains look at build path and find the library it is holding onto that is not in your pom.
Sometimes I just
rm .classpath
rm -rf .settings
rm -rf project
mvn eclipse:clean eclipse:eclipse

Java 10: Replacement for java.xml.ws conflict

I have to use java.xml.ws* components in my project but because it's deprecated and will be removed soon I want to use replacement for these components. So I added this dependency to my project's pom file:
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.0</version>
<type>pom</type>
</dependency>
This is my module configuration:
module x.y.z {
requires kotlin.stdlib;
requires spring.boot;
requires spring.boot.autoconfigure;
requires spring.context;
requires cxf.core;
requires cxf.rt.frontend.jaxws;
requires java.xml.ws;
}
But there is an error:
What does it mean and how to fix it so I can use my dependency above instead of java.xml.ws from jdk?
Just use Java 11 :) There is no javax.xml.ws module there, so no conflict.
As for Java 10, the easiest workaround is to change the scope of jaxws-ri to runtime:
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.0</version>
<scope>runtime</scope>
</dependency>
By adding requires java.xml.ws you tell the module system that you depend in the deprecated Java EE module java.xml.ws, which it will then resolve and make available. At the same time there seems to be a module of the same name on the module path. (Maybe a JAR pulled in by jaxws-ri?)
Although, come to think of it, I would have expected a compiler message complaining of duplicate modules... It looks like the error (is it compiler or runtime?) comes from an IDE. What happens if you run the build with Maven?
Anyways, if you are willing to start with Java 11, you could give that a try. The Java EE modules are removed, so there is no chance of a platform module interfering. I'm not sure whether it is possible to add a java.* module on the module path, though.
If it is not or you prefer to stick to Java 10, you should take a look at upgreadable modules and the --upgrade-module-path option. That way you can use the JARs that provide the JAX WS API to replace the platform module.

Maven dependencies for IBM Websphere packages

I'm trying to convert a "classic" JAVA EE project, using IBM websphere 8.0.0.5, into a maven multi module project and facing issues with the IBM dependecies.
We use IBM classes from the following packages:
com.ibm.websphere.asynchbeans
com.ibm.websphere.scheduler
com.ibm.websphere.ce.cm
com.ibm.ws.asynchbeans
com.ibm.ws.util.ThreadPool
To get my local project to be compiled I downloaded the was.installer-8.0.0.pm from IBM and installed it to my maven using
mvn install -f "was.installer-8.0.0.pom" -D serverInstallationFolder="C:\Program Files (x86)\IBM\WebSphere\AppServer"
This step was successfull according to command line output.
I then added the following dependencies to my project as described from IBM:
In parent:
<dependency>
<groupId>com.ibm.tools.target</groupId>
<artifactId>was</artifactId>
<version>8.0.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
In module:
<dependency>
<groupId>com.ibm.tools.target</groupId>
<artifactId>was</artifactId>
</dependency>
But I still can't compile my project as the IBM packages are not found.
Can anyone help me to find and correct a mistake I made?
Edit
After following BevynQ tip from the comments I copied the "was_public.jar" to "was_public-8.0.0.jar" (described at IBM here) and added it to my repository:
mvn install:install-file -Dfile="C:\Program Files (x86)\IBM\WebSphere\AppServer\dev\was_public-8.0.0.jar" -DpomFile="C:\Program Files (x86)\IBM\WebSphere\AppServer\dev\was_public-8.0.0.pom"
I then changed the dependencies to:
<dependency>
<groupId>com.ibm.websphere.appserver</groupId>
<artifactId>was_public</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.websphere.appserver</groupId>
<artifactId>was</artifactId>
</dependency>
This helped to get the compiling errors for the imports to com.ibm.websphere done.
What I now have still open is the packages com.ibm.ws.* package. Anyone have an idea?
Edit 2
I added the following dependency and then I was rid of the com.ibm.ws.* import errors.
<dependency>
<groupId>com.ibm.websphere.ws</groupId>
<artifactId>com.ibm.ws.runtime</artifactId>
<version>1.0.0</version>
</dependency>
But it still does not compile as now indirectly references can not be found (in my case commonj.work.WorkManager). It seems I need to add further .jars for every single thing. Isn't there an easier way to provide all websphere jars at once as descirbe in the above linked tutorial with the com.ibm.toolsdependency (which do not work)?
In general, com.ibm.websphere are public API for use by applications (this is true of the packages you listed above) which is consistent with these being in was_public.jar
However, com.ibm.ws package is generally product internals. May I ask what interface methods you are using from the com.ibm.ws.asynchbeans package? Maybe there is a public API alternative.
Regarding commonj.work, the only place I can find this in the WebSphere Application Server product image is WAS/plugins/com.ibm.ws.prereq.commonj-twm.jar so it looks like you will need to use that to compile against.
Here's the solution so I solved my dependency problems:
I configured the company repository manager (nexus) as a mirror. In this nexus all ibm packages are present. As you can think that solved the main problem.
I then added the following dependencies according to common maven style:
Dependencies in pom.xml (version numbers extracted to properties):
<dependency>
<groupId>com.ibm.websphere.ws</groupId>
<artifactId>com.ibm.ws.runtime</artifactId>
<version>${ibm.ws.runtime.version}</version>
</dependency>
<dependency>
<groupId>com.ibm.ws.prereq</groupId>
<artifactId>commonj-twm</artifactId>
<version>${ibm.ws.prereq.commonj-twm.version}</version>
</dependency>
Sorry I can't provide a "nice" solution that's useable by all people but the answer from njr and the comment from BevynQ helped at lot to get clearer with the problem and helped to solve the problem in a "more manual" way by copying the needed jars by hand.
I was facing this issue as I tried to build a project using Maven version 3.3.9, running on Java version 1.8.0_101, as depicted in the screenshot:
This is how I resolved it: Step 1. Download the commonj.jar from here.
Step 2. Determine which JDK your Maven is using by typing mvn -version in the command prompt.
Step 3. Go to that directory and place the commonj.jar file there in the jre/lib/ext directory, as shown below. Now your project should build in maven without any issues.

Categories

Resources