Maven - Not able to open jars it is downloading - maven

Whenever I try to run mvn clean install on my code, maven runs and start downloading jars, after downloading some jars It give an error i.e. Not able to open xxxxx.jar
On first though i changed that particular jar , but this error is coming for more jars, then i tried to take my friends repository.
And then it works fine for the jars already available in my friends repository. But whenever it have to download new jars from central repository same error occurs.
I tried 100 of time deleting .m2 folder and create it again but no luck.
I also tried switching maven installations or version from different friend and maven official websites but still No Luck
I am fed up of this. Trying from last week.
Please Help

Just a quick suggestion from the top of my head:
You could take a look at the .jar-Files that get downloaded using a text editor or even better some hex-editor. Depending on the network from that you are accessing the repository there might be some kind of proxy-server that intercepts the jar-download-requests and sends back some html-page - at least it might do so in our company-network.
If the text-editor just shows some strange characters try opening the jar-file with some zip-tool (eg. 7zip) and see if that shows some error.

Related

STS on Linux - Could Not Calculate Build Plan

After installing the Spring Tool Suite, I tried to create a maven project and this is what I get in an instant:
So waddap Maven/STS creators? How do I make your product work?
To any noobs like me who got overwhelmed by this error, here's what I did:
Go to your .m2/repository, where I think Maven stores its configurations files, then wipe it clean, delete all files, delete the 'repository' folder even.
I then closed the STS IDE and restarted it. You can see in 'Progress tab' that Maven is downloading new files.
Saw the same 5 errors, right clicked and clicked 'Quick Fix'. That's it.
This post was helpful too.

Download maven2 repository for offline use

We are developing offline due to limited internet resources and would like to run once every several months a whole grab of an external repository (e.g repo1.maven.org/maven2 - Disk space isn't an issue).
Today I'm using a simple POM that contains a lot of common dependencies that we are using, I've set my local maven to use a mirror to proxy thru a local nexus repository to cache locally and this is how I'm grabbing for offline use - but that isn't very effective.
I'm now looking for a command line tool that allow me to run searches on maven repositories so that I can write a script that grab them all to my local nexus installation and would like to hear if there is any or if there is another way to achieve that.
Thanks
Not a whole solution (yet) but I'm using httrack to grab the whole content of repo1.maven.org/maven2 - That is already better than nothing :)
In general, there is a goal in Maven dependency plugin called "go-offline"
So it allows to grab all the project dependencies and to store them in local .m2 repo.
You can find more information here.
If you want to run Maven and tell it to behave like the network does not exist you can run it with "-o" option (offline mode). So that if there is no dependency installed locally, Maven won't even try to go to network and bring it - but will fail the build.
On the opposite, if you want to force Maven to check and bring new versions (otherwise they already should be in your repo), you can use "-U" option.
I'm not really sure I've got the point about general search-and-download use case. Usually people install Nexus or Artifactory once in a network so that each dependency will be downloaded only once. In local development machines people usually just work with filesystem and don't maintain tools like this.
Now if you want to copy the whole repository from internet (for copying it later to some other network or something) you can just use crawlers like Apache Nutch for example or craft your own script that will recursively download all the files.

Maven is over 100%! [downloading no-stop] [duplicate]

everytime i start with a fresh new workspace, m2eclipse downloads nexus-maven-repository-index.gz from the maven central repository.
this is good.
but,
some times, i just want to start a new workspace, and not wait for it to download,
it tried copying the whole .metadata directory from an old workspace to the new one,
but the list of maven artifacts are still empty.
is there a way i can cache it?
or at least download the file once, and the copy/extract/repackage it so that m2eclipse thinks it has already downloaded it and allows me to search for maven artifacts.
or a short version of the question
where and in what format is the "nexus-maven-repository-index.gz" file stored in the workspace?
The index is stored in the plugin's metadata location, i.e.
[workspace root]/.metadata/.plugins/org.maven.ide.eclipse/nexus
There will be one folder for each remote repository index in use.
You can configure the plugin to not download the index at startup too. Got to Window->Preferences->Maven and uncheck Download repository indexes at startup, you'll have to remember to reactivate it to get any updates though
Update:
I just verified that copying the metadata works. M2Eclipse will still contact the repository to download the deltas (assuming the above option is checked), but that only takes a few moments as it is only downloading the deltas.
Depending on your situation, you may want to try running a managed repository such as artifactory or nexus.
Configure it as the one-true-source-of-everything in maven, that way the initial download should only be from a local location and hence fast.
There is similar problem in my company, due to the network/security restrictions, the index file can't be downloaded by m2eclipse.
I have tried to use apache, to direct maven.org to my localhost to provide the index.(it should work, you can try). But again, network restriction disables local pc level ds resolution.
Last solution is try to downlaod nexus-maven-repository-index.zip, extract everything inside this zip, except the timestamp file, and extract and replace everything into the corresponding index folder for central repository.
It works. :-D

archiva extra file not visible

I'm trying to also upload a deployment plan for certain web application projects.
This file has the extension '.dat'.
I can upload the file to archiva successfully using the deploy:deploy-file command. (checked by calling the url and it's there)
The problem i'm having is that i can't see the file in the downloads box on the screen when browsing to it, which makes it pretty pointless to upload it to archiva if noone can see that it's there.
Is this archiva only showing certain file types or is this a caching issue?
Where can I find more information about what is being shown in that box?
archiva version:
Apache Archiva 1.3.3
What you need to do is go to the "Repository Scanning" tab, and ensure that **/*.dat files are included in the list of artifacts to be detected. Afterwards, you will need to go t the "Repositories" tab and scan the repository again to have it appear.
Uhm that's not part of the visible files.
BTW that should work with last 1.4*

compiling with maven and nexus stuck on downloading artifacts

we are using here nexus 1.9.2.4 and maven 2.2.1 and on one pc (and only that one) when we try to compile our code using maven, it get stuck on downloading jars.
for example it'll be stuck on:
Downloading: http://mainserver:8081/nexus/content/groups/public/org/codehaus/mojo/javascript/javascript-maven-plugin/1.0-alpha-1-SNAPSHOT/javascript-maven-plugin-1.0-alpha-1-20090530.211438-7.jar
17/54K
and won't continue at all. tried using maven 3.0.4, but with the same result.
the machine runs windows 7.
any advise will be appreciated
This appears to be a bug related to using Maven on Java 7 and 64bit Windows. I have been experiencing similar problems.
The maven bug report and some discussion can be found here:
http://jira.codehaus.org/browse/MNG-5162
Workaround documented here:
https://cwiki.apache.org/confluence/display/MAVEN/ConnectException
Add -Djava.net.preferIPv4Stack=true to MAVEN_OPTS
Maven really needs to have some kind of support for mirrors and failsafes for the qurkeyness of the internet. Really, not everyone is going to be able to have a peered connection with the Oracle and Apache repositories. Every internet connection is going to drop a packet here and there, the "get a new ISP" response from Maven fans wouldn't help even if it were an option.
I've been staring at a 400k download go nowhere for about 10 minutes. I've noticed it gets stuck on the same files every time I wipe my repo too (bad sector maybe?). Which is a complete pita since it doesn't seem I can specify mirrors for it (short of hacking a hosts file). If you're a Maven project leader, look to Aptitude for ideas on what Maven could be.
EDIT:
I found a solution to my Maven problem here.
https://jira.codehaus.org/browse/MNG-5162
Under Ubuntu 13.10 simply...
sudo gedit /etc/environment
Add
MAVEN_OPTS="-Djava.net.preferIPv4Stack=true"
Save
Close
Reload terminal.

Resources