log4j 1.2.12 dependency showing in compile logs but not in mvn dependency tree - maven

I am trying to compile the product and it downloads log4j 1.2.12 version.
When I try to see how is it added using mvn dependency:tree, it does not show up.
In the compilation logs, it says below:
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # jobcontroller-worker-api ---
Downloading from central: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.jar
Downloaded from central: https://repo.maven.apache.org/maven2/log4j/log4j/1.2.12/log4j-1.2.12.jar (358 kB at 1.6 MB/s)
Any idea how to know who is downloading this jar and how to change it to use 2.x version of logs.
Thanks,
Swaraj

Related

maven copy-dependencies fails on status 403 forbidden

Project I'm working on uses Vaadin framework (old version 7) and java 8. Project is implemented as multiple projects (modules).
Everything worked fine for a few months until yesterday. I did some changes on 'core' part of the project, ran mvn install and jumped into the main project. There I ran
mvn clean
mvn dependency:copy-dependencies
to get my changes and dependencies copied from core to the main project. Last goal (copy-dependencies) always fails with this error
(note that I covered some information in the error message on purpose):
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< myproject.main >-------------------------
[INFO] Building Main version
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/com/vaadin/addon/jpacontainer/3.1.1/jpacontainer-3.1.1.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/com/vaadin/addon/vaadin-touchkit-agpl/3.0.0/vaadin-touchkit-agpl-3.0.0.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/org/vaadin/resetbuttonfortextfield/1.2.1/resetbuttonfortextfield-1.2.1.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/org/vaadin/addon/confirmdialog/2.1.2/confirmdialog-2.1.2.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/com/vaadin/tapio/googlemaps/0.6.1/googlemaps-0.6.1.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/org/vaadin/addons/contextmenu/4.5/contextmenu-4.5.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/org/vaadin/addons/lazyquerycontainer/vaadin-lazyquerycontainer/7.3.3.6/vaadin-lazyquerycontainer-7.3.3.6.pom
Downloading from mvn-repository jetty: https://mvnrepository.com/artifact/org/vaadin/addons/popupbutton/2.6.0/popupbutton-2.6.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.383 s
[INFO] Finished at: 2021-08-17T11:37:09+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project main: Could not resolve dependencies for project *myproject.core:version*: Failed to collect dependencies at *myproject.core:version* -> com.vaadin.addon:jpacontainer:jar:3.1.1: Failed to read artifact descriptor for com.vaadin.addon:jpacontainer:jar:3.1.1: Could not transfer artifact com.vaadin.addon:jpacontainer:pom:3.1.1 from/to mvn-repository jetty (https://mvnrepository.com/artifact/): authorization failed for https://mvnrepository.com/artifact/com/vaadin/addon/jpacontainer/3.1.1/jpacontainer-3.1.1.pom, status: 403 Forbidden -> [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
The weird thing is that I don't know about any change in the project or my pc that could cause this issue.
I already tried:
mvn -U dependency:copy-dependencies
running mvn package on before trying to copy dependencies (fails with the same error)
Resetting my Intellij environment
Recompiling every dependent projects
I read the wiki article from the error message but I do not consider it to much use - project work before that without me having to set for example proxy or TLS. Do you have any suggestions on how to solve this problem ?
The problem was indeed in the maven repository link. It seems that the dependencies have changed recently.
In my case the solution was to remove the repository in POM that caused trouble, namely
<repository>
<id>mvn-repository jetty</id>
<url>https://mvnrepository.com/artifact/</url>
</repository>

How to get CodenameOne Maven Project Running in Netbeans

Thx to Steve for the CN1 ant to maven migration tool and video here. - Has anyone been able to run the Kitchen Sink project in Netbeans after migration? I follow the video instructions with the migration tool and migrate successfully and it runs from command line with ./run.sh but when I go to run it in NetBeans, I had a lot of 501 (https needed) errors. Added umer's code from here and that solved the 501 errors but now get:
Invalid POM for com.codenameone:codenameone-javase:jar:7.0.23, and
No implementation for org.codehaus.plexus.languages.java.jpms.LocationManager was bound.
while locating org.apache.maven.plugin.surefire.SurefirePlugin.
Note invalid POM warning...
------------------------------------------------------------------------
Building kitchensink-common 1.0-SNAPSHOT
------------------------------------------------------------------------
--- properties-maven-plugin:1.0.0:read-project-properties (default) # kitchensink-common ---
--- codenameone-maven-plugin:7.0.23:generate-gui-sources (generate-gui-sources) # kitchensink-common ---
The POM for com.codenameone:codenameone-javase:jar:7.0.23 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
Generating GUI sources
No GUI Entries available
Running from command line, invalid POM warning disappears:
[INFO] -----------< com.codename1.demos.kitchen:kitchensink-common >-----------
[INFO] Building kitchensink-common 1.0-SNAPSHOT [4/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- properties-maven-plugin:1.0.0:read-project-properties (default) # kitchensink-common ---
[INFO]
[INFO] --- codenameone-maven-plugin:7.0.23:generate-gui-sources (generate-gui-sources) # kitchensink-common ---
Generating GUI sources
No GUI Entries available
Running on apache-maven-3.8.1 on MacOSX
Java version: 1.8.0_172
Suggestions welcomed.
Thx, Mike
I think perhaps the method I'm using to detect the latest version of cn1 has issues. It picked 7.0.23 which was released this morning. But then it was unable to find some of the jars.
Probably it will work if you just try running the project again as it should be fully propagated to maven central now.
Problem was solved updating from Netbeans 8.2 to latest Netbeans version (currently 12.3).

Custom maven archetype:generate defaults to version 3.1.1 instead of 3.1.2?

I have build a custom maven archetype in my local. However while generating a project it always looks for the maven archetype:generate version 3.1.1 instead of 3.1.2. I have multiple modules in my project with profiles to avoid the bug associated in 3.1.1 using the upgraded version 3.1.2.
Here is the error.
C:\Repo>mvn archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=com.lamo.archtypes -DarchetypeArtifactId=microservice-component-server -DarchetypeVersion=0-SNAPSHOT -
DgroupId=com.organisation.platform.product -Dpackage=com.organisation.platform.product.pd -DartifactId=product-server -Dcomponent-short-name=pd -Dcomponent-long-name=product
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/3.1.1/maven-archetype-plugin-3.1.1.pom
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/3.1.0/maven-archetype-plugin-3.1.0.pom
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/3.0.1/maven-archetype-plugin-3.0.1.pom
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/3.0.0/maven-archetype-plugin-3.0.0.pom
Here is the public repository link to my custom archetype https://github.com/lagnajit712/microservice-component-server
If you want a specific version of the maven archetype plugin, just specify it. Use
mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeCatalog...

Caching Maven with Docker and Kotlin

I am trying to warm up my Docker + Maven cache before building a Kotlin project.
As suggested by many Maven/Docker threads, my docker file looks like this:
COPY pom.xml .
RUN mvn dependency:go-offline
COPY ./src/ src/
RUN mvn package
The thought is that if I change a file in the ./src directory, I want docker cache to skip maven's lengthy dependency download page.
My problem is that the mvn package command still downloads alot of files.
I tried to use mvn -o package (maven offline flag) to diagnose what dependencies are missing, but it just complains that it cannot download dependencies. But I would have expected that the dependencies would allready be downloaded in the previous step. Here are the errors that I get with the "-o" flag:
Step 8/13 : RUN mvn dependency:go-offline
---> Using cache
---> 0334facb9cc9
Step 9/13 : COPY ./src/ src/
---> Using cache
---> 27149a191017
Step 10/13 : RUN mvn -o package
---> Running in 5183eced32ca
Warning: JAVA_HOME environment variable is not set.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building auth 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # auth ---
[WARNING] The POM for org.apache.maven:maven-core:jar:2.0.6 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-monitor:jar:2.0.6 is missing, no dependency information available
[WARNING] The POM for org.codehaus.plexus:plexus-utils:jar:2.0.5 is missing, no dependency information available
[WARNING] The POM for org.apache.maven.shared:maven-filtering:jar:1.1 is missing, no dependency information available
[WARNING] The POM for org.codehaus.plexus:plexus-interpolation:jar:1.13 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.882 s
[INFO] Finished at: 2019-07-12T07:02:23+00:00
[INFO] Final Memory: 13M/174M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project auth: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-plugin-api:jar:2.0.6, org.apache.maven:maven-project:jar:2.0.6, org.apache.maven:maven-profile:jar:2.0.6, org.apache.maven:maven-artifact-manager:jar:2.0.6, org.apache.maven:maven-repository-metadata:jar:2.0.6, org.apache.maven:maven-plugin-registry:jar:2.0.6, org.apache.maven:maven-core:jar:2.0.6, org.apache.maven:maven-artifact:jar:2.0.6, org.apache.maven:maven-settings:jar:2.0.6, org.apache.maven:maven-model:jar:2.0.6, org.apache.maven:maven-monitor:jar:2.0.6, classworlds:classworlds:jar:1.1-alpha-2, org.codehaus.plexus:plexus-utils:jar:2.0.5, org.apache.maven.shared:maven-filtering:jar:1.1, org.codehaus.plexus:plexus-interpolation:jar:1.13: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven:maven-plugin-api:jar:2.0.6 has not been downloaded from it before. -> [Help 1
Try following mvn commands, it saved me from the maven error.
RUN mvn --batch-mode --errors --strict-checksums --threads 1C \
org.apache.maven.plugins:maven-dependency-plugin:3.0.2:go-offline
RUN mvn --batch-mode --errors --offline package
From what I gathered from various sources go-offline not always handles caching packages in a correct way, leaving some of them outside of the local repository (see pull request on GitHub).
In my case, the standard mvn dependency:go-offline used go-offline 2.8 and returned errors. I then tried running mvn org.apache.maven.plugins:maven-dependency-plugin:3.2.0:go-offline but I still had some issues with different packages.
What worked for me was using a different "go-offline" plugin available at GitHub.
Using
mvn de.qaware.maven:go-offline-maven-plugin:resolve-dependencies
finally did the job.

Transitively download a Maven artifact to the local repository

I am trying to download a specific artifact (and all of its dependencies) to a machine's local repository.
It would seem that using the dependency:get goal would be the best option for this, but despite the documentation it does not seem to actually get the transitive dependencies.
Here is an example where I have tried to use dependency:get to download the spring-core jar and all of its many dependencies. You'll notice that the spring-core jar is the only thing downloaded despite the fact that this was done after cleaning the local repository.
$ mvn org.apache.maven.plugins:maven-dependency-plugin:2.2:get -DrepoUrl=http://repo1.maven.org/maven2/ -Dartifact=org.springframework:spring-core:3.0.5.RELEASE -Dtransitive=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.2:get (default-cli) # standalone-pom ---
Downloading: http://repo1.maven.org/maven2/org/springframework/spring-core/3.0.5.RELEASE/spring-core-3.0.5.RELEASE.jar
Downloaded: http://repo1.maven.org/maven2/org/springframework/spring-core/3.0.5.RELEASE/spring-core-3.0.5.RELEASE.jar (374 KB at 548.4 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.401s
[INFO] Finished at: Wed May 25 00:29:47 CDT 2011
[INFO] Final Memory: 7M/107M
[INFO] ------------------------------------------------------------------------
My questions are:
Is this a bug with the dependency:get goal?
If not, what am I doing wrong?
Are there any alternatives methods I could use to accomplish my initially stated goal?
If this is a one time or irregular occurrence for you, The simplest thing to do would be to define the dependency in a POM and run mvn package or similar to retrieve the dependency artifacts. You could also try mvn dependency:sources if you'd like to have the source jars too.
If this is something you want to do more regularly or as part of a process, you could look at using Aether directly to retrieve the dependencies for you.
Another approach if this is something you need to do regularly to manage groups of artifacts into your internal development ecosystem is to use Nexus' procurement suite to retrieve the dependencies and manage them into your repository.
You might can go with this solution
1) Download the artifact as you described (I tested with version 2.5.2)
c:\test>mvn -DrepoUrl=http://repo1.maven.org/maven2/ -Dartifact=org.springframework:spring-core:2.5.2 -Dtransitive=true
2) Download the pom (-Dpackaging=pom) of this artifact
c:\test>mvn -DrepoUrl=http://repo1.maven.org/maven2/ -Dartifact=org.springframework:spring-core:2.5.2 -Dtransitive=true -Dpackaging=pom org.apache.maven.plugins:maven-dependency-plugin:2.2:get
3) Use the downloaded pom to copy all dependencies via the dependency:copy-dependency gaol
c:\test>mvn -DoutputDirectory=C:/test/dependency -f C:/<path-to-repository>/org/springframework/spring-core/2.5.2/spring-core-2.5.2.pom dependency:copy-dependencies
You will find the dependencies (including test and optional scope!) in the created c:\test\dependency folder. To exclude test and optional scope use -DincludeScope=runtime.
You need to dynamically build some path information (e.g. path to the pom in your repository) to set up this solution and also need to bring the artifact itself together with its dependencies but it should work in a script without generating a special pom (which might be easier).
It would appear the answer to question #1 (Is this a bug with the dependency:get goal?) is yes. As of 5/25/2011 issue MDEP-308 is still unresolved.

Resources