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>
Related
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.
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
Scala and sbt newbie here. I created a Scala sbt project that uses casbah
libraryDependencies += "org.mongodb" %% "casbah" % "3.1.1"
to query a mongodb and return results as a map. I want to use this code in my Java maven project to manipulate the results that I get from querying the database.
I added this to my build.sbt file:
publishMavenStyle := true
publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath + "/.m2/repository")))
to install a jar file in my .m2 local repo. Here is the output when I do sbt publish:
> publish
[info] Packaging /Users/miguelvelez/Documents/Programming/Scala/Projects/mongo/target/scala-2.12/mongo_2.12-0.1.0-SNAPSHOT-sources.jar ...
[info] Done packaging.
[info] Main Scala API documentation to /Users/miguelvelez/Documents/Programming/Scala/Projects/mongo/target/scala-2.12/api...
[info] Packaging /Users/miguelvelez/Documents/Programming/Scala/Projects/mongo/target/scala-2.12/mongo_2.12-0.1.0-SNAPSHOT.jar ...
[info] Done packaging.
[info] Wrote /Users/miguelvelez/Documents/Programming/Scala/Projects/mongo/target/scala-2.12/mongo_2.12-0.1.0-SNAPSHOT.pom
[info] :: delivering :: edu.cmu.cs.mvelezce#mongo_2.12;0.1.0-SNAPSHOT :: 0.1.0-SNAPSHOT :: integration :: Sun Apr 09 13:58:46 EDT 2017
[info] delivering ivy file to /Users/miguelvelez/Documents/Programming/Scala/Projects/mongo/target/scala-2.12/ivy-0.1.0-SNAPSHOT.xml
model contains 9 documentable templates
[info] Main Scala API documentation successful.
[info] Packaging /Users/miguelvelez/Documents/Programming/Scala/Projects/mongo/target/scala-2.12/mongo_2.12-0.1.0-SNAPSHOT-javadoc.jar ...
[info] Done packaging.
[info] published mongo_2.12 to /Users/miguelvelez/.m2/repository/edu/cmu/cs/mvelezce/mongo_2.12/0.1.0-SNAPSHOT/mongo_2.12-0.1.0-SNAPSHOT.pom
[info] published mongo_2.12 to /Users/miguelvelez/.m2/repository/edu/cmu/cs/mvelezce/mongo_2.12/0.1.0-SNAPSHOT/mongo_2.12-0.1.0-SNAPSHOT.jar
[info] published mongo_2.12 to /Users/miguelvelez/.m2/repository/edu/cmu/cs/mvelezce/mongo_2.12/0.1.0-SNAPSHOT/mongo_2.12-0.1.0-SNAPSHOT-sources.jar
[info] published mongo_2.12 to /Users/miguelvelez/.m2/repository/edu/cmu/cs/mvelezce/mongo_2.12/0.1.0-SNAPSHOT/mongo_2.12-0.1.0-SNAPSHOT-javadoc.jar
[success] Total time: 3 s, completed Apr 9, 2017 1:58:49 PM
I then imported this dependency in my pom file:
<dependency>
<groupId>edu.cmu.cs.mvelezce</groupId>
<artifactId>mongo_2.12</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
When I run mvn compile, I get the following error:
[ERROR] Failed to execute goal on project performance-mapper: Could not resolve dependencies for project edu.cmu.cs.mvelezce:performance-mapper:jar:0.1.0-SNAPSHOT: Failure to find org.mongodb:casbah_2.12:jar:3.1.1 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
I know that casbah has several modules and I can import just a few instead of all of them. However, following the documentation in Casbah, I add the enterie library. I also looked at Maven Central and this version of casbah does not have a jar; only the independent modules. I added some of those modules in my pom, but I still got the same error as above. Maven is looking for that complete jar file.
Is there a way to fix this? I thought I could only add the Scala dependencies that I need in my build.sbt file, but I got compilation errors when I did that. Does anybody have sugguestions?
Thanks!
You need to ensure that the Casbah dependency is of type pom in your project. Eg in your pom.xml add the following:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>casbah_2.11</artifactId>
<version>3.1.1</version>
<type>pom</type>
</dependency>
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 have dependency:
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.10</version>
</dependency>
And run a test that includes testing a website for form submission. Works great. I package this up into my local repo mvn install and include it in another wider project.
Doing a mvn dependency:tree -Dverbose -Dincludes=net.sourceforge.htmlunit doesn't seem to reveal anything untoward
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # myproject ---
[INFO] com.myproject:myproject:war:1.0-SNAPSHOT
[INFO] \- com.myproject:myproject:mp:jar:1.0:compile
[INFO] \- net.sourceforge.htmlunit:htmlunit:jar:2.10:compile
[INFO] \- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.10:compile
So I don't think any of the other deps are causing an issue. Yet if I copy/paste a test from the base project into the wider one, I always get errors:
java.lang.NoSuchMethodError: com.gargoylesoftware.htmlunit.html.HtmlPage.getElementById(Ljava/lang/String;)Lcom/gargoylesoftware/htmlunit/html/HtmlElement;
I've made sure my IDE isn't caching some dodgy library somewhere so as far as I can tell it's clean. Any ideas?
Thanks
Problem is you have this class coming from some other artifact, since you verified it is not directly coming from htmlunit with different version, it must be shaded in some other jar
for jvm to get pick up correct class please put htmlunit dependency on top of dependency so it will be first in classpath taking priority