I am trying to package my project to a jar, whenever I try this it fails to compile because of old cached dependencies I dont use anymore.
Could not resolve dependencies for project at.htl:testmonitoring-client:jar:1.18.47: Failed to collect dependencies [old dependencies] in http://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]
If you're not using the dependencies, then you should remove them from the pom. If the dependency is not in the pom, then (most of the time) Maven won't try to resolve them and the build won't fail.
If you've removed them from the pom but maven is still trying to resolve them, then it may mean that something is using them transitively. You can check on that with mvn dependency:tree
If for whatever reason the build needs to resolve them, then the simplest thing is to remove the "cached failures" from your local repo. The easiest thing to do is remove the entire ~/.m2/repository directory (and all subdirectories and content thereof), which is probably safe as maven will reconstruct it from the remote. The only problem would be if you have/need artifacts in the local repo that don't exist on any remote. If that's not the case, you won't lose anything by doing it, though it will make the next build take longer as it must download everything again.
If you can't remove the entire local repo, then you could still track down the specific artifacts causing the problem. For example, if you have a problem with an artifact groupId=com.some.comapny artifactId=someArtifact, version=1.0.0 then you could remove ~/.m2/repository/com/some/company/someArtifact/1.0.0 (and all content thereof).
Note that this assumes Maven will be able to resolve the dependencies from the configured remote(s). If they aren't available in the remotes you've configured, then you may have to resolve that (either by adding them to your local repo manager, by adding public repos that do have the artifacts, etc.).
go to home directory and delete .m2 (hidden directory) folder and update project and run it.
Related
I have a .jar file, which I want to use in my current project which I am building with Maven. After some research I figured out that I need to install it locally. This I did using:
mvn install:install-file -Dfile="D:\Eclipse Workspace\TextOnlyJam\adapterLib\lwjgladapter.jar" -DgroupId=lwjgladapter -DartifactId=lwjgladapter -Dversion=1.0 -Dpackaging=jar`
I then added the dependency into my pom like so:
<dependency>
<groupId>lwjgladapter</groupId>
<artifactId>lwjgladapter</artifactId>
<version>1.0</version>
</dependency>
My project in exclipse now manages to resolve all dependencies and does not give me any compile errors. However after cleaning and updating my maven project several times, I still get the following error when running an install:
Failure to find lwjgladapter:lwjgladapter:jar:1.0 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
I assume that maven is looking for the artifact in the wrong location, however I can not figure out what I need to change here.
(I am also not sure if I need to add the dependency into , since it does not seem to change anything when I do.)
Okay, I just figured out that it was just a stupid mistake on my end. I looked into the repository folder and found, that my jar file was named `.jar``
So yeah, a simple copy and past error. Thanks for the help so far!
In an application that worked until now, I run in Eclipse the command Maven->Update project and I started getting errors.
I tried to fix it by deleting all the local repository and running Maven->Update project again. But these are the errors that I still see in my Markers view:
Missing artifact org.slf4j:slf4j-api:jar:1.6.6
Missing artifact org.slf4j:slf4j-api:jar:1.6.6
ArtifactTransferException: Failure to transfer org.slf4j:slf4j-api:jar:1.6.6 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of
ArtifactTransferException: Failure to transfer org.slf4j:slf4j-api:jar:1.6.6 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of
Error occured processing XML 'org/springframework/transaction/interceptor/TransactionInterceptor'. See Error Log for more details
The code hasn't changed and worked fine before.
Any idea on how I can fix these errors?
I am not sure about the particular mentioned jar.
But when you do build you should be connected to internet cause some external jar referred in POM get downloaded while building your project.
Also please check whether the mentioned jar is is maven repository or not.
Above jar is related to slf4j so i think it will be resolved if you are connected to internet .
Perhaps the SL4J jar is partially downloaded in your maven local repository. Try deleting it if it exists in the local repository. If that fails try creating a new dir called repository; mine is stored in ~/.m2 (ubuntu). Out of paranoia I rename the current dir as not to lose the jars already inside it.
Can a pom file uploaded to a remote repository via mvn deploy have a classifier in its name?
For example, if I have artifacts Webapp-1.0.war and Webapp-1.0-CLASSIFIER.war can I easily have Webapp-1.0.pom and Webapp-1.0-CLASSIFIER.pom?
I'd like to be able to deploy artifacts with multiple classifiers to the same repository, but the mvn deploy goal always fails because it's trying to upload a pom that's already there.
I don't want to use mvn deploy:deploy-file if I can avoid it because I don't want to unnecessarily complicate my CI build, i.e., having to specify file/url as configuration parameters because the file and url will change depending on whether I'm deploying a snapshot/release version.
Your problem is the understanding of Maven. If you produce an artifact which has an classifier it means having a pom which describes creating the artifact with the classifier as well as an artifact without an classifier. In other words your problem can be solved by having a single pom file. Furthermore you can deploy an artifact and several artifacts with classifiers with a single call to the maven-dependency-plugin call like the following:
mvn deploy:deploy-file
-DgroupId=com.soebes.test
-DartifactId=x1
-Dversion=2.7.5-SNAPSHOT
-Dfile=TheMainArtifact.jar
-Dclassifiers=first,second
-Dfiles=firstFile,secondFile
-Dtypes=zip,xml
-DrepositoryId=RepositoryId
-Durl=URLOfTheRepository
With the above (into a single line) you can deploy several files with a single deploy command without changing the configuration of Neuxs or any other repository manager to allow redeploying (wrong way!).
I've run into this before too. As far as I know, classified POMs aren't allowed.
The trick is to configure the remote repo to allow the POM to be updated while not allowing redeploy of other artifacts.
In Nexus, this is done through Repository Targets. The pattern to match POMs in a repository is .*/(?!.*\.pom).*. The target gets linked to Privileges, which may be assigned to Roles, which are then assigned to Users. (Memory is a little fuzzy here, I got this working and then decided to use deploy:deploy-file instead.)
There's no such thing as a classified pom. For every groupId + artifactId + version there's exactly one pom, and this pom is also used for the attached/classified artifacts. So this means that for instance that the main artifact and all the attached artifacts have the same dependencies.
Most used attached artifacts are javadoc and sources, for which this makes perfectly sense.
I am on Netbeans and don't know Maven much. Whenever I import, open some Maven project, it starts donwloading something from some central repository, sometimes huge. It downloads things in .m2\repository.cache\m2e. I have limited bandwidth and don't want this. How to stop this?
I have set Options>Java>Maven>Dependency Download Strategy to never. Also tried mvn -o install and mvn -o for offline. Not solved.
The Maven way is to get you what the project says it needs, but you have not already downloaded to your local repository.
The huge file is the list of what is actually available in Maven Central, and for some reason unknown to me it is downloaded on a regular basis. If you do it once, it should be kept for future sessions.
Maven will download all the dependency only once to the local repository and not again and again.
Weather you have limited or unlimited bandwidth you have to download it to execute your project.
Maven has a very modular architecture. That means the the thing you get when you download the Maven distribution is in reality small core functionality.
The rest is downloaded from a Maven artifact repository, like Maven Central (which is the default repo).
Note that this applies not only for dependencies (the library your project uses), but also your plugins (i.e. the stuff that compiles, packages, and otherwise builds the projects). Hence the large number of downloads.
Like the other answers said, if you don't delete your local repository it should eventually contain all the artifacts (dependencies and plugins) you need without re-downloading. The only exception are SNAPHSOT dependencies which can get re-downloaded periodically, depending what's in your POM and settings.
Ultimately, you have two possibilities:
If you have access to a higher-bandwith connection somewhere, you can build the projects while using it, and your local repo will still store the needed artifacts.
If you have several computers/configurations behind a local network, you can set up a Maven repository manager, like Nexus or Artifactory, and use it as a local mirror. Note that those still need to download the artifacts at first as well.
But there isn't much else you can do. "Maven downloading the Internet" is, unfortunately in your case, by design.
I have started working on a new project using Maven, and I'm unable to have it work properly on eclipse. I have multiples of this error :
ArtifactTransferException: Failure to transfer com.caucho:hessian:jar:3.1.5 from <repository> was cached in the local repository, resolution will not be reattempted until the update interval of Archiva SIVPN Internal has elapsed or updates are forced. Original error: Could not transfer artifact com.caucho:hessian:jar:3.1.5 from/to Archiva SIVPN Internal (<repository>): No response received after 60000 pom.xml /<file> line 2 Maven Dependency Problem
Description Resource Path Location Type
Missing artifact com.caucho:hessian:jar:3.1.5 pom.xml / line 2 Maven Dependency Problem
After doing some research, I found that it was probably either the pom.xml that's wrong, or that I have proxy problems.
I checked that the resource was available on our repository, and that the pom snippet is the same as declared in my code :
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
<version>3.1.5</version>
</dependency>
My proxy works just fine for the trunk of the project, and there is no other proxy I'm aware of.
I thought it was maybe a one-time connection problem, but making a new maven build with -U didn't resolve the problem.
I also found https://stackoverflow.com/questions/6111408/maven2-missing-artifact-but-jars-are-in-place
with several I-don't-know-what-else-to-do solutions, but it didn't work for me...
Since the lead developer is on vacation and I have little experience on mvn, could someone tell me other potential problems that could be responsible for this ?
Thanks in advance for answers :)
Open a command prompt, go to your project directory and run: mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
The eclipse:eclipse portion will regenerate your project files etc, the last 2 properties are more for convenience but I like downloading the sources and javadoc.
After a failed attempt, maven will leave a small file in your local .m2 repository that will prevent any attempt to re-download the file unless the update interval has elapsed or you force the updates using the maven -U switch described in other answers.
Just delete the folder for that artifact in your local m2 repository and update you project; a new download attempt will trigger.
rm -rf ~/.m2/repository/com/caucho/hessian/3.1.5