Could not resolve dependencies while building in Maven - java

Hi I am trying to build a maven project.
After building initial projects successfully, its failing. The error shows that it failed to collect dependency from a particular location in the local repository.
When I went to that location the jar files are missing in it. So I guess it is supposed to download from the remote repository.
I am wondering whether it fails to download or I am getting anything wrong? Also a few posts suggest to delete the .m2 folder. Will that cause any problems or am I suppose to delete the few folders in it?
Thanks

Try to force update dependencies with the switch -U. At least you can be sure that it is not because of your local error in .m2.

Related

Maven Deploy/Install Not Resolved

I'm having trouble getting Maven to load some of my plug-ins. I either get an error saying these plug-ins weren't found or weren't resolved. I'm not sure why it can find some but not others.
Error:
Plugin 'maven-install-plugin:' not found
I have tried changing the Maven home path, unchecking work offline, use the plugin registries, updating the snapshots, automatically download sources/documentations/annotations.
I have also invalidated cache, and reloaded all Maven projects, and deleted the plugins from the .m2 folder.
Am I missing something simple here? I am a Maven noob.
Thanks,
A

Compilation error occurs if jars are added manually in Intellij

I am using Maven in my project, and for some reasons, some additional jars should be added manually (I have followed the step like Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project).
The package can be imported successfully. However, the compilation error happens, which indicates the package does not exist and cannot find the symbol of the used object.
I have tried the following tips but it remain unchanged:
Invalid caches / restarts
reimport
delete .idea file and .iml file
The scenario is quit similar to this one : https://intellij-support.jetbrains.com/hc/en-us/community/posts/206821195--beginner-question-including-external-jar-compile-error.
Please see the following sample images. It may run successfully but cannot be compiled well.
The reason is that when you add a library manually via IntelliJ, only IntelliJ knows about them and when you compile your code using Maven, it can't be find by Maven because Maven only searches for dependencies you defined in pom.xml.
You should install your libraries in your (at least) local maven repository and add them as a normal dependency in your pom.xml. Then you don't need to add them manually in IntelliJ.
You should follow the steps mentioned at Guide to installing 3rd party JARs
Update:
Also you should note that if you're working as a team, you should install this on the local maven repository of all developers (which is not practical). The best solution is to install a Maven repository (e.g. Nexus, Artifactory or Archiva) in a server on your local network and upload your private jar files on those servers. Then all developers can define the address of the local Maven repository server in their local Maven settings and use artifacts/libraries from that servers. Plus it works as a local cache/proxy to fetch any Maven artifacts and prevents unnecessary calls to public maven repositories.

POM file Uploaded by Artifactory Jenkins plugin won't resolve in Maven builds

I am building a jar in Jenkins and uploading it to an Artifactory repository. I've verified the jar, the pom, and the hash files are present in the repository. When I try to build a project on my machine that has a dependency on the jar, it downloads the jar correctly but then I get a POM file is missing message and the maven build fails. I don't see any rhyme or reason why this should fail, I've done an Artifactory trace on the jar and the pom in Chrome and Firefox and the response says that it found the files. So I don't understand what could bve causing the issue? We were running Artifactory 5.2.1 and upgraded over the weekend to 5.5.1, but it hasn't changed anything. What should I be looking at?
Thanks.
EDIT: This question is about to be moot. Discussions are in progress about setting up a generic maven repository and avoiding the use of Artifactory altogether, since it won't do what is needed.
First, make sure your groupId and artifactId are correct. I've lost a lot of time thinking it's a maven problem when it's really just that I reversed a couple letters in a long groupId.
Next, have you tried 'forcing' maven to bypass its local cache? Try running mvn -U <your tasks>
If that doesn't work, try deleting the ~/.m2/repository/path/to/the/artifact/with/the/missing/pom and use mvn -U again
OK, problem solved. Turned out to be a Maven problem, not an Artifactory problem. Our maven settings contain a proxy setting so we can pull down jar from Maven Central - problem was, our company url was incorrectly configured in the nonProxyHosts tag, was set to domain.org, instead of *.domain.org, so it was trying to retrieve the maven artifact through the proxy instead of going directly to the Artifactory server. My apologies to the Artifactory devs for blaming the problem on Artifactory.

How to resolve missing artifact error when using Eclipse AWS plugin?

I am using the aws Java plugin for Eclipse. I didn't have any issues during the installation process but after I used the plugin to create a sample DynamoDB project, I got this error
Missing artifact com.amazonaws:aws-java-sdk-cl....watchmetris.jar:1.11.123(click for 156 more...).
clicking didn't do anything.
I thought the error was due to the fact that I didn't install that jar during the installation process - I only installed "AWS Toolkit for Eclipse".
I went back into Eclipse and installed every non optional plugin from the aws(see below)
After I restarted Eclipse and tried creating my DynamoDB project again, I get a different failed to read artifact descriptor error(see below)
Has anyone experienced this issue before or know what the solution is? Elastic load balancer should be apart of AWS Toolkit which I installed. I've tried removing and reinstalling the aws plugin but I'am still getting missing artifact errors. I've looked at other threads on AWS plugin for Eclipse as well.
For anyone dealing with this issue with this issue, I got it to work! I can't really explain why it works though - maybe Maven's way of resetting some setting.
What I did was go inside pom.xml, the configuration file for Maven, and into the Dependencies tab. This is what I saw
I reasoned that the missing artifact was in the aws-java-sdk jar so I removed it. I then deleted the project from disk and created a new one. The new project came with the correct dependencies and no compiler errors!
The problem is not your AWS Toolkit, it's a problem of your Maven. Please try to create a project with Maven to check if Maven's setting is correct. If Maven is correct, please see your pom file in XML and check the dependency is correct? If you cannot create Maven project, it's means that your Maven setting is wrong somewhere!
I received a similar error "failure to transfer com.amazonaws:aws-java-sdk ...". The pom resolution could work, but here's another solution. So, when you start an aws project for the first time, certain artifacts necessary for maven are stored under .m2\repository\com\amazonaws.
What happened to me was that when I deleted one of my aws projects, I also deleted the resources being referred to which was somewhere in the aforementioned directory. And because the directory existed, eclipse's aws toolkit didn't bother downloading it again. I solved it by just deleting the $home.m2\repository\com\amazonaws directory. So next time I created a new aws project, it had to download all the artifacts.

Error building Alfresco CE 5.0a in eclipse

I am trying to build Alfresco CE 5.0a in Eclipse.I followed steps according to this link. The checkout was successful.But while building the sourcecode using maven(using clean install) I am getting the following error.
[ERROR] Failed to execute goal on project alfresco-core: Could not resolve dependencies for project org.alfresco:alfresco-core:jar:5.0.a: The following artifacts could not be resolved: org.mybatis:mybatis:jar:3.0.4-alfresco-patched, org.springframework.extensions.surf:spring-surf-core-configservice:jar:1.2.1-M16, org.springframework.extensions.surf:spring-surf-core:jar:1.2.1-M16, org.springframework:spring-web:jar:3.0.5.RELEASE, javax.servlet:servlet-api:jar:2.4: Could not transfer artifact org.mybatis:mybatis:jar:3.0.4-alfresco-patched from/to alfresco-public (https ://artifacts.alfresco.com/nexus/content/groups/public): No response received after 60000 -> [Help 1]
I guess this is because of this jar file under the Alfresco Core 5.0.a
Downloaded: http ://repo.maven.apache.org/maven2/org/mockito/mockito-all/1.9.5/mockito-all-1.9.5.jar
I couldn't find that jar file in the specified URL.
So how can I solve this.Can I change the dependancy in pom.xml?
Help Needed.Thanks in Advance.
First Question Will be ,Why you would like to compile alfresco source code?Are you aware that We can do many customization without customizing alfresco source code.
Above was only for your information.
First try to compile it without using eclipse.Due to that you are facing error.
If still problem persist, remove dependencies from your .m2 directory of your maven and make maven download this dependencies again.If you face similar error again for different jar than remove it from .m2 and again fire clean install command.
This will definitely solve your problem.
It may be that , above mentioned error is listing your all corrupted jar files so remove first and try it again

Categories

Resources