Introduction
In this article, the main focus is to be able to solve the error message as it exist in the title of this article. So, upon the execution for compiling and building the Java web-based application using NetBeans IDE, an error message appear. The appearance of the error message exist in the output tab of the Netbeans IDE. The following is the appearance of that error message :
Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.6:copy (default) on project app: Unable to find artifact version of javax:javaee-api in either dependency list or in project's dependency management. -> [Help 1]
Actually, the error appear as the consequence of editing the ‘pom.xml’ file. The original ‘pom.xml’ file exist as follows :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.web</groupId> <artifactId>app</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>app-1.0-SNAPSHOT</name> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <failOnMissingWebXml>false</failOnMissingWebXml> <!--<jakartaee>8.0</jakartaee>--> </properties> <dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${jakartaee}</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> <compilerArguments> <endorseddirs>${endorsed.dir}</endorseddirs> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.6</version> <executions> <execution> <phase>validate</phase> <goals> <goal>copy</goal> </goals> <configuration> <outputDirectory>${endorsed.dir}</outputDirectory> <silent>true</silent> <artifactItems> <artifactItem> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${jakartaee}</version> <type>jar</type> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
Solution
The article itself has a relation with the previous article available before. That article is an article with the title of ‘How to Solve Error Message Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.3:war (default-war) on project app: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.3:war failed: Unable to load the mojo ‘war’ in the plugin ‘org.apache.maven.plugins:maven-war-plugin:2.3’ due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: null when compiling and building Java Web Application in NetBeans’. Furthermore, that article exist in this link. Since the Java EE of the new version which is called the Jakarta EE is not compatible with the maven-war-plugin, the fast solution is to comment the declaration. But commenting the javaee-api package is causing aother error appear. So, the error appear when the above ‘pom.xml’ for declaring javaeee-api is being commented. The commented part exist above as in the following appearance :
<properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <failOnMissingWebXml>false</failOnMissingWebXml> <!--<jakartaee>8.0</jakartaee>--> </properties> <dependencies> <!-- <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${jakartaee}</version> <scope>provided</scope> </dependency> -->
As an assumption, the reason for commenting the above part is because in the Java-based web application, the usage of the Java EE API with the version of Jakarta EE is not compatible with one of the other package dclaration. Mainly, the package of maven-war-plugin which is very important to generate war file for further deployment.
Solution
Since it is a Java-based web application using Java EE technology, it need another Java EE package version declaration in the ‘pom.xml’ file. Since in the previous article, it ends in failure to use the new version of the Java EE which is Jakarta EE, the solution is to comment the Jakarta EE declaration. This link explains the difference between Java EE and Jakarta EE. Change the Jakarta EE to an old one as one of the solution if Jakarta EE or the new Java EE version is not important for the usage. As long as using the old one or the Java EE is not really matter at all. The Java EE declaration exist as follows :
So, the following is the modification of the ‘pom.xml’ using the old Java EE instead of the Jakarta EE :
<dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>8.0</version> <scope>provided</scope> </dependency>
Overall modification by adding the above Java EE version in the ‘pom.xml’ file will be available as follows :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.web</groupId> <artifactId>app</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>app-1.0-SNAPSHOT</name> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <failOnMissingWebXml>false</failOnMissingWebXml> <!--<jakartaee>8.0</jakartaee>--> </properties> <dependencies> <!-- <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${jakartaee}</version> <scope>provided</scope> </dependency> --> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>8.0</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> <compilerArguments> <endorseddirs>${endorsed.dir}</endorseddirs> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.3</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.6</version> <executions> <execution> <phase>validate</phase> <goals> <goal>copy</goal> </goals> <configuration> <outputDirectory>${endorsed.dir}</outputDirectory> <silent>true</silent> <artifactItems> <artifactItem> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <!--<version>${jakartaee}</version>--> <version>8.0</version> <type>jar</type> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>