After I'd searched the net and similar StackOverflow questions and tried to apply the proposed sollutions I didn't come up with an idea how to fix this error, which gives me pom.xml:
Multiple annotations found at this line:
- Missing artifact jakarta.json:jakarta.json-
api:jar:2.0.0-RC3
- Missing artifact org.glassfish.hk2:hk2-
locator:jar:3.0.0-M2
- Missing artifact org.glassfish:jakarta.json:jar:2.0.0-
RC3
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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 //error appears here
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.gson</groupId>
<artifactId>advanced-jaxrs-01</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>advanced-jaxrs-01 Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-
media-moxy -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>3.0.0-M6</version>
</dependency>
<!--
https://mvnrepository.com/artifact/org.glassfish.jersey.bundles/jaxrs-ri -
->
<dependency>
<groupId>org.glassfish.jersey.bundles</groupId>
<artifactId>jaxrs-ri</artifactId>
<version>3.0.0-M6</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>advanced-jaxrs-01</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven
defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-
bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
I've had a look at .m2/repository and I've noticed, that there are files maven can't find. What should I do? What's the matter?
If there are files that maven can't find, you can always try to install the JAR file and going into
Project folder properties --> Java Build Path --> Add external JARs (Click on Modulepath if you cant immediately press Add External JARs)
Related
I have been trying to set up a JavaFX project to prepare for a school project and I wanted to use Maven to make it easier to share it as it removes the need for configuration as long as the pom.xml file is correctly written.
I can compile the project, run it with javafx:run but when I use the maven jar plugin to generate a JAR I get the following error trying to run it :
Error: Could not find or load main class org.openjfx.App
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
I don't understand why it's not finding the JavaFX classes as I do have the JavaFX Maven plugin as well as the javafx-controls and javafx-fxml dependencies added in the pom.xml
Here's the full file for reference
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openjfx</groupId>
<artifactId>hellofx</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
<javafx.version>19</javafx.version>
<javafx.maven.plugin.version>0.0.8</javafx.maven.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${maven.compiler.release}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.maven.plugin.version}</version>
<configuration>
<mainClass>org.openjfx.App</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<mainClass>org.openjfx.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Does anyone know what I'm missing for the JAR to include the JavaFX classes ? I thought adding the maven plugin was enough.
Thank you
I've been reading online for days and days but i'm still not sure i got the answer I need, or a way to fix this problem.
I have a set of Java tests that are using JUnit5 and Selenium.
This was my pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<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.ces.cursos.timetracker</groupId>
<artifactId>primerosScripts3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>primerosScripts3</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.3.0</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
With it, I was able to run all tests successfully by selecting the package and going into "Run As > JUnit tests"
Now I want to create test suites to organize my tests.
I created a new package, and created a new class inside it with the following code:
package suites;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;
import com.tests.Testing.Test1;
import com.tests.Testing.Test2;
#Suite
#SelectClasses({Test1.class, Test2.class})
public class Suite1 {
}
My first problem was that the #Suite and #SelectClasses annotations were not recognized. I had to add the following dependency to my pom.xml file to be able to use them:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-api</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
Now, when I try to run this suite, I get the "No tests found with test runner JUnit 5" error.
I have a strong suspicion this has to do with my dependencies and JUnit versions, but after reading and reading online I'm not able to understand exactly what I need to do.
I'm a beginner so that might be why i'm having trouble understanding where to go next.
My POM.XML:
<?xml version="1.0" encoding="UTF-8"?>
<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>qaclickacademy</groupId>
<artifactId>Mavenjava</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Mavenjava</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.1.2</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
My maven error output with 0 failures in test cases" even though I added SLF4J jars to my libraries:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
This is the installation procedure I followed for Maven for Eclipse software:
Download MAVEN software from "Binary zip archive" column from https://maven.apache.org/download.cgi
Extract zip file and copy the location of apache-maven-3.3.9:
C:\work\apache-maven-3.3.9-bin\apche-maven-3.3.9
Go to control panel < Adavanced System settings < Adavanced (tab) < Environment Variables < System Variables (column)
Click “New”, then "New System Variable" window pops up, In "Variable Name" field, enter "MAVEN_HOME" and in "Variable value" field, paste the location of apache-maven-3.3.9, click “OK.
Now copy the location of "bin" folder present in "Apache-Maven-3.3.9" folder
and double click "path" in "system variables", click "NEW", then paste it.
The Variable under 3. should be M2_HOME, but this is not really relevant for your issue.
The point is that in one of your dependencies the slf4j-api is referenced. In your tests it searches the classpath for an implementation and does not find one. One countermeasure would be to add logback like this:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
I'm developing a Jersey webapp that serves as a webhook for chatbots, currently I have a generic service that handles the basic connections and now I want to create a specific app webhook that will be able to use the generic service.
I've already added the generic webapp as a maven dependency and can use it in my workspace, but when deploying to tomcat I get error:
[org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError:
.../generic/services/Webhook] with root cause
java.lang.ClassNotFoundException: ...generic.services.Webhook
Generic services pom file:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
</parent>
<artifactId>...-generic-services</artifactId>
<name>...</name>
<groupId>...</groupId>
<packaging>jar</packaging>
<properties>
<jersey.version>2.27</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
...
</dependencies>
<build>
<finalName>...</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
</plugins>
</build>
App services pom file:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
</parent>
<artifactId>...-app-services</artifactId>
<name>...</name>
<groupId>...</groupId>
<packaging>war</packaging>
<properties>
<jersey.version>2.27</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>..generic.services</groupId>
<artifactId>...-generic-services</artifactId>
<version>...</version>
<classifier>classes</classifier>
</dependency>
</dependencies>
<build>
<finalName>...-app-services</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
So what I basically want to accomplish is to be able to call the generic services functions from the app service webapp, so for example if in generic service there is a function that receives and returns a json then I want to be able to make a function like this in app and call the generic service function with a json and receive from it.
You can't add a WAR as a Maven dependency. WAR has a specific layout which is understood by Servlet Containers and JEE Servers. This layout is not understood by other tools e.g. Maven which expects dependencies to be JARs.
This problem is normally solved by extracting either a new services-common Maven module which stores the shared code or moving the Java code outside of the WAR into a new JAR Maven module.
You can try using WAR Overlays to achieve what you want but it won't be as clean as extracting new JAR Modules.
I use maven-android-plugin, and I get duplicate dependency.
I don't know which dependency should be exclude.
My pom.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.hello</groupId>
<artifactId>gs-maven-android</artifactId>
<version>0.1.0</version>
<packaging>apk</packaging>
<properties>
<!-- use UTF-8 for everything -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>5.14</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.9.0-rc.1</version>
<configuration>
<sdk>
<platform>19</platform>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
<extractDuplicates>true</extractDuplicates>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
I get below error when I use mvn package:
[INFO] UNEXPECTED TOP-LEVEL EXCEPTION:
[INFO] java.lang.IllegalArgumentException: already added: Lorg/apache/commons/logging/impl/NoOpLog;
I search this information, it seems that there are duplicate library. Now, I think:
Maven should deal with this problem, right?
I find the command causing error below, I do not find duplicate library.
/bin/sh -c cd /Users/diplab/Documents/workspace/engineonandroid &&
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java
-Xmx1024M -jar /opt/Android/android-sdk-macosx/build-tools/19.1.0/lib/dx.jar --dex
--output=/Users/diplab/Documents/workspace/engineonandroid/target/classes.dex
/Users/diplab/.m2/repository/org/springframework/spring-asm/3.1.2.RELEASE/spring-asm-3.1.2.RELEASE.jar
/Users/diplab/.m2/repository/javax/mail/mail/1.4.1/mail-1.4.1.jar
/Users/diplab/.m2/repository/org/springframework/spring-core/3.1.2.RELEASE/spring-core-3.1.2.RELEASE.jar
/Users/diplab/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.9.9/jackson-core-asl-1.9.9.jar
/Users/diplab/.m2/repository/org/slf4j/slf4j-api/1.7.2/slf4j-api-1.7.2.jar
/Users/diplab/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
/Users/diplab/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
/Users/diplab/Documents/workspace/engineonandroid/target/classes
/Users/diplab/.m2/repository/org/activiti/activiti-bpmn-converter/5.14/activiti-bpmn-converter-5.14.jar
/Users/diplab/.m2/repository/org/mybatis/mybatis/3.2.2/mybatis-3.2.2.jar
/Users/diplab/.m2/repository/joda-time/joda-time/2.1/joda-time-2.1.jar
/Users/diplab/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar
/Users/diplab/.m2/repository/org/springframework/spring-beans/3.1.2.RELEASE/spring-beans-3.1.2.RELEASE.jar
/Users/diplab/.m2/repository/org/activiti/activiti-engine/5.14/activiti-engine-5.14.jar
/Users/diplab/.m2/repository/org/apache/commons/commons-email/1.2/commons-email-1.2.jar
/Users/diplab/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.2/jcl-over-slf4j-1.7.2.jar
/Users/diplab/.m2/repository/org/activiti/activiti-bpmn-model/5.14/activiti-bpmn-model-5.14.jar
What should I do?