Errors in eclipse pom.xml but maven clean install is successful - eclipse

It seems that the property ${user.dir} is recognized by Maven but not recognized by Eclipse. I am seeing the errors below in the pom.xml file in eclipse everywhere then there is a reference to this section:
<outputDirectory>${user.dir}\Nightly_Build\lib</outputDirectory>
The errors are:
Cannot invoke "org.eclipse.core.runtime.IPath.segmentCount()" because "outputDir" is null (org.apache.maven.plugins:maven-jar-plugin:2.4:jar:bpcstudioToats:package)
java.lang.NullPointerException: Cannot invoke "org.eclipse.core.runtime.IPath.segmentCount()" because "outputDir" is null
The good thing is that the command mvn clean install is working fine. I run this command from eclipse right-click run/build and from the command line, and all is working fine.
This is causing eclipse not to recognize the maven dependencies correctly, and reporting compilation errors in various places, and the compilation in maven is successful.
Any idea how to resolve this issue?
Update:
I replaced all references to user.dir with project.basedir in all pom.xml, did a project clean, and updated maven, then all errors disappeared. But, I could see a new folder was created under each project base directory. I will check what was the intent of using user.dir and then will provide an update.

Related

Maven dependencies are downloaded but eclipse won't resolve them

A multi-module maven project will be buit successfully from the command line using mvn clean install and is loaded successfully in vscode without any compilation errors.
When the same project is opened in Eclipse (version Version: 2022-09 (4.25.0), Build id: 20220908-1902), I see compilation errors for dependencies not resolved for example:
The import com.ibm cannot be resolved
I tried everything to resolve this error, nothing worked, for example:
Update maven project
Project / Clean
Remove maven feature, delete the project, reimport, and convert back to maven
The strange thing is that if I delete the repository folder from <user-home>\m2.\repository and make a simple change to any pom.xml file, the entire repository folder is downloaded. Also, I located the JAR file using VSCode (ctrl-click) and I can see the related JAR logEnglish-1.0.jar in the local .m2 repository folder <user-home>\.m2\repository\logEnglish\logEnglish\1.0\logEnglish-1.0.jar.
The problem is that only Eclipse is reporting compilation errors and a lot or maybe all of the maven dependencies are not resolved. This is also affecting the debugging option and it breaks due to such compilation errors.
Another thing I noticed is that the Maven Dependencies folder is not showing on the Project Explorer no in Package Explorer, but I can see Maven Dependencies entry in Project Properties -> Configure Build Path -> Libraries.
Please help resolve this issue so that I can clear the compilation errors in Eclipse.
Update 1:
I created a simple parent/child pom with one inner module. I was able to reproduce the problem right away.
See attached snapshots for details.
The compile errors will show only when you open the parent project. If you open the inner module directly as a separate project, no compile errors will show and I can run and debug the project. However, if I try to debug the parent project, I will get a warning due to compile errors, and I can run the project only and only after I added the jar of the inner module to the classpath of the debug configuration. If I don't add the jar file, I will get this error Error: Could not find or load main class training.FirstProjectClass. The project is being built successfully using mvn clean install and that's why I can run the project. If I run mvn clean then I cannot run the parent project.
Also, notice how the maven dependencies folder will show if you open the inner project directly, but, it won't show if you open the parent project.
In addition, I noticed if I add the inner project to the classpath of the debug config then it works also without building the project and without generating the jar file using mvn clean install.
Based on the above, the problem boils down to:
How we can resolve the dependencies of the inner modules when you open the project using the parent maven project?
If we can resolve the errors, then we can run without seeing the warning, and we have the assurance that the project is clear before running the mvn clean install command.

Eclipse Maven errors when I'm only using Gradle

I began to get errors after downloading Nodeclipse and creating a Gradle project with New Gradle Project -- sample project "Java Quickstart". Whenever I re-open Eclipse, I get this error:
"Updating Maven Dependencies" has encountered a problem. An internal
error occurred during: "Updating Maven Dependencies".
org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob$1
I have never used Maven, but I tried to investigate the error. When I try to open Preferences > Maven, or most (but not all) of its subfolders, I get:
Unable to create the selected preference page. An error occurred while
automatically activating bundle org.eclipse.m2e.core.ui (545).
I looked on Maven Central and there is no m2e folder in org/eclipse. I also looked in Eclipse/features for pom.xml files and I have folders starting with org.eclipse.m2e, but no org.eclipse.m2e.core.ui.
Edit:
I created a new workspace and got the same error message as soon as I created a New Gradle Project based on Java Quickstart sample project. I did this twice and the second time Eclipse logged an error. Some relevant lines from the stack trace:
Exception:org.osgi.framework.BundleException: Exception in org.eclipse.m2e.core.internal.MavenPluginActivator.start() of bundle org.eclipse.m2e.core
Exception:java.lang.NoClassDefFoundError: org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob$1
at org.springsource.ide.eclipse.gradle.core.wizards.NewGradleProjectOperation.createProjectContents(NewGradleProjectOperation.java:106)
First try to build your project from command line.
Enide 2015 by Nodeclipse has built-in Terminal Ctrl+Alt+T
run gradle build
or right-click build.gradle Run as -> gradle build
Then see and think
You are building with Gradle, so don't look at Maven preferences, but Gradle one.
Possibly you confused Gradle and Maven and made wrong preferences, you can try again in new workspace.

Eclipse not downloading the apache jars from pom.xml

I am using Eclipse as my IDE and want to build a maven program, but I see that neither my maven clean or maven install is working
For maven clean,I get the error:- "Failed to parse plugin descriptor for
org.apache.maven.plugins:maven-clean-plugin:2.4.1 "
I also tried the help mentioned in the link
[ERROR] For more information about the errors and possible solutions, please
read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/PluginDescriptorParsingException
but it is not helping
Also my maven install is not working,it shows the following error:
] Failed to parse plugin descriptor for org.apache.maven.plugins:maven-resources-plugin:2.5
I had tried all the approaches mentioned in similar issues which include deleting the directories u nder .m2 folder, deleting .m2 folder, re-installing apache-maven on my system but nothing is working.
And when I run the same maven program under intelliJ, I could see the jar names but when I click on them it shows no contents which means they are not getting downloaded properly...'
So not able to work on my java maven project.Please help.
what is the fix for such environmental issues.
Even I tried re-installing eclipse, intelli J but nothing helps.
The issue got resolved by following the steps mentioned at:
https://issues.sonatype.org/browse/MVNCENTRAL-299
try to download appropriate maven version from https://maven.apache.org/download.cgi. and follow installaion steps mentioned.
set the "M2_HOME" and "MAVEN_HOME" as environment variables pointing to maven installation directory.restart your machine.
set the maven settings in eclipse through preferences tab.

Intellij unable to resolve references to a specific jar file

In a given project that is driven by sbt there is some kind of corruption in the project libraries specifically for a MavenLocal repository used for kafka-spark-9.7.2.jar in which:
references to the classes provided by that jar are marked as "symbol not found" by the editor parser
however the editor (strangely) does offer to import the classes
but after accepting the import, the symbols are still marked in red as unresolved.
The following attempts to "clean things up" have already been performed:
Build | Make Project
Build | Rebuild Project
In addition I have verified that the project does build from
sbt package
on the command line
UPDATE After re-running sbt gen-idea the librraries are still not found by the Parser. yet the libraries exist -even IJ knows about them as shown in the following screenshot. Why is it that IJ can find the library
C:\Users\S80035683\.ivy2\cache\org.apache.kafka\kafka\jars\kafka-0.7.2-spark.jar!\kafka\api\FetchRequest.class
However IJ is unable to resolve any classes from that library in the Parser?
You have to build the project for Intellij, try to do this in your project root:
sbt idea with-sources=yes
This should build the project structure from scratch and add the right dependencies, usually I refresh the project after adding a dependency or a jar.
Edit:
To use the command you need this plugin, otherwise you can use gen-idea but I used it only a few times and I'm not sure how it will work out.
Edit2:
There was some confusion, first, for the IDEA SBT console you don't need to prepend the sbt command since you already are inside sbt:
If you have the sbt plugin for idea you can use gen-idea with-source=yes (without prepending sbt)
From the terminal, either you go to your project root and type sbt to enter the sbt console and use gen-idea or idea with-sources=yes (without prepending sbt)
or directly sbt gen-idea or if you have the plugin sbt idea with-sources=yes (prepending sbt)
To reach the sbt console inside idea you need to install the sbt plugin on preferences -> plugin and search for sbt and then View -> Tool Windows -> SBT Console:
To start the console click on the play button, to kill the console on the skull.
I had the same problem. I fixed it by directly writing the CLASSES and SOURCES of the problematic library. This can be found in .idea/libraries/SBT__<problematic library>_jar.xml

Eclipse package error,but all his childPackage has no error

I check out my code from svn, but one package has errors ,but all his sub-packages have no red-error icon.
error img http://postimg.org/image/o2veg9811/
All my project is based on 'aiis-framework' project ,So I want to make the aiis-framework project correct first.
Before I ask this question, I do 'Project->Clean' in eclipse ,and 'mvn clean compile -Dmaven.test.skip' in maven again and again ,but nothing changed.
If someone give me some advice ,it will do me a big favor.
Additional:I see the problems, it says my pom-file is not up-to-date。
But I runs these in my cmd.exe
mvn clean compile -Dmaven.test.skip
mvn eclipse:clean eclipse:eclipse -Dwtpversion=2.0 -Dmaven.test.skip
mvn resources:resources
Then refresh in the eclipse.
what it happens 'pom is not up-to-date'