In attempting to prepare a personal project for Gitlab CI, I've stumbled across an issue where maven cannot find the io.reactivex.subjects package in the terminal, and as a result, compilation fails like so:
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) # spell-idle ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 24 source files to /home/aschaefer/dev/spell-idle/target/classes
...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project spell-idle: Compilation failure: Compilation failure:
[ERROR] /home/aschaefer/dev/spell-idle/src/com/aps/spells/rx/GuiSubjects.java:[5,29] package io.reactivex.subjects does not exist
[ERROR] /home/aschaefer/dev/spell-idle/src/com/aps/spells/rx/GuiSubjects.java:[6,29] package io.reactivex.subjects does not exist
[ERROR] /home/aschaefer/dev/spell-idle/src/com/aps/spells/rx/GuiSubjects.java:[14,29] cannot find symbol
[ERROR] symbol: class Subject
[ERROR] location: class com.aps.spells.rx.GuiSubjects
[ERROR] /home/aschaefer/dev/spell-idle/src/com/aps/spells/rx
Here's the arguably relevant part of the pom. If anything else is needed, let me know and I'll edit it in:
<dependencies>
<dependency>
<groupId>io.reactivex.rxjava2</groupId>
<artifactId>rxjavafx</artifactId>
<version>2.2.2</version>
</dependency>
... (other dependencies here)
</dependencies>
I've been running various combinations of commands like mvn clean install or mvn compile test but it doesn't seem to help.
Eclipse version of maven is 3.5.3, system version is 3.5.2.
I don't have a settings.xml in the ~/.m2 directory.
Thanks in advance for any help offered!
As you say that in eclipse is working, go to Preferences>Maven>user settings there you will see the eclipse mvn configuration and compare it with the one on your system normally in ~/.m2/settings.xml or by the environment variable $M2_HOME/conf/settings.xml
Related
I try to compile GraalVM Native Image for a Spring Boot 3.0 application with multiple Maven modules.
The module structure is like the following:
heroes-parent
|- heroes-backend
|- heroes-frontend
|- heroes-webapp
where each sub-directory is a module of the parent
pom.xml extract:
<modules>
<module>heroes-backend</module>
<module>heroes-frontend</module>
<module>heroes-webapp</module>
</modules>
When I try to build the app with (see Spring Boot docs):
mvn -Pnative native:compile
it errors with (because the parent has no classes):
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.18:compile (default-cli) on project heroes-parent: Image classpath is empty. Check if your classpath configuration is correct. -> [Help 1]
So, I have tried to build the whole application first with mvn install and then only build the application heroes-webapp with native:compile
mvn install
cd heroes-webapp
mvn -Pnative native:compile
But this fails with the following error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.047 s
[INFO] Finished at: 2022-12-12T16:26:20+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0:process-aot (process-aot) on project heroes-webapp: Unable to compile generated source
[ERROR] cannot access heroes.WeblateProperties
[ERROR] bad class file: /home/koc/git/work/koc/angular-spring-heroes/heroes-webapp/target/classes/heroes/WeblateProperties.class
[ERROR] unable to access file: java.nio.file.NoSuchFileException: /home/koc/git/work/koc/angular-spring-heroes/heroes-webapp/target/classes/heroes/WeblateProperties.class
[ERROR] Please remove or make sure it appears in the correct subdirectory of the classpath. /home/koc/git/work/koc/angular-spring-heroes/heroes-webapp/target/spring-aot/main/sources/heroes/WeblateProperties__BeanDefinitions.java 15:25
[ERROR] cannot access heroes.MainController
[ERROR] bad class file: /home/koc/git/work/koc/angular-spring-heroes/heroes-webapp/target/classes/heroes/MainController.class
[ERROR] unable to access file: java.nio.file.NoSuchFileException: /home/koc/git/work/koc/angular-spring-heroes/heroes-webapp/target/classes/heroes/MainController.class
[ERROR] Please remove or make sure it appears in the correct subdirectory of the classpath. /home/koc/git/work/koc/angular-spring-heroes/heroes-webapp/target/spring-aot/main/sources/heroes/MainController__BeanDefinitions.java 15:25
[ERROR] cannot access heroes.HeroesApplication
[ERROR] bad class file: /home/koc/git/work/koc/angular-spring-heroes/heroes-webapp/target/classes/heroes/HeroesApplication.class
[ERROR] unable to access file: java.nio.file.NoSuchFileException: /home/koc/git/work/koc/angular-spring-heroes/heroes-webapp/target/classes/heroes/HeroesApplication.class
[ERROR] Please remove or make sure it appears in the correct subdirectory of the classpath. /home/koc/git/work/koc/angular-spring-heroes/heroes-webapp/target/spring-aot/main/sources/heroes/HeroesApplication__BeanDefinitions.java 18:25
You can find the source code for the whole application on GitHub.
Is there any way to build a native-image with a Maven multi-module Spring Boot 3 application?
I found the issue. Visual Studio Code was open and the project was loaded using Extension Pack for Java. This was deleting the classes while Maven was building them which resulted in the error above.
I've been working with test automation a lot lately.
Im now familiarized with several tools, frameworks, dependencies, etc. like Selenium, JUNits, TestNG that helps me manage my daily work as a QA Engineer.
I frequently use Selenium and TestNG to build up my solutions, together with IntelliJ IDEA that runs on the latest JDK version (jdk-15.0.1) available on a Mac running on macOs Catalina Version 10.15.7.
I have mi POM.mxl file already configured for my projects and since the very beginning it displayed the following error on the console:
Cannot resolve com.sun:tools:0
I always ignored that because my projects within my IDE always compiled&ran and because I was never using that dependency. But now I'm trying to run my project with maven support from my Terminal in my Mac and because of the sun:tools.jar dependency, I'm not allowed to compile any working project I have developed so far.
I have read a lot of similar threads on similar problems with the same sun:tools:jar dependency like in:
Missing artifact com.sun:tools:jar
Missing Library com.sun.tools.attach
Could not find artifact com.sun:tools:jar:0
I have done everything, but many solutions were based on finding the tools.jar file in the jdk installation directory. Since I'm using JDK 15, this dependency was already removed:
Removed: rt.jar and tools.jar
The class and resource files previously stored in lib/rt.jar,
lib/tools.jar, lib/dt.jar, and various other internal JAR files are
now stored in a more efficient format in implementation-specific files
in the lib directory. The format of these files is not specified and
is subject to change without notice.
I attach the exact error message I get with the terminal:
----------------------< org.example:YelpExercise >----------------------
[INFO] Building YelpExercise 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.737 s
[INFO] Finished at: 2020-11-04T18:59:47-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project YelpExercise: Could not resolve dependencies for project org.example:YelpExercise:jar:1.0-SNAPSHOT: Could not find artifact com.sun:tools:jar:0 at specified path /Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home/../lib/tools.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Ok, after hours and even days of research, I found the solution:
For JDK 9 and above, when defining the pom.xml, you have to exclude that sub-dependency whenever you will use a dependency that contains it. In my case, the cobertura dependency included sun.com:tools.
What I edited in my pom.xml file:
<!-- https://mvnrepository.com/artifact/net.sourceforge.cobertura/cobertura -->
<dependency>
<groupId>net.sourceforge.cobertura</groupId>
<artifactId>cobertura</artifactId>
<version>2.1.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
</exclusion>
</exclusions>
</dependency>
This seems to be still an open issue for some maven dependencies. Check: issues1 or issues2 or Google search: <dependency_you_are_using> sun tools for more info.
The mvn install command fails and I am unable to build the kafka-connect-jdbc source code. My intention is to modify the kafka-connect-jdbc source code.
I followed the instructions
https://github.com/confluentinc/kafka-connect-jdbc/issues/456
and
https://github.com/confluentinc/kafka-connect-jdbc/wiki/FAQ
All of which do not solve the problem. Can someone please assist?
Error Message (Snippet)
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project kafka-connect-jdbc: Compilation failure: Compilation failure:
[ERROR] /java/projects/kafka-connect-jdbc/src/main/java/io/confluent/connect/jdbc/dialect/SqlServerDatabaseDialect.java:[19,38] package org.apache.kafka.common.config does not exist
[ERROR] java/projects/kafka-connect-jdbc/src/main/java/io/confluent/connect/jdbc/dialect/SqlServerDatabaseDialect.java:[20,37] package org.apache.kafka.connect.data does not exist
[ERROR] /java/projects/kafka-connect-jdbc/src/main/java/io/confluent/connect/jdbc/dialect/SqlServerDatabaseDialect.java:[21,37] package org.apache.kafka.connect.data does not exist
[ERROR] /java/projects/kafka-connect-jdbc/src/main/java/io/confluent/connect/jdbc/dialect/SqlServerDatabaseDialect.java:[22,37] package org.apache.kafka.connect.data does not exist
[ERROR] /java/projects/kafka-connect-jdbc/src/main/java/io/confluent/connect/jdbc/dialect/SqlServerDatabaseDialect.java:[23,37] package org.apache.kafka.connect.data does not exist
[ERROR] /java/projects/kafka-connect-jdbc/src/main/java/io/confluent/connect/jdbc/dialect/DatabaseDialectProvider.java:[19,38] package org.apache.kafka.common.config does not exist
[ERROR] /java/projects/kafka-connect-jdbc/src/main/java/io/confluent/connect/jdbc/dialect/GenericDatabaseDialect.java:[19,38] package org.apache.kafka.common.config does not exist
[ERROR] /java/projects/kafka-connect-jdbc/src/main/java/io/confluent/connect/jdbc/dialect/GenericDatabaseDialect.java:[20,44] package org.apache.kafka.common.config.types does not exist
Download kafka source libraries into your maven local repo and retry it should work.
The master version of kafka-connect-jdbc depends on snapshot libraries not available on the central maven repository.
Make sure to clone locally:
https://github.com/confluentinc/common.git : use mvn clean install
https://github.com/apache/kafka.git : use ./gradlew installAll
After successfully performing these steps proceed to build/modify locally kafka-connect-jdbc
Go to FAQ and than you will have information that you must :
Kafka - clone https://github.com/confluentinc/kafka.git and build with ./gradlew installAll
Common - clone https://github.com/confluentinc/common and build with mvn install
I need to install db unit in my system. I have completed installing JDBC driver. i have downloaded junit-4.11.jar.
I have to generate the jar file into the directory.What is the correct method/step of doing this.AS per the link:
http://www.dbunit.org/building.html
i tried to run the command mvn from command line.
But i get the error
C:\Users\suvin>mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.225s
[INFO] Finished at: Tue Nov 20 14:51:56 IST 2012
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM
in this directory (C:\Users\suvin). Please verify you invoked Maven from the co
rrect directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProject
Exception
Any help would be appreciated
Is dbUnit dependency is included in the POM file, if so mvn install does what you are expecting it to do
<dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>2.4.3</version>
</dependency>
it seems C:\Users\suvin location doesn't have pom file, Before execute "mvn install" your command prompt should be in place where your POM file exist.
For your information.
Normaly from a source codes you can build(compile) it and get your jars. To build a source codes you can use either ant or maven which are some build tools in java. Source codes providers provide their source codes with build.xml or pom.xml or both. You could use your build technology to compile that java source and get jar from it.
you can learn ant and maven from the web
I have a very simple default application that I've created to test my Eclipse Indigo/Maven v3.0.1 setup on my Windows 7 machine. The Hello World app runs fine from Eclipse.
Now from the command line I'm trying to test with mvn install.
At which point I see Maven download a large series of dependencies. For some reason though it will get stuck downloading one and will just stop part way through. It's not at the same point each time, but it's currently consistently the same jar file, eg...
http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-booter/2.5/surefire-booter-2.5.jar
If I download this file from a browser it works perfectly. Quite fast in fact. Now if I manually copy that downloaded file to the appropriate directory in my .m2 repository directory, the install continues to download dependencies until it hits another one at random which it stops at.
Here's my POM, although I'm not sure it'll help as it's so basic and seems to work fine with a mvn compile.
<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.kyeema</groupId>
<artifactId>QServer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>QServer</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Here's some debug output referencing some dummy jar file?
[INFO] Surefire report directory: C:\workspace\QServer\target\surefire-reports
[DEBUG] Setting system property [user.dir]=[C:\workspace\QServer]
[DEBUG] Setting system property [localRepository]=[C:\Users\Andre\.m2\repository]
[DEBUG] Setting system property [basedir]=[C:\workspace\QServer]
[DEBUG] Using JVM: C:\Program Files\Java\jdk1.7.0\jre\bin\java
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[DEBUG] org.apache.maven.surefire:surefire-booter:jar:2.7.2:compile (selected for compile)
[DEBUG] org.apache.maven.surefire:surefire-api:jar:2.7.2:compile (selected for compile)
[DEBUG] Adding to surefire booter test classpath: C:\Users\Andre\.m2\repository\org\apache\maven\surefire\surefire-booter\2.7.2\surefire-booter-2.7.2.jar Scope: compile
[DEBUG] Adding to surefire booter test classpath: C:\Users\Andre\.m2\repository\org\apache\maven\surefire\surefire-api\2.7.2\surefire-api-2.7.2.jar Scope: compile
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[WARNING] Missing POM for org.apache.maven.surefire:surefire-junit3:jar:2.7.2: Error resolving project artifact: Failure to find org.apache.maven.surefire:surefire-junit3:pom:2.7.2 in http://mirrors.ibiblio.org/pub/mirrors/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of ibiblio.org has elapsed or updates are forced for project org.apache.maven.surefire:surefire-junit3:pom:2.7.2
[DEBUG] org.apache.maven.surefire:surefire-junit3:jar:2.7.2:test (selected for test)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.626s
[INFO] Finished at: Tue Aug 16 13:18:42 PDT 2011
[INFO] Final Memory: 8M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.7.2:test (default-test) on project QServer: Error to resolving surefire provider dependency: Missing:
[ERROR] ----------
[ERROR] 1) org.apache.maven.surefire:surefire-junit3:jar:2.7.2
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=org.apache.maven.surefire -DartifactId=surefire-junit3 -Dversion=2.7.2 -Dpackaging=jar -Dfile=/path/to/file
[ERROR]
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR] mvn deploy:deploy-file -DgroupId=org.apache.maven.surefire -DartifactId=surefire-junit3 -Dversion=2.7.2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR]
[ERROR] Path to dependency:
[ERROR] 1) dummy:dummy:jar:1.0
[ERROR] 2) org.apache.maven.surefire:surefire-junit3:jar:2.7.2
[ERROR]
[ERROR] ----------
[ERROR] 1 required artifact is missing.
[ERROR]
[ERROR] for artifact:
[ERROR] dummy:dummy:jar:1.0
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] ibiblio.org (http://mirrors.ibiblio.org/pub/mirrors/maven2, releases=true, snapshots=false)
OK guys, I had the same problem downloading a large file. We're all probably using the lightweight HTTP wagon. If you look at the docs:
http://maven.apache.org/wagon/wagon-providers/wagon-http-lightweight/
Known Limitation:
The main limitation is that you can't download data that doesn't fit entirely into memory.
So I increased the memory for Maven:
export MAVEN_OPTS="-Xmx1024m"
and voila, it works. (!!!!)
I had the same problem. In my case AVG antivirus software blocked Maven from downloading artifacts. Disabling it temporarily helped.
Well for what it's worth, here's the answer to what I've been experiencing.
If I leave Maven at v3.0.1 I have to add the mirror listed above and it works fine.
If I upgrade Maven to v3.0.3 then I have to remove the mirror listed above to make it work. :-)
I tried this on two separate machines and had identical behaviour. This could mean the network here is to blame as they both go through the same router.
Anyway, so there's essentially two workarounds there. I'm not sure if either are the "correct" response, but they keep me moving forward at least.
Thanks to all that submitted answers.
I solved this problem by downgrading to Java 6.
In my case, I went to the local repository (~/.m2/repository/), found the corresponding group and discovered that the artifact at which the download is stuck has two files with .part and .part.lock extensions. Deleting them helped.
I had exactly the same problem a while back - long story short it was a networking issue. And, yes just like you tried I could grab the file with a web browser just fine.
For testing purposes are you using a proxy, and to the proxy settings in Maven match the browser?
I had similar issue. What changed was the move of nexus to VPN. Turned out I had DNS entry cached.
Flushing DNS fixed it. For record for Ubuntu like systems:
sudo systemd-resolve --flush-caches