Convert to maven project in Eclipse results in an endless loop - java

This is related to my last question
One of the answers suggested that the error wasn't related to the AWS plugin but rather Maven. I used this as a reference to install the Maven plugin. The installation finished fine.
I made a simple Java project called Maven with a single class that outputs "Hello Maven". I then tried to configure the java project into a Maven project by going to configure -> convert to Maven Project. These are my settings for configuring my simple project into a Maven project(all default)
After clicking finish, I get into an endless loop. I've tried restarting Eclipse but that didn't work. This tells me that the issue in my other question was related to Maven. I'am new to Maven. Can someone guide me into the next step for debugging this issue? There's no error output I can look at.

Related

Unknown error in maven pom.xml when using intelliJ

so I recently installed maven in my pc. Did a little maven project with the guide of an online course in Udemy but I didn't get to finish it. My problem here is when I try to open maven in IntelliJ, pom.xml looks like this and I'm scared that this might cause a problem when I start another project on web dev using Java, SpringBoot, and RestAPI. I'm new to this so I'm not sure what to fix and make sure I will not face any errors. Thank you so much and looking forward to your helpful response.
It can be known from the error message that the reason for this error is because you did not add a constraint file for the xml file, so IDEA is prompting you to add a constraint space for the xml file.
You should check the constraint format of maven's pom.xml file and add it to your pom.xml file.
Another thing to know is that IDEA will use the built-in maven by default instead of the maven you downloaded. If you want to use the maven you downloaded, you should go to the settings to modify the maven configuration. (Of course you can use maven that comes with IDEA).

Eclipse Maven - Autosearch when writing code

Today I started with Maven in Eclipse. Now I have a little Question. I saw in a video that when you write Code and use a Class of another Dependency for example and go over the "Error" there should be an Option to search for the Class / Dependency in Maven. But this option is not there in my Eclipse (in the "Mouseover" Menu).
Here some Infos: I use Eclipse Mars and m2eclipse for it. Maven is configured right so: Index Updating etc.
But I dont have the option nonethereless.
The option was removed long ago.
You need to search the class through Maven Central.

Failed make using IntelliJ, JBoss due to multiple configuration issues including Pom.xml

Introduction
I have inherited a project that I am able to build using the maven command mvn clean install -DskipTests. However, I am not able to make using the inteliJ button. I am able to deploy the project using Remote debugging but I am not able to hotswap new code in/out due to make not working.
Errors during make
When I run make I get a series of errors such as:
Older Maven Version
I have been told to use an older version of maven, specifically 3.0.3 .
I have gone to the settings for the current project and manually set maven 3.0.3 as the default.
Question 1) Is there a chance this does not apply to the sub directories? Should I change my system path variable and set the old maven as the system default?
Red Highlighting in POM.XML
I am seeing that InteliJ is highlighting a pom.xml in one of the sub-modules for errors. This code has been committed by colleagues so it is strange that there would be errors.
and
and
Question 2) Could Maven be the issue here? Or could there legitimately be an error in the POM.xml?
Maven > Reimport does not solve the issue
Additionally, running Maven > re-import does not solve the issue.
Updating Indices
I tried selecting the proposed option to Update Maven Indices. This has brought up the following dialogs and is downloading in the background from both the maven servers but also a private artifactory.
The indices were taking too long to update so I invalidated the cache/restarted and will try again as proposed # Intelli J IDEA takes forever to update indices .
Summary of Questions
Question 1) Is there a chance this does not apply to the sub directories? Should I change my system path variable and set the old maven as the system default?
Question 2) Could Maven be the issue here? Or could there legitimately be an error in the POM.xml?
Update
Indices finished downloading after some time.
I removed some of the problematic entries in the pom.xml and the project now is not red-underlying the various packages that they do not exist.
I am starting to believe the pom.xmlwas problematic. However, if someone downloads the dependencies/indices, then the problem no longer appears.
Update - Remove Module
I talked with a colleague and he said the specific modules are no longer used (even if they do include faulty pom.xml files). I was told to right click the module and select "remove module". This pretty much stopped the problem.
I talked with a colleague and he said the specific modules are no longer used (even if they do include faulty pom.xml files). I was told to right click the module and select "remove module". This pretty much stopped the problem.

Eclipse + Maven: What is M2E really doing?

I wonder if when I hit Project > Clean, mvn is really involved in setting up the build process.
Is M2E (Maven to Eclipse, standard plug-in) just reading and analyzing the pom setting up / updating the Eclipse project the way specified by the pom or does it actually run the phases defined in the pom?
I just wonder what happens on Project > Clean when it comes to Maven... .
[Update]
Since people seam to get confused by the question here are more information:
I altered the build process of the project in maven and it seam to be not reflected by actions I trigger in the IDE directly. So M2E seams to be more like a translator of maven settings and applying the same settings to Eclipse without altering the behaviour. It also would explain why M2E is providing connectors in the first place.
Since I could not verify this, I boiled it down to a simple question that if answered, I know the answer to the more difficult question regarding Maven integration in Eclipse.
[Update2]
M2E has the ability to execute certain phases. I added an answer. This answer is not obvious since I searched the internet up and down before I asked this question. Also I only found the answer by some thoughts that were raised by the previous answer to this question which is what I asked for but only half of the picture.
This question is a perfect example why often on stack overflow the obvious is neither asked nor was implied nor is the final answer and the trigger happy close friendly swarm sometimes misses the point :-).
When you clean a eclipse project, eclipse clears output directories of the project, without invoking maven. This is a eclipse operation that is executed over all projects you have, whether or not the projects has been imported from maven.
If you want to run maven targets on an imported eclipse project, you could use Run configurations to explicitly invoke maven targets on the projects.
M2E does has its own mapping for each phase. Depending on this mapping Eclipse actions are replaced, extended or left-as-is.
From the following picture one can see that the clean command is set to ignore. You can view/change those mappings by Project Properties > Maven > Lifecycle Mapping. So this is actually (as-expected) a per phase mapping. By downloading new connectors M2E is able to provide additional mappings to special phases not supported by default installation.

The container 'Maven Dependencies' references non existing library - STS

I'm using win8 previously I had been running Eclipse Juno on my pc but from now on I wanted to start using STS, I am getting the below error as soon as I create a new project. I deleted my .m2 folder and everything related to Eclipse in order to start over from scratch still didn't work, I've ran out of ideas. Any advice???
Can not find the tag library descriptor for "springframework.org/tags" index.jsp /app/src/main/webapp line 6 JSP Problem
The container 'Maven Dependencies' references non existing library 'C:\Users\Pablo.m2\repository\org\springframework\spring-webmvc\3.2.3.RELEASE\spring-webmvc-3.2.3.RELEASE.jar' app Build path Build Path Problem
The project cannot be built until build path errors are resolved app Unknown Java Problem
ArtifactTransferException: Failure to transfer antlr:antlr:jar:2.7.7 from 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. Original error: Could not transfer artifact antlr:antlr:jar:2.7.7 from/to central (http://repo.maven.apache.org/maven2): No response received after 60000 pom.xml /app line 1 Maven Dependency Problem
22 more errors like this for each of my dependencies...
Class 'org.springframework.web.servlet.view.InternalResourceViewResolver' not found [config set: app/web-context] mvc-config.xml /app/src/main/webapp/WEB-INF line 16 Spring Beans Problem
So I get you are using Eclipse with the M2E plugin. Try to update your Maven configuration : In the Project Explorer, right-click on the project, Maven -> Update project.
If the problem still remains, try to clean your project: right-click on your pom.xml, Run as -> Maven build (the second one). Enter "clean package" in the Goals fields. Check the Skip Tests box. Click on the Run button.
Edit: For your new problem, you need to add Spring MVC to your pom.xml. Add something like the following:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
Maybe you have to change the version to match the version of your Spring framework. Take a look here:
http://mvnrepository.com/artifact/org.springframework/spring-webmvc
I got the same problem and this is how i solved. :
Right click your Spring MVC project, choose Run As -> Maven install.
Observe the output console to see the installation progress. After
the installation is finished, you can continue to the next step.
Right click your Spring MVC project, choose Maven -> Update Project.
Choose your project and click OK. Wait until update process is
finished.
The error still yet, then do Project->Clean and then be sure you have selected our project directory and then do the follow Project->Build.
Although it's too late , But here is my experience .
Whenever you get your maven project from a source controller or just copying your project from one machine to another , you need to update the dependencies .
For this Right-click on Project on project explorer -> Maven -> Update Project.
Please consider checking the "Force update of snapshot/releases" checkbox.
If you have not your dependencies in m2/repository then you need internet connection to get from the remote maven repository.
In case you have get from the source controller and you have not any unit test , It's probably your test folder does not include in the source controller in the first place , so you don't have those in the new repository.so you need to create those folders manually.
I have had both these cases .
I'm a little late to the party but I'll give my two cents. I just resolved this issue after spending longer than I'd like on it. The above solutions didn't work for me and here's why:
there was a network issue when maven was downloading the required repositories so I actually didn't have the right jars. adding a -U to a maven clean install went and got them for me. So if the above solutions aren't working try this:
Right click on your project -> Choose Run as -> 5 Maven build...
In the Goals field type "clean install -U" and select Run
After that completes right click on your project again and choose Maven -> Update Project and click ok.
Hope it works for you.
I finally found my maven repo mirror is down. I changed to another one, problem solved.
Today I had this same problem with another jar. I tried multiple things people said on Stackoverflow, but nothing worked. Eventually I did this:
Close eclipse and any project-app that is running.
Delete the .m2 folder (Users --> [your_username] --> .m2). It's an invisible folder, make sure you are able to view invisible folders.
Restarted Eclipse (I guess it works in other IDE too) and updated my project.
Now it works again for me. Perhaps this solves the problem for someone else too.
I have solved it using "force update", pressing Alt+F5 as it is mentioned in the following link.
In Eclipse adding to the #Saket Mittal response.
Run As > Maven build...
Set goals clean install and run

Categories