IntelliJ IDEA shows plugin not found - java

I'm trying to tune IntelliJ IDEA.
In the company I now work they use Nexus as a store for Maven plugins.
In maven settings file (.m2/settings.xml) there are Nexus repositories :
.../nexus/content/repositories/releases
.../nexus/content/repositories/releases-temporal/
.../nexus/content/repositories/snapshots
In IDEA I see errors like:
Plugin '''org.apache.maven.plugins:maven-project-info-reports-plugin:2.7''' not found
Inspects a Maven model for resolution problems.
Though Nexus contains it as I can see through it's web interface.
What might be the problem?

IDEA should normally manage your Maven dependencies for you (as long as your pom.xml are correct.)
When your POM-file changes, IDEA will display a notification-window and ask if you would like to download dependencies (this can be easy to miss).
Or, if IDEA is configured with automatic Maven imports (File > Settings > Maven > Importing -> Import Maven projects manually), this should happen automatically.
If your problem persists, you can delete and re-import your IDEA-project:
Close IDEA.
Remove "*.iml" and ".idea"-directories.
Run "mvn clean install" from the command-line.
Re-import your project into IDEA.
This will normally solve these types of tricky problems.
Also worth checking: If you use Maven, your IDEA (and Eclipse) project files should not need to be checked into version control. If you check out someone elses *.iml-files or .idea-folder, problems can occur.

You maybe try this solution:
Close your IntelliJ IDEA. Backup IDE setting files (1). Then, delete all files in directory "config":
<User home>\.IntelliJIdeaXX\config
(on Windows, for example: C:\Users\user_name.IntelliJIdea13\config)
Go to menu File \ Settings or press Ctrl + Alt + Shift, in group Project Settings, choose Maven \ Repositories, press button Add "Artifactory or Nexus Service URLs", choose:
https://repository.jboss.org/nexus/service/local
Then update this repository, you will wait some minutes for indexing repository.
Then try what you want.
1 http://www.jetbrains.com/idea/webhelp/project-and-ide-settings.html

Related

IntelliJ can't find Java class [duplicate]

Platform: IntelliJ Community Edition 10.0.3
SDK: jdk1.6.0_21
OS: Windows 7
So I have a strange situation with IntelliJ that has me completely stumped. I setup a Maven project and add log4j as a dependency in the pom.xml file. The IDEA inspections run fine and my unit tests all compile and run.
I then added hunnysoft's jmime library to my local maven repository using the mvn install:install-file as follows.
mvn install:install-file -Dfile=jmime.jar -DgroupId=jmime \
-DartifactId=jmime -Dversion=3.1.1e -Dpackaging=jar
Maven installed the jar file just fine into my local repository.
I then went into IntelliJ's Settings => Maven => Repository Services and Updated my local repository (so that IntelliJ would reindex the repository contents).
Finally, I added the following dependency to my pom.xml file (just above the log4j dependency).
<dependency>
<groupId>jmime</groupId>
<artifactId>jmime</artifactId>
<version>3.1.1e</version>
</dependency>
I now create a new class as follows:
package com.stackoverflow.question;
import org.apache.log4j.Logger;
import com.hunnysoft.jmime.ByteString;
import com.hunnysoft.jmime.Field;
import com.hunnysoft.jmime.FieldBody;
public class StackOverflowQuestion {
public Field create(String name, String text) {
Logger.getLogger(getClass()).debug("create entered");
FieldBody body = new FieldBody();
body.setText(new ByteString(text));
Field field = new Field();
field.setFieldName(name);
field.setFieldBody(body);
return field;
}
}
Now for the weirdness. IntelliJ's intention mechanism picks up and recognizes the Logger import in the maven pom file just fine. However, for all of the hunnysoft imports it reports: "Cannot resolve symbol 'ByteString/Field/FieldBody'", BUT Build => Compile 'StackOverflowQuestion.java' compiles everything correctly and the unit test I created for this class runs fine (though the intentions mark the call to create() as a problem area too).
So somewhere, somehow IntelliJ is ignoring the jmime.jar file for the intention subsystem. I'm confused because the log4j dependency works fine and everything compiles and runs fine. F12 ("Go To Declaration") works on the Logger import, but breaks on all the jmime imports.
Oh, one other thing, if I go to the 'Packages' view in the "Projects" window the "com.hunnysoft.jmime" package appears and I can see ALL of the classes I imported in the code snippet above under "Libraries". Removing the above dependency from the pom.xml file causes this package to disappear and the compilation breaks.
It appears that the inspection's classpath is broken, but there does not seem to be a setting for this anywhere in the Settings => Intentions | Compiler areas (not that I expected any such settings, I believe the IDEA should already know the correct classpath based on the pom file and JDK).
As a final experiment I created a brand new standard J2SE application project (without using maven) and added the jmime.jar file directly to the project as one of its libraries. I run into exactly the same problems as described above in this new project.
Here is the MANIFEST.MF from the jmime jar file.
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.5.4
Created-By: 10.0-b23 (Sun Microsystems Inc.)
Name: com/hunnysoft/jmime/
Sealed: true
Specification-Title: Hunny JMIME
Specification-Version: 3.1.1
Specification-Vendor: Hunny Software, Inc.
Implementation-Title: com.hunnysoft.jmime
Implementation-Version: 3.1.1E
Implementation-Vendor: Hunny Software, Inc.
I don't see anything unusual in this jar file.
My best guess is that perhaps the problem might be a missing dependency issue. But AFAIK jmime is supposed to be self contained (JarAnalyzer doesn't come up with anything, but I'm not sure it would if a dependency jar is missing).
So, anyone have any IDEAs?
First of all you should try File | Invalidate Caches and if it doesn't help, delete IDEA system directory. Then re-import the Maven project and see if it helps.
In some weird cases compiled classes may report wrong info and confuse IDEA. Verify that the classes from this jar report correct names using javap.
The following trick resolved this issue for me:
Right click on the code editor
Hover on Maven and expand
Click on Reimport
My idea version is 12.0.4
None of the solutions above worked for me. What did was removing the main.iml file manually and it suddenly worked.
This was mentioned in another answer to this same question here, but this alone fixes this for me. I do all my builds in a separate terminal, outside of IntelliJ. So the cache's need to have the proper permissions set for the IntelliJ app to read them.
Run it from the project's root folder.
$ mvn -U idea:idea
For Gradle users:
You may need to synchronize your project with your build.gradle file.
You can right-click on your gradle file under the Project pane to do this, but that didn't seem to do anything for me (I suspect a bug in my version). You'll know if this happens because it wont' kick off any IntelliJ tasks that you will be waiting on. Instead, open up the Gradle Tool pane, then click the synchronize (refresh) button. This worked for me where invalidating the cache and restarting did not.
My own circumstance: I was using a Scala project with Gradle and had to do this.
One extra step, when I did File -> Invalidate Caches and restarted the IDE, open a project. It popped up a toastbox on the top-right asking me whether to enable auto-import and that solved the problem.
Inconsistent/duplicate module names in project structure was causing this issue for me.
Go to File -> Project Strucutre -> Modules
In Click on modules which have red underline
Got to "Dependencies" tab
Make sure the dependencies which are red actually exist in dependency list. If not, rename them to match existing dependency names
This can happen when IntelliJ doesn't shut down properly and thus cannot properly save renamed module names.
Another thing to check: Be sure that dependencies are not duplicated. In my case I found that a module exhibiting this behavior was misconfigured as follows: it had a dependency on another module, and it had a dependency on a jar produced by that other module. This meant for every symbol referenced in duplicate, and was ambiguous.
Has a fixed been published? Appears issue originally affected v11/12 due to a "Compiler overhaul" back in 2013. With discussion on related issues in Jira up to end of 2014.
http://youtrack.jetbrains.com/issue/IDEA-98425
Also on Jira IDEA-98425 was marked fixed but unverified (on v12.0.3). None of the following work-around helped resolve this "Unable to Resolve Symbol" issue with Version 13.1.1 on Windows
a. Delete .IdealIC13 folder (Then, File \ Invalidate Caches / Restart)
b. From Maven Projects window,
b.1 mvn -U idea:idea –〉Executing this maven goal suppose to reload the dependencies. This works prev, but since last FRI, executing this maven goal failed as it tried to recompile the project (Of course it fails as "Unable to resolve Symbols", that's what I am trying to fix by running this command in the first place) mvn -version — shows maven version referenced 3.2.5 and that it's working
b.2 Simply right click project, and Reimport
b.3 File \ Invalidate Caches / Restart
c. Tried both Enable & Disable this setting: File -> Settings -> Maven -> Importing -> "Use maven3 to import project"
d. Settings \ Maven \ Multiproject build fail policy = Fail at end (instead of Default)
Nothing works. What's happenning to IntelliJ support on Maven.
https://youtrack.jetbrains.com/issue/IDEA-99302
From JetBeans release history, https://www.jetbrains.com/company/history.jsp
IntelliJ v14 NOV 2014
IntelliJ v13 DEC 2013
I'd assume v12 fixed (although unverified) would be incorporated in subsequent releases. Any one having similar problems with which IntelliJ version? Please share your experience. IntelliJ maven support seems broken.
Press "shift" two times > "Reimport All Maven projects" always works for me.
None of the other answeres worked for me. My imports were not being resolved because IntelliJ pointed to wrong .m2 file.
IntelliJ Version: IntelliJ Idea 2018.1.5
My location for the .m2 directory was pointed to the wrong path. All I did to fix it was re-point IntelliJ to the right .m2 directory and update it.
First, go to: File->Settings->Build, Execution, Deployment->Build Tools->Maven
I had to change the User settings file: and the Local repository: to the correct location of my .m2 directory.
After this go to: File->Settings->Build, Execution, Deployment->Build Tools->Maven->Repositories
and click the Update button.
I'm jealous of all of you who resolved through File / Invalidate caches. I just spent hours trying everything on this question and a few others from around the web.
The magic menu item didn't do it for me so I invalidated the caches myself by nuking %USERPROFILE%\AppData\Local\JetBrains\IntelliJIdea2020.3\caches
Once I did this and restarted IntelliJ (2020.3), the indexes were rebuilt and my errors went away.
My Project Structure:
src -> main -> scala -> mypackages
What worked:
Right click on the scala folder, and click "Mark Directory as Sources Root".
I had problem with Maven Importer JDK - somehow it switched itself to JDK 11, but Maven Project reload worked only with JDK 8.
Update 2022
IntelliJ 2022.1 has an interactive, step-by-step process File -> Repair IDE. It leads you through 5 steps in sequence to try and resolve this problem for the current project before invalidating the caches for all projects. From the IDEA documentation:
Refresh Project Indexes
Rescan Project Indexes
Reopen Project
Drop Shared Indexes
Reindex Project
Invalidate Caches and Restart
Steps 1- 3 fixed it for my project.
In v2022.3 and the new UI, this setting is now in File -> Cache Recovery -> Repair IDE. You can also select an individual step from there.
If your maven project is a multi-module project, check if some of the modules are ignored by intellij.
Click on View -> Tool Windows -> Maven Projects, and check if some modules are ignored(Ignored modules are in grey, e.g. gs-multi-module in the following image).
Right click on the ignored module and choose Unignore Projects.
Then wait for intellij to finish indexing, after which it will work.
For Gradle projects:
Exit IntelliJ IDEA
Delete the <problematic-project-root>/.idea directory
Delete the <problematic-project-root>/.gradle directory
Delete all .iml files in <problematic-project-root>
windows command prompt: DEL /S /Q *.iml
linux: find . | grep -e .iml$ | xargs rm
Re-import the project into IntelliJ IDEA with Gradle
In IntelliJ IDEA 2020.3, select:
File > Invalidate Caches / Restart... > Invalidate and Restart
When prompted with Download pre-built shared indexes:
don't import the shared indexes: close the dialog or choose More actions > Don't show again
Yes, sounds like you have to create libraries containing the JARs you need and add them as a dependency in your module.
For another alternative.
I got this problem also when I used JDK7_07. I tried all answers here (except deleting IDEA System Directory). But, I still got the problem. So what I did it is:
Install newest JDK (it was JDK7_45), and set the Intellij's JDK to the new one, and it works.
Re-importing the project worked for me.
Right Click on Project -> Maven ->Reimport
when I did File -> Invalidate Caches and restarted the IDE,open a project. It showed a dialogue on the top-right "Maven changes detected" and gave an option to import and enable auto-import. Even after importing the project here, I had the same issue. The above step solved the problem.
Suggested solutions did not work. I had to unignore several projects, by right clicking on the pom => maven => unignore project.
Then after a
mvn clean install -T 6 -DskipTests
in the console, IntelliJ was happy again. No idea how the projects became ignored...
Sometimes, I just open project structure, and click project, then choose a SDK version.
In my case, I am trying to open a spring boot project from IntellijIdea got the same issue like unable to import all spring related files.
Then I did:
File -> Close Project -> Import Project -> Import from external model -> Choose Gradle -> Next -> Select the project from file location -> Finish
Now everything working fine as expected.
I have seen many answers here but I finally found this solution. It may use for someone like me.
I just had this issue and it would just not go away. I eventually wiped out the IntelliJ config directory in ~ and rebuilt my IntelliJ project from scratch. (This only took about 15 minutes in the end, compared to spending an hour trying to work out problems with cached files, etc.)
Note that my guess is that the initial problem was caused by something like javathings.blogspot.com/2009/11/too-many-open-files-in-intellij-idea.html (NB: as of 2018, that link is dead, but archive.org has a copy of the page from around when this answer was first written -ed.) or a disk space/memory issue causing Java to crash. IntelliJ seemed to just get corrupted.
After invalidating my cache and restarting; and confirming my maven settings were okay, I was still seeing "Cannot resolve symbol" for a module that I definitely had set as a dependency. Turns out I had it set to the wrong scope.
You can check by right clicking on your module and selecting Open Module Settings. Click the dependency tab and verify that the scope for your un-resolvable dependency is set to Compile.
Open "Settings"
Search for "Maven"
Click on "Ignored Files" under "Maven"
Uncheck the pom.xml files contains the missing dependencies
Click "OK"
Click File -> Invalidate Caches/Restart...
Click "Invalidate and Restart"
mvn idea:idea worked for me. Found it here. Spent more than an hour, hope it helps someone
In my case, my project was using Lombok and I was missing the Lombok Plugin in IntelliJ. After installing it everything worked fine.
I tried
File -> Invalidate and Restart
which did not worked for me.
Solution that really worked :
Project Structure -> Modules -> select target folder -> Right click generated-sources and select sources -> Apply -> ok

Maven Error : Maven Project Configuration for Module isn't available

I keep getting this error when I try to compile my code. I have the pom.xml file in my directories but I am not sure if there is something wrong in there. I found only one link on the internet regarding this and that was not my case: Maven project configuration required for module
Error:Maven Resources Compiler: Maven project configuration required for module 'updater' isn't available. Compilation of Maven projects is supported only if external build is started from an IDE.
Here is the content of my pom file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nothing.updater</groupId>
<artifactId>Updater</artifactId>
<version>1.0-SNAPSHOT</version>
<!--<dependencies>-->
<!--<dependency>-->
<!--<groupId>com.nothing.toolbox</groupId>-->
<!--<artifactId>Toolbox</artifactId>-->
<!--<version>1.1</version>-->
<!--</dependency>-->
<!--</dependencies>-->
</project>
I am using a multi-module project.
Right-click on pom.xml and then click on "Add as Maven Project".
Right click the module and select the Make Module "project module name" option from the pop up menu. The messages will be shown. But go to Problems and see now. This will clear and correct this problem.
In my case the problem ocurred after uprgrading IJ from 14.x to 15.x and disappeared when I issued Build -> Rebuild Project
In case of IntelliJ , Right click on the POM.xml file of your project and click on the option "Add as Maven Project".
My problem with this error under 2019.3.4 is related to the build delegating to Maven. Idea is letting Maven build my project first and that build is failing because I broke a test. I get around this problem by not allowing IDEA to delegate to Maven. On Mac OS Catalina: Intellij -> Preferences -> Build, Execution, Deployment -> Build Tools -> Runner and uncheck Delegate IDE Build/run actions to Maven
The messages originates from Line 43 in /org/jetbrains/jps/maven/compiler/MavenResourcesBuilder.java, so my guess is that it is no pom.xml issue but rather IntelliJ Idea related.
If you dig further into the code, it looks for a file called maven/configuration.xml and from what I see, it searches in some temporary directory.
Maybe you should try and start your build as clean as possible.
Quick solution (IntelliJ IDEA):
Right-click on the project, the select Maven->Reimport
In my case, I had to use the following trick:
Right click the module name in the project panel
Select "Open Module Settings"
In the pop-up window, click Dependencies
Select java version 1.8.0_151
I have the same error after a Intellij Idea version upgrade (2016.3 to 2017.1):
Error:Maven Resources Compiler: Maven project configuration required
for module 'MODULE_NAKE' isn't available. Compilation of Maven
projects is supported only if external build is started from an IDE.
But my solution was another. Somehow, I think the Intellij lost the maven version used in my project. I was using maven 2.2.1 but Intellij was trying to use maven 3.x.
So, my solution was adjust this configuration in:
File > Settings > Build, Execution, Deployment > Build Tools > Maven
And set the maven version to 2.2.1.
I had this problem after an Intellij Idea version upgrade. The fix was to wait for it to finish indexing. Then I think it downloaded some stuff it needed.
Makes me think that the other answers on this thread about the IJ version upgrade probably just needed to wait as well - by the time they finished trying a few things the problem was fixed by itself.
In my case this was caused by a misconfiguration of IntelliJ. A long time ago I had been experimenting with the Lifecycle options within the Maven Projects view and had left a few phases in a sub module checked as Execute Before Build.
Because I had completely forgotten having checked these, it took me quite some time to understand the connection with the error messages in the Problems view. After unchecking the Execute Before Build switches of the affected phases everything went back to normal and particularly running unit tests became much faster.
In my case, I invalidated the cache and restarted the IDE. It worked, not sure why though.
I chose the bundled maven installation which helped me.
It could also be something to do with using a symlink to reference the maven installation..
it turns out the version of intelliJ I use (2018.3) can't import maven projects using apache-maven-3.6.2
modify .idea/compiler.xml,add config(should change module name to yourself):
In my case I got this error message, because my Maven configuration in IntelliJ was broken. I had entered invalid options into VM options for importer at Preferences:Build,Execution,Deployment->Build Tools->Maven->Importing.
After deleting these options IntelliJ started to behave normal again.
I am using IDEA with WSL2 and Windows10.
My problem occurred when IDEA automatically set the JDK in WSL2 as project JDK.
After Setting my JDK back to Windows JDK, the error disappearred.
In my case I had all configured to execute the hot reload with devtools after each file change namely:
File -> Settings -> Build, Execution, Deployment -> Compiler -> Enable "Build project automatically";
File -> Settings -> Advanced Settings -> Allow auto-make to start even if developed application is currently running.
The maven related error in the Auto-build tab was being displayed and only went away when I deleted .idea folder in the root directory, opened the project again, built the project without maven config (build as Ant project), and configured all again.
After the reset the error disappeared and the maven build was executed without errors.
I was troubled by this problem all afternoon,the solution in stackoverflow is not usefull for me.But I just solved this problem by accident,i don't kown how it worked,but it is effective.If you have the same project structure.
project structure
you can try this
try this button
and you will found all children project is build success. then you can run all project normally.
Go to event log and from there you will see options, what need to fix it

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

Error opening Maven POM file dependency hierarchy in Eclipse - "Project read error"

When I open a POM file and click on the "Dependency Hierarchy" tab at the bottom, it gives me the error, "Project read error". It works with other projects in the same workspace, just not with this one. Any ideas?
EDIT
In response to #Yhn's answer.
Running the compile and package phases outside of Eclipse from the command-line work as expected. It compiles the application and builds the final WAR file.
Eclipse is indeed pointing to the default location of the Maven settings.xml file, so it should be aware of the custom repositories that are defined in it (my company has its own Maven repository).
I can open and edit the POM file from Eclipse, so it must have read/write permissions to the file.
The project is not configured in Eclipse as a Maven project, so I cannot run the package phase from Eclipse (I can only run it from the command-line).
I wonder if it has anything to do with the fact that I was having trouble building the project with Maven 3 because apparently some of the transitive dependencies are configured for Maven 1, which Maven 3 does not support (this is my theory anyway, based on some of the error messages). I can build the project with Maven 2, but I still get messages such as the following:
Downloading: http://dist.codehaus.org/mule/dependencies/maven2/org/codehaus/xfie/bcprov-jdk14/133/bcprov-jdk14-133.pom
[INFO] Unable to find resource 'org.codehaus.xfire:bcprov-jdk14:pom:133' in repsitory mule (http://dist.codehaus.org/mule/dependencies/maven2)
It must be able to find these dependences however, because it downloaded the JARs just fine and can build the application. It seems like the problem is that the dependencies don't have POM files associated with them, which is maybe why they cannot be used with Maven 3. This might also be why I cannot view the Dependency Hierarchy in Eclipse.
EDIT 2
I converted the project to a Maven project by going to "Configure > Convert to Maven Project". When I open the POM file, I see the error:
ArtifactDescriptorException: Failed to read artifact descriptor for woodstox:wst (Click for 140 more)
(woodstox:wst is another transitive dependency of the project). An error appears in the "Markers" view for seemingly every depedency and transitive dependency in my project. However, I can successfully build the project by doing a "Run As > Maven build". (Edit: This might be because this project has no Java source code, but the JARs of the dependencies correctly appear in the final WAR.) The Dependency Hierarchy still gives the same error--"Project read error".
About the "Unable to find resource" messages--but this only appears for a handful of transitive dependencies. The project has many more transitive dependencies, but these messages do not appear for them. It seems like, because the dependencies do not have POM files, that Maven tries to search for them every time the project is built. Is this normal not to have POMs??
How might I go about getting a repo manager? Is this something that would have to be installed on the company's Maven repository or can you install it on your own workstation?
I had this problem with some non-maven jars that I needed to include in my maven project. I put the jars in my local repository using this maven command:
mvn install:install-file -Dfile=/test/gov.nist.xccdf-1.2.jar -DgroupId=gov.nist -DartifactId=xccdf -Dpackaging=jar -Dversion=1.2
Then I referred to them as dependencies in my pom.xml:
<dependency>
<groupId>gov.nist</groupId>
<artifactId>xccdf</artifactId>
<version>1.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
This worked fine for a while, but I must have upgraded something in eclipse, and I started getting the error you describe.
The fix is to take them out of the local repository, and redo the install-file asking maven to generate a pom for you:
mvn -DgeneratePom=true install:install-file -Dfile=/test/gov.nist.xccdf-1.2.jar -DgroupId=gov.nist -DartifactId=xccdf -Dpackaging=jar -Dversion=1.2
The command will cause a pom to be generated in the same directory (within your local repo) where the jar is placed.
In recent versions of eclipse maven support, the maven build is still done with maven 2 (if you right-click your pom.xml, choose run as mvn package for example). The dependency analysis is now done with an embedded maven 3 plugin, which doesn't like a dependency that has no pom.xml.
I had the same problem. If you made your project a maven project, you should run:
Right Mouse Click on project | Maven | Update Dependencies or
Right Mouse Click on project | Maven | Update Project Configuration
That worked for me.
Given the information through the comments:
mvn compile/mvn package work through console (I'm assuming outside of eclipse). Based on that, the POM file should be correct and dependencies can be resolved.
However; it could be that eclipse's settings aren't correct. For example, if eclipse has some own maven properties (instead of the default ~/.m2/settings.xml file); I can imagine it to fail resolving dependencies configured in the settings.xml used by maven itself. The settings for this should be in the Eclipse Preferences # Maven > User Settings.
Also make sure that Eclipse can actually read the file (not locked, correct rights, etc).
Should this seem to be correct; can you try to run the mvn goal compile from eclipse? You can do this by right-clicking the project and selecting run as > maven package. That way it should run maven with the same settings as eclipse is using, and might show any additional errors in it's configuration.
--
In response to additional information:
Basically it tells you - when using Maven 2 - that it can't find a dependency resource (in this case bcprov-jdk14) in the given repository (codehaus/mule). When I search that maven module (bcprov-jdk14) I find it in the Maven central repo (through our local nexus) # repo1.maven.org/maven2. Maybe that causes the error you're getting with Maven2?
And as the Maven 3 doc says; for Maven 1.x repo's; you should proxy them through a repo manager that can serve it to you as a maven 2 repository (I believe we do that here too for some repo's through Sonatype Nexus OSS)
ps.: Enabling maven dependency management in eclipse should be enough to be able to use maven run targets; if you would want to test it.
--
Sound like it can be multiple problems... given that the normal maven build works fine, one would think that maven can at least get the artifacts it depends upon and their dependencies... Yet, eclipse doesn't seem to be able to.
Double check if your Eclipse internet connection settings are correct? Since you were talking about a company repo, I'm assuming there will probably also be a proxy (I had to set up my Eclipse to use that one too; though for plugins (see next point)).
Another possibility, from experience, can be a rule-based proxy block on *.pom url requests (our proxy here blocks that to force usage of the local repo manager, how evil and annoying that is :(). You might want to try and open the .pom file it tries to download manually in your browser to see if this is the case (I can't, for example...).
To get the repo set up, you would probably have to ask the one responsible for the repository to add it as a maven2 proxy.
At the very least, it seems Eclipse is having issues getting the dependency poms (which are needed to build the dependency tree) from the internet. You could always try to ask some ICT crew (if they are capable enough...) about it at your company, maybe they have some useful hints.
right click on the project, Maven->Update Project->Tick "Force Update of Snapshots/Releases"
I had the same problem when I added a new dependency to pom.xml without network connection. After this, I had so many problems such as "Missing artifacts", "Missing Descriptor", or "Project Read error". I solved this
delete the bad dependency just added from local repository.
rebuild local index.
re-add the dependency
<properties>
<!-- ********************** -->
<!-- Plugin's properties -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.7</java.version>
</properties>
this pom setting worked for me
Usually this happens if there is a typo in the pom that Maven cannot understand and then it throws Project read error. Like in my case I copied a maven dependency snippet and I by passed the version. Instead of typing the actual version # it was getting it dynamically ${asciidoctorj.version} and my pom didn't have this in the properties section. So I got this error. Once I removed that and put a version number it started working.
I had this after copying a local repository folder from another machine. The fix was to go into the repository folder I copied and delete
_remote.repositories along with the 'LastUpdated' files then refresh the Maven dependencies in Eclipse (Alt+F5)
I faced same situation today. In my case it's caused by dependency name in wrong case. E.g.
Project A -> Project B -> Project C
In project B's pm file, I mistakenly specified the dependency artifacts name with "c" in stead of "C".
As in mac os, the files system is case insensitive. so I can build it in command line without detecting this mistake.
In Eclipse it breaks, but it provides very bad error message. In the error list, it says "dependency problem", but the name of dependency is empty. It also can't identify which line in the POM causes the problem.
When try to open "Effective POM" in POM viewer, it will show project read error. In the pop up error dialog box, it will show:
Could not read maven project
java.nio.channels.OverlappingFileLockException
All the messages are useless and misleading.
I finally detected this problem by submit to Jenkins CI after wasted hours of time.
I did maven clean install and the errors were gone
I faced the same issue of "Project read error" while clicking on "Dependency Hierarchy" tab. In my project I had a parent pom and child pom.
Parent pom had a property <appVersion>4.5<appVersion> that was being used in child pom
<version>${appVersion}<version>.
I selected the main project, right click and choose run as maven clean. The console display showed warning that version is using expression but should be a constant. Replacing ${appVersion} with constant value of 4.5 fixed the issue.

How to force m2eclipse to look for new dependencies after network outage?

we are using m2eclipse 0.12.1 together with nexus oss 1.9.0.1 repository. Today, during a downtime of the nexus server, some user did use "update dependencies" in m2eclipse, which did result in a broken project configuration (artifact not found ... for nearly all dependencies)
The problem is, after the nexus server comes back online, update dependences still did not work, it seems not trying to reach the server. The only brute force sollution which did work was to delete the local repository. Then all dependencies got successfully downloaded.
So, it seems the local metadata went corrupt, or tell m2eclipse not to look on the server again.
How to force m2eclipse to download the dependencies? Or how to tell m2eclipse to enable the nexus server again ?
You have to remove all "*.lastUpdated"-files from your local Maven repository.
On Linux you can use this line to do that:
find ~/.m2/repository -name "*lastUpdated" -print0 | xargs -0 -r rm
And then use Maven -> Update Dependencies in Eclipse.
Do a "project clean" for all projects or, if this doesn't eliminate the build path errors, restart eclipse with the clean option.
If all doesn't help: create a new workspace and (physically) import all projects through the eclipse IDE. This will create new project metadata and leave the old workspace unaffected.

Categories