Maven project in Eclipse gets no search results in "Select dependency", but added manually downloads resources - eclipse

No results when doing this
Both in Eclipse 4.20 and 4.25** with m2e 2.0.4 — Maven is embedded 3.8.6 — when in the pom.xml of a maven project and having selected "Add" of the "Dependencies" tab, I search for a known maven resource and there are no results found, for example if I'm looking for 'spring', and I enter in the field "Enter groupId, artifactId, or sha1 prefix or pattern (*):", for example 'spring', 'spring*' or '*spring*'.
I've never had to fill in Group Id or Artifact Id before, but the dialog is indeed stating neither of these can be empty. If I fill them in with say 'org.springframework' and 'spring-core' for example, this makes no difference other than it then says "Searching 'spring'", if that's my search term. Still nothing is found.
Expected
That just typing say 'spring', for example, in the search field would give me some results. This has worked like this for me for more than a decade, so that's why I'm expecting this to work.
Tried this so far
I've tried to re-index, but this is only possible in Eclipse 4.20 and not in 4.25… <Edit> actually if you click the circling arrow symbol Eclipse offers to "Reload settings.xml" which is said to "rebuild the indexes for the repositories". However, this makes no difference in either version.</Edit>
"Download repository index updates on startup" is active. Also tried with it off.
Do not automatically update dependencies from remote repositories" is disabled.
Also tried making a fresh workspace in 4.25.
Maven > Update project with Force Update config.
disabled any network filters. Though this does not seem to be involved, see below.
Restarted the system.
Checked the fresh workspace for settings that could affect maven and found none. There is only a version.ini file inside .metadata.
Read several previous questions like this one from the last 10 years. All are familiar, but suggestions from these older cases make no difference in this case.
Artefacts are downloaded
If I add the artefacts manually as text in the pom.xml, there are no issues getting them to download to my repository folder, which is why I don't think there is a network problem. When I do this there are no issues whatsoever to develop.
Clues
I don't think these should make a difference:
In "Maven" > "User Settings" Global Settings is empty
User Settings points to a non-existing settings.xml
but maybe these could point to a solution? Again, that manually adding works, may suggest these are both non-issues.
I do wonder if the m2e config/install may be involved. I'm not sure how though.
** Note that Eclipse 4.25 is aarch64 fresh installed on this Apple Silicon Mac with macOS 12.6.1. Eclipse 4.20 is also aarch64, but has been updated since 2021.

Searching for dependencies is currently broken in the Dependencies tab, but you can search and add dependencies in the pom.xml tab instead, which works even without downloading an index.
See Eclipse m2e issue #930: Artifact search is not working in Add dialog on Dependencies tab

Related

Eclipse does not show source code of maven dependencies in debug view

I've filed a bug by now: 495662 - Source Lookup: Not seeing source code in the debug view.
My issue sounds familiar but it can't be since that issue appears to be fixed. However,
I have set a breakpoint in a class coming from a dependency (via maven). The source code got downloaded but as the program reaches the line all I get to see is
Source not found.
I've tried to add lookup paths by clicking at "Edit Source Lookup Path..." but nothing changed. I don't know what I have to add such that the debugger finds the sources.
It appears that this stopped working for all my dependencies.
How did I break my source lookups and how can I fix it?
Could be important:
I am running my tomcat from a maven build these goals:
tomcat7:run-war -am -pl mz-web-server -Denv=dev
but this hasn't been a problem so far.
Further, none of my maven dependencies e.g. gwt-user*.jar or `spring*.jar or anything are listed in the Source Lookup Path. There is only the "Default" path which doesn't contain it either - shouldn't those jars be somewhat listed there?
After downloading Eclipse Mars 2, removing my project completely and re-importing it without any .settings, .project or .classpath files, I am still seeing this problem. I can't tell if this is really an Eclipse bug but at this point I don't know what else it could be.
I also tried removing C:\Users\<username>\.eclipse and restarted the IDE without different results.
These are the included libraries under Maven Dependencies. As you can see e.g. spring-security-core-*.jar is included and the source is pointing to the local maven repository. Clicking on edit I see the full path C:/Users/Stefan/.m2/repository/org/springframework/security/spring-security-core/4.0.3.RELEASE/spring-security-core-4.0.3.RELEASE-sources.jar and yes, the file is really there.
My Classpath Variables:
I don't know what the actual problem was and why it stopped working. As you can take out of my question I actually downloaded a clean version of Eclipse, checked out the naked project and imported it with maven without results.
However, I found this com.ifedorenko.m2e.sourcelookup plugin. The link was provided in "Java Debugging: Source not found".
Go to Help > Install New Software .. and use
http://ifedorenko.github.com/m2e-extras/
to search for the links. After installing this plugin I was finally able to debug the source code of dependencies.
Tested for Eclipse Neon:
Press 'Edit Source lookup ...', press Add button for 'Java Classpath Variable' in dialog and choose M2_REPO variable and press 'Extend...'.
Then choose source jar file for wanted dependency from file system tree.
After that press 'OK' on all dialogs and relaunch debug process.

Subclipse: How to add the default output folder to version control (*.class files)?

I am using eclipse 4.2 and Subclipse 1.8.20.
I am trying to add the contents of /WebContent/WEB-INF/classes to version control (this is also the default output folder of my project).
First let me state that this is possible with TortoiseSVN. I do understand why by default Subclipse ignores this directory, and I tried to change the Team settings, but I am not seeing a relevant entry for *.class files:
Is this at all possible with Subclipse?
More info:
Old an unanswered similar question: http://subclipse.tigris.org/ds/viewMessage.do?dsForumId=1047&dsMessageId=473163
Same topic but opposite question: How can I ignore build directory in Subclipse?
It is a horribly bad idea to version your build directory. Every time Eclipse does an auto-build it will cause all of the files to need to be committed again.
To answer your question, all Eclipse team providers automatically ignore any resource that is marked as "Derived" by Eclipse. The Derived flag is set on files that are created by the Eclipse builders. If you select one of these files that are ignored in Eclipse, right click and choose Properties. Navigate to the Eclipse Resource page. There will be a bunch of checkboxes. You should see that one of these is labelled Derived and will likely be checked.
Do not try to change the checkbox value. I am just pointing out where you can see and confirm this.

AspectJ causing "Editor does not contain a main type" error

After installing the AspectJ Development Tools into Eclipse, the "Run" button and the Ctrl-F11 shortcut both become nearly useless: using them (or the Debug button) will throw an "Editor does not contain a main type" error message, even for projects that do not require a main type to be present (eg. Android application projects). Standalone Java projects with a proper main type defined work fine - so it seems AJDT is forcing Eclipse to check for a Java main() without checking the project type first. Whether or not the project is an AspectJ project makes no difference, either.
The problem only appears when the file you are currently editing has either ".java", ".aj" or ".class" anywhere within its filename (note: it doesn't actually have to end with those extensions, as long as it's anywhere in there - readme.txt will work, readme.java.txt won't).
Two ways I've found to work around this - regardless of whether or not it's an AJ project - after installing AJDT is:
Select a file within your project in the Package Explorer whose name doesn't contain .java, .class or .aj, and then hit Run (the Package Explorer has to remain active and selected).
Create a new Run Configuration for your project, and use it to launch your project. This still adds a pointless extra step, as well as being impractical for those who work with a lot of projects.
I've tried this on both Eclipse Juno and Helios (Windows XP x86 as well as Win7 x64), the result is the same. While it might seem like nitpicking it certainly isn't: AJDT is hijacking the most frequently used function of the IDE.
I've resorted to having two different Eclipse installations with their own separate workspaces on my work PC, one with AJDT installed, and one without, so I can use the IDE properly when I'm not working on anything AJ-related. Since my company is working on a project that would require other developers to install AJDT into their IDEs, this is a significant issue for us that goes beyond our own loss of time - I can't imagine a lot of developers would be willing to put up with a significant bottleneck being added to their workflow for absolutely no reason at all. So most likely, they will just ditch our product instead!
Update: This has been identified to be a bug inside AspectJ, and has been reported to the AJ development team. You can keep track of it here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=399660
As of this writing, the bug has already been partially fixed, restoring Run functionality to non-AJ-enabled projects.
I was just coming on this site to ask the same question. While I don't have an answer for why this is going wrong, I have a workaround which is helping me currently:
Go to Preferences > Run/Debug > Launching and select Always launch the previously launched application. This will introduce bearable behaviour when working on a single project. You will need to manually create a run configuration for your main class.

Eclipse : Maven search dependencies doesn't work

I created a new simple Maven project in a new Workspace.
When I open the pom.xml's Dependencies view in Eclipse editor, and I choose Add.. dependency, there's no search results no matter what search criteria I input in the search fields:
It instantly give me, for example, Results for 'spring' (0).
In my other workspace, with my existing projects I don't have this problem.
Is there a way to fix that ?
Eclipse artifact searching depends on repository's index file. It seems you did not download the index file.
Go to Window -> Prefrences -> Maven and check "Download repository index updates on start". Restart Eclipse and then look at the progress view. An index file should be downloading.
After downloading completely, artifact searching will be ready to use.
UPDATE
You also need to rebuild your Maven repository index in 'maven repository view'.
In this view , open 'Global Repositories', right-click 'central', check 'Full Index Enable',
and then, click 'Rebuild Index' in the same menu.
A 66M index file will be downloaded.
In your eclipse, go to Windows -> Preferences -> Maven
Tick the option "Download repository index updates on startup". You may want to restart the eclipse.
Also go to Windows -> Show view -> Other -> Maven -> Maven repositories
On Maven repositories panel, Expand Global repositories then Right click on Central repositories and check "Full index enabled" option and then click on "Rebuild index".
You can get this result if you are inside a corporate proxy and the new project isn't pointing to the correct settings.xml file with the proxy credentials.
You can also get this if you are using Maven proxy (Nexus, for example) and the index into the proxy is messed up somehow. I don't know a way to describe how to fix this. Fool around with it or call the one who set up the Maven proxy.
You can also get this if the new workspace hasn't yet downloaded the index either from Maven central or from the proxy. (This is the best one as you just have to wait a while and it will work itself out.)
For me for this issue worked to:
remove ~/.m2
enable "Full Index Enabled" in maven repository view on central repository
"Rebuild Index" on central maven repository
After eclipse restart everything worked well.
The maven add dependency is actually from the maven indexes. If the indexes is up to date, the result should be from there.
If you go to the maven repository, then select global repository, you should see a central ... tab, and select that, there should be a list of folders, and you should be able to see all the indexes from there. If not, then it means you didn't get the full index, then you can right click that and enable full index.
Another thing I annoyed me most is even I did everything, it still not showing anything when I type "spring". This is actually where I did wrong. If you just type some additional text "springframework", BOOM, the result is there.
I have the same problem. None of the options suggested above worked for me. However I find, that if I lets say manually add groupid/artifact/version for org.springframework.spring-core version 4.3.4.RELEASE and save the pom.xml, the dependencies download automatically and the search works for the jars already present in the repository.
However if I now search for org.springframework.spring-context , which isnt in the current dependencies, this search still doesn't work.
Use https://search.maven.org/ manually with the prefix fc: to search for class names. Both Netbeans and Eclipse seem to be too stupid to use that search interface and the gigabytes of downloaded repository indexes seem to not contain any class information. Total waste of disk space. Those IDE projects are so badly maintained lately, I wish they would move development to GitHub.
It is neccesary to provide Group Id and Artifact Id to download the jar file you need. If you want to search it just use * , * for these fields.

Searching for dependencies returns nothing

I've just installed Eclipse Juno with m2e installed.
Then, I've created a new Maven project and decided I want log4j, so I opened the pom.xml, clicked on the Dependency tab, clicked on the Add... button and typed in log4j.
Zero results. The only thing that it finds is junit (that was automatically added to the project with the quickstart archetype, it seems). Note that I can add the log4j dependency manually and it will work just fine, but I find the search feature really convenient!
I'm a kind of a Maven beginner, though I got m2e working no problem in Indigo. So I'm thinking I might have forgot to set something?
All you have to do is update or rebuild your workspace maven repository index.
Open your "Maven Repositories" view. Open Global Repositories and right-click on central. Enable full index and rebuild.
Initially the process will take several minutes. After that your search will start working.
You can automate this process by turning Download repository index updates on startup on in your workspace preferences under Maven
in case rebuilding your workspace maven repository index didn't work, try reinstalling m2e. I updated mine via marketplace and it started working again. I'm not sure what was the issue but I suspect some URLs got changed recently.
Just go to Window -> Preferences -> Maven
and check the option Download repository index updates on startup and click Apply. That's all.