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.
Related
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
I am attempting to compile my maven project, and I am depending on another project (which is a jar file). For some reason, when I attempt to compile I get the following error which seems to be that my project can not access the required dependencies of the project I'm depending on, even though I don't use any of those dependencies.
Here is the error http://hastebin.com/pebolozuxi.sql
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/cneth/Desktop/Developing/PrimeMC/PrimeMobWhacker/src/main/java/org/primemc/MobWhackerManager.java:[315,34] cannot access tech.rayline.core.plugin.RedemptivePlugin
class file for tech.rayline.core.plugin.RedemptivePlugin not found
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.892 s
[INFO] Finished at: 2016-10-07T14:56:20+03:00
[INFO] Final Memory: 25M/298M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project MobWhacker: Compilation failure
[ERROR] /C:/Users/cneth/Desktop/Developing/PrimeMC/PrimeMobWhacker/src/main/java/org/primemc/MobWhackerManager.java:[315,34] cannot access tech.rayline.core.plugin.RedemptivePlugin
[ERROR] class file for tech.rayline.core.plugin.RedemptivePlugin not found
I know that I can easily depend on that required dependency to solve the issue, however I don't see why that would be necessary so I wish to solve this issue without taking that route, if possible.
Thanks!
This is nothing to do with Maven. The java compiler wants that class. MobWhackerManager.java:[315,34], in fact, wants that class. The line number is right there. Your code, at line 315, references that class somehow.
Try excluding not needed transitive dependecy
https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html
Your error says that the compiler misses the class tech.rayline.core.plugin.RedemptivePlugin.
So you probably need to add the jar with this class to your Maven dependencies.
From your last comment I understand that you need the jar containing RedemptivePlugin so you must keep it. In the worst case, download it manually with the right version and put it in your .m2 with the right path
previous answear
Juste to be able to help:
Have you checked the presence of your needed jar in your .m2 ?
Have you checked the full dependencies of your project to state for sure that you don't need the jar containing the class tech.rayline.core.plugin.RedemptivePlugin.
If you are sure of that, try:
<dependencies>
<dependency>
<groupId>The Project Jar That Links You To RedemptivePlugin Jar</groupId>
<artifactId>Project</artifactId>
<version>TheVersion</version>
<exclusions>
<exclusion>
<groupId>The Jar containing RedemptivePlugin</groupId>
<artifactId>theJar</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
I am trying to build and run a Spring MVC beginner lesson project using IntelliJ. I imported the existing project from GitHub. But when I try to build the project I keep getting:
Error:(3, 38) java: package org.springframework.stereotype does not exist
Error:(4, 47) java: package org.springframework.web.bind.annotation does not exist
These external dependencies jars are under my Maven local repositories (C:\Users\sudi.m2)and I can see in IntelliJ under Maven->Repositories that repo location is indeed there. I also tried "Invalidate Cache and restart" but that does not help. My M2_HOME is set correctly to C:\apache-maven-3.2.2. If I try to run mvn install from command line, I get:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.845 s
[INFO] Finished at: 2014-09-25T19:03:21+05:30
[INFO] Final Memory: 9M/93M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project basic-web-app: Error assembling WAR: webxml attribute is required (or preexisting WEB-INF/web.xml if executing in update mode) -> [Help 1]
Any suggestions are appreciated.
If the project doesn't have a web.xml file (IE: Entirely java config based). The build war plugin will fail unless you specify the "failOnMissingWebXml" attribute to false.
Delete you local .m2 repository and let it re-download all needed jars. Maybe, there were issues while downloading one of the dependencies.
I am facing this issue , when i am deploying my application using Maven, please suggest some solution.
Error log,
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.790s
[INFO] Finished at: Wed Apr 23 10:44:13 IST 2014
[INFO] Final Memory: 54M/131M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project clustering.services: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre7\..\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/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :clustering.services
Thanks in advance.
set JAVA_HOME to jdk not to JDK_DIR/jre, See this question for how to set the value
If you're using Eclipse, go to Windows->Preferences.
Under Java->Installed JREs, double click on the item in the list and make sure the JRE home points to a JDK (for example, set it to "C:\Program Files\Java\jdk1.7.0_60"), and leave everything else the same.
Most of the time that i get this "Mojo" error. It is just because, i may have forgotten to do "Maven generate-sources" then "Maven Clean" prior to do the "Maven Install" or "Maven Build". The MojoExecutionException should not appear after that. Some Eclipse versions have this problem to refresh the target folder. In this case, Refresh the project just after the "Maven Install".
If not resolved yet, it could be a lot of things (failed to copy a file(s), missing file(s), etc). I would suggest that you run the Maven Install in debug mode by adding -X to get more details on what may have happened then check your log: Right click on project> Run As> Maven Build as the following screenshot:
Verify that the name of the main class to execute in the application is specified in the pom.xml.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>com.enterprise.mainPacket.MainApp</mainClass>
</properties>
Also check if the .fxml file has been relocated, so that it correctly addresses the controller associated with it. fx:controller="com.enterprise.mainPacket.FXMLController"
<VBox fx:id="vBMasterContainer" prefHeight="698.0" prefWidth="800.0" styleClass="theme" stylesheets="#/styles/style.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.enterprise.mainPacket.FXMLController">
I had the same error. I fixed the path to Java, and was missing the tools jar. I copied it from another place. After that, everything worked.
Check that there are no conflict on the port (another service already running) !
Make sure that you don't have any empty packages within your source code folder. If there aren't any classes, the same error will occur.
After I changed the version in pom.xml to 1.2.1, the error was resolved.
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