IntelliJ does not recognize workspace maven modules

Answered

When using maven, first everything worked fine, but during the last weeks I found that IntelliJ seems to have forgotten how to resolve my workspace artifacts and instead tries to rely on the artifacts in the maven repository.

I've got a huge multi-module maven project (so rebuilding it all the time is not really an option). When I CTRL+Click on the class name in another module (same workspace), it does not lead me to that class in that module, but instead only to a decompiled version of the maven artifact in the repository, which is hugely annoying. Also, it prevents IntelliJ from finding references to something in other modules, making the search for usage function basically useless...

Example:

Parent
   - X (containing class CX)
   - Y (contains a class using CX)

When I now CTRL+Click on the reference to CX in Y, it opens the decompiled view of the jar, but of course, it should recognize that this class is IN the workspace already and it should use that version instead.

Unfortunately, while there seems to be something about "Resolve Workspace Artifact", I have not yet found such a setting. I assume that this is only a simple problem where I just haven't found the right setting...

0
34 comments

Looks like you mean the issue is that IDE resolves module's dependencies to a Maven jar library instead of an IDE module sources?

Are the modules connected via the same main pom.xml?

In a multi-module Maven project IDE will resolve dependency to a module sources, rather than to a local maven jar library, if maven coordinates (groupIdartifactIdversionId) are the same. Also for the 'SNAPSHOT' version, dependency of the 'LATEST' version will be resolved. For versions without 'SNAPSHOT' dependencies with versions declared as 'LATEST' and 'RELEASE' will be resolved. Of course these modules should be present in current IDE project and added as a Maven modules.

If issue remains, please describe more your project structure: how do you declare dependencies between maven modules which are not correctly resolved? Please provide relevant pom.xml configuration (modules declarations and dependencies section). Please also provide idea.log to check.

Make also sure to try with version from https://www.jetbrains.com/idea/download. It may also help re-import Maven project or use different Maven version in IDE Maven settings.

0
Avatar
Permanently deleted user

Yes, that is exactly the issue: IDE resolves the dependency to an artifact in the maven repository instead of a module in the IDE workspace (with the artifact being created from the module in the workspace in the first place). And yes, our dependencies are all SNAPSHOT dependencies there. As far as I know, my IntelliJ Ultimate is quite current (downloaded it two weeks ago).

The "interesting" fact is, that it worked correctly for a while and stopped working then. I now have deleted the whole project, checking it out from GIT again, importing it again and it seems to work... for now. Would be interesting what is causing this and how to prevent it form happening. If it happens again, I will post an update here with the log file, thanks.

0
Avatar
Permanently deleted user

Ok, just one day later, same thing happens, suddenly it associates only the jars in the maven repository but not the workspace modules which makes it impossible to use "Find Usages".

0

After what action does issue occur?

Do you version project configuration files?

Can you provide sample *.iml file for the module when it does not have the issue and when you see the issue?

Also when issue occurs - do you see these modules (which are resolved to jar libraries) in Maven projects tool window in IDE?

0
Avatar
Permanently deleted user

Unfortunately, I cannot pinpoint an exact action. Perhaps(!) it was after running mvn clean install in a terminal outside of InteliJ, but I cannot be absolutely sure about that.

I will try to save the .iml next time I freshly import the projects from git and then again after it fails, k.

But yes, when the issue occours, nothing changes in the Project view. Still I see my parent project (called build-aggregator) and all the modules (some active, some inactive, due to the profile). Everything seems normal there, only the modules that have dependencies to other modules aren't "linked" to the workspace modules, but only their built .jars in the Maven repository.

0

Please better attach versions of all project configuration files for both times: before and after the issue. Having idea.log after IDE restart would be also useful.

0
Avatar
Permanently deleted user

I believe I have this issue as well. One of my modules doesn't compile and I see that it is resolving two other module dependencies from maven instead of as a local module. I have to manually change the dependency in module settings, but it breaks again whenever I do another `mvn clean install` from the command line later.

Possibly related is that it seems to be importing an outdated snapshot version, but other modules in the same project are fine.

0
Avatar
Permanently deleted user

When I updated the pom.xml of the module (removed the dependencies for testing) and tried to reimport, it didn't actually update either and still adds dependencies for old versions

0

Hello,

Looks like we have similar issue on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-172898. Does it help to remove ".idea" folder and reimport project from Maven?

0
Avatar
Permanently deleted user

Hi Yaroslav,

I did some experimenting and it seems the cause is a plugin usage:

<plugin>
<groupId>io.takari.builder</groupId>
<artifactId>takari-builder</artifactId>
<version>0.20.5</version>
<extensions>true</extensions>
</plugin>

It doesn't make sense to me how this would be related, but when this is present none of the dependencies are found for the module, and when I remove it they are found. It almost seems like there is a hidden error that prevents it from processing parts of the pom.xml file.

 

0

Yes, there is some problem with plugin. It also fails from command line.

0
Avatar
Permanently deleted user

Hmm, my maven build from the command line runs just fine. I was thinking IntelliJ was silently erroring out when it could just log the issue and continue on. But I'll see if I need to set the same version of maven in IntelliJ as I have on the command line.

0

What OS do you use? In my machine running clean from coomand line gives this error from plugin:

```

Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/Users/yaroslav.bedrov/Desktop/libs/apache-maven-3.5.2-bin/apache-maven-3.5.2/bin/../conf/logging/

```

0
Avatar
Permanently deleted user

I'm running MacOS High Sierra, my version of maven is 3.5.4. It runs fine on the command line for me. I tried changing IntelliJ to use the same maven installation but it still has the issue. 

0

Seems only Windows command line is affected. Could you please share your idea.log ("Help | Show Log in..") after restarting IDE and running refresh from Maven tool window?

0
Avatar
Permanently deleted user

I can't upload the full log for security reasons, but I see this error happening every time in the logs after refreshing Maven:

 

2018-09-28 12:22:35,024 [ 573572] INFO - #org.jetbrains.idea.maven - com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error in custom provider, com.google.inject.OutOfScopeException: Cannot access Key[type=io.takari.builder.enforcer.modularity.maven.internal.MavenLifecycleParticipant, annotation=[none]] outside of a scoping block
at ClassRealm[extension>io.takari.builder:takari-builder:0.20.5, parent: sun.misc.Launcher$AppClassLoader@29453f44] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating io.takari.builder.enforcer.modularity.maven.internal.MavenLifecycleParticipant
while locating java.lang.Object annotated with *

1 error
java.lang.RuntimeException: com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error in custom provider, com.google.inject.OutOfScopeException: Cannot access Key[type=io.takari.builder.enforcer.modularity.maven.internal.MavenLifecycleParticipant, annotation=[none]] outside of a scoping block
at ClassRealm[extension>io.takari.builder:takari-builder:0.20.5, parent: sun.misc.Launcher$AppClassLoader@29453f44] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating io.takari.builder.enforcer.modularity.maven.internal.MavenLifecycleParticipant
while locating java.lang.Object annotated with *

1 error
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1025)
at org.eclipse.sisu.inject.Guice4$1.get(Guice4.java:162)
at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81)
at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
at org.eclipse.sisu.wire.EntryListAdapter$ValueIterator.next(EntryListAdapter.java:111)
at java.util.AbstractCollection.addAll(AbstractCollection.java:343)
at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.getLifecycleParticipants(Maven3ServerEmbedderImpl.java:855)
at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.loadExtensions(Maven3ServerEmbedderImpl.java:802)
at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.access$400(Maven3ServerEmbedderImpl.java:121)
at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl$3.run(Maven3ServerEmbedderImpl.java:693)
at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.executeWithMavenSession(Maven3ServerEmbedderImpl.java:641)
at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.doResolveProject(Maven3ServerEmbedderImpl.java:660)
at org.jetbrains.idea.maven.server.Maven3ServerEmbedderImpl.resolveProject(Maven3ServerEmbedderImpl.java:594)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: com.google.inject.OutOfScopeException: Cannot access Key[type=io.takari.builder.enforcer.modularity.maven.internal.MavenLifecycleParticipant, annotation=[none]] outside of a scoping block
at org.apache.maven.session.scope.internal.SessionScope$2.get(SessionScope.java:140)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
... 29 more

0

Could you please clarify IDEA build version?

0
Avatar
Permanently deleted user

Sorry for the delay, I was out of town:

IntelliJ IDEA 2018.2.4 (Ultimate Edition)
Build #IU-182.4505.22, built on September 18, 2018


JRE: 1.8.0_152-release-1248-b8 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6

0

I reported an issue on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-200272

Please follow it for updates.

0
Avatar
Permanently deleted user

thanks!

0
Avatar
Permanently deleted user

Did run into an issue that behaved like this - opened compiled code instead of source (found this when searching for a solution).

The subproject that did not work was not marked by intellij as a subproject

pom.xml were OK

Decided to manually reimport the subproject - got the answer that sorry can't do that as it is ignored, see

File | Settings | Maven | ignored

and it was! The only idea on why it had became ignored was that I was working with git, and had backed to a version where this subproject did not exist (answered that files should be deleted) then added the files using cherry pick.

6

Ext Roger A Larsson, that worked for me!

For some reason, Intellij had added the subproject's pom.xml file to the Maven Ignored Files list, bizarre.

Thanks

1

I faced with the same issue today... again =( Usually I remove .idea and %userdir%/.IntellijIdeaX folder to solve such things, but this time I was too lazy to restore all cfgs and found one more solution:

- go to %projectDir%\.idea folder

- delete compiler.xml file

- check misc.xml file, if <option name=ignoredFiles"> and its <set> somehow contains the module that Idea is unable to resolve - just remove it from there

- re-import maven project

I've wasted so many time for this issue for a lot of times, hope it will help you =)

0

There is a related enhancement request about indication that the pom.xml is ignored in IDE: https://youtrack.jetbrains.com/issue/IDEA-164626

Btw Kostkol87 do you know hw the project was added to ignore list initially? Do you synchronize project configuration files somehow (file sharing, VCS etc)?

1

Andrey Dernov, indication really will be nice =)) What about ignore list - have no idea how it happens, we have .idea folder ignored in our VCS, moreover there were 4-5th time I've faced with such issue on different projects with different VCSs and even in different companies I worked, and .idea - always was exclude from any sharing, btw idea version were different from 2017.* to 2019.*. I'm not pretty sure that all the time modules were ignored, but it always could be solved by deleting .idea directory and reimport, so I suppose it could be the same issue.

PS: the way how it could be ignored provided by Ext Roger A Larsson sounds reasonable, it is quite regular situation when I switch branches between different versions, and idea often ask if I want to delete missing maven modules, so mb it is really leads to ignore and not restore them after switching back?

0

I'm facing the same issue but it isn't due to maven ignore files list. Deleting .idea did not help either.

Strange is that the same IDEA version and project on Win10 is working fine but it does not on macOS Catalina

I'm using the latest IDEA community version 2019.3.4

Unfortunately due our company restrictions I cannot share my project here.

I checked idea.log and there aren't any issues.

Any hints on how to troubleshoot this are welcome.

0

Please report at https://youtrack.jetbrains.com/newIssue?project=IDEA and provide the steps to reproduce the issue, attach the logs anyway (Help | Compress Logs and Show in ...).

0

I have some issue

2020-05-30 00:03:30,126 [ 305017] ERROR - #org.jetbrains.idea.maven - java.lang.RuntimeException: org.codehaus.plexus.component.repository.exception.ComponentLookupException: com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) Error injecting: private org.jetbrains.idea.maven.server.embedder.CustomMaven3ModelInterpolator2 org.jetbrains.idea.maven.server.embedder.CustomModelValidator.myModelInterpolator
while locating org.jetbrains.idea.maven.server.embedder.CustomModelValidator
at ClassRealm[maven.ext, parent: ClassRealm[plexus.core, parent: null]] (via modules: org.eclipse.sisu.wire.WireModule -> org.eclipse.sisu.plexus.PlexusBindingModule)
while locating org.apache.maven.model.validation.ModelValidator annotated with @com.google.inject.name.Named(value=ide)

1 error
role: org.apache.maven.model.validation.ModelValidator
roleHint: ide
java.lang.RuntimeException: java.lang.RuntimeException: org.codehaus.plexus.component.repository.exception.ComponentLookupException: com.google.inject.ProvisionException: Unable to provision, see the following errors:

2020-05-30 00:03:30,127 [ 305018] ERROR - #org.jetbrains.idea.maven - IntelliJ IDEA 2020.1.1 Build #IU-201.7223.91
2020-05-30 00:03:30,127 [ 305018] ERROR - #org.jetbrains.idea.maven - JDK: 11.0.6; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o
2020-05-30 00:03:30,127 [ 305018] ERROR - #org.jetbrains.idea.maven - OS: Mac OS X
2020-05-30 00:03:30,129 [ 305020] ERROR - #org.jetbrains.idea.maven - Last Action: Maven.Reimport

 

My resolution was to downgrade maven used by IntelliJ to  3.5.4.

Source https://stackoverflow.com/questions/37587402/how-to-install-specific-version-of-maven-in-mac-using-brew-command

0

Could be caused by takari maven extension use din project, see https://youtrack.jetbrains.com/issue/IDEA-200272

0

Please sign in to leave a comment.