Skip to content

Conversation

marcosemiao
Copy link
Contributor

@marcosemiao marcosemiao commented Jul 4, 2025

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

ErrorProne Plugin Issue with Maven Build Cache Extension in IntelliJ

As part of a project, the Javac ErrorProne plugin is used. Its configuration is defined in the root pom.xml.

Occasionally, when launching the Spring Boot application, the following error appears:

java: plug-in not found: ErrorProne

This issue occurs when the module does not have the required Maven processors configured, even though the -Xplugin:ErrorProne option is specified.

After investigation, the issue appears to be related to the maven-build-cache-extension. A minimal project was created to reproduce the problem:
👉 https://github.com/marcosemiao/Intellij-project-test

Steps to Reproduce

  1. Clone the project.
  2. Run mvn install in IntelliJ.
  3. Click on "Reload All Maven Projects".
    "Reload All Maven Projects
  4. Navigate to:
    Build > Execution > Deployment > Compiler > Annotation Processors
  5. Observe the behavior.

Observed Behavior

  • When working correctly, modules are associated with the profile:
    "Annotation profile for intellij-project-test"

    "AnnotationProcessorsOK

  • Randomly, one or more modules are associated with the profile:
    "Maven default annotation processors profile", which causes the issue.

    "AnnotationProcessorsKO

If the issue does not occur immediately, try clicking "Reload All Maven Projects" multiple times.

A stacktrace may appear when the issue is triggered :

com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/ErrorInCustomProvider]: IllegalStateException
  at SessionScopeModule.configure(SessionScopeModule.java:55)
      \_ installed by: WireModule -> SessionScopeModule
  at CacheConfigImpl.(CacheConfigImpl.java:126)
      \_ for 2nd parameter
  at ClassRealm[coreExtension>org.apache.maven.extensions:maven-build-cache-extension:1.2.1-SNAPSHOT, parent: ClassRealm[plexus.core, parent: null]]
      \_ installed by: WireModule -> PlexusBindingModule
  while locating CacheConfigImpl
  while locating Object annotated with *
  at LocatorWiring
  at CacheLifecycleParticipant.(CacheLifecycleParticipant.java:39)
      \_ for 1st parameter
  at ClassRealm[coreExtension>org.apache.maven.extensions:maven-build-cache-extension:1.2.1-SNAPSHOT, parent: ClassRealm[plexus.core, parent: null]]
      \_ installed by: WireModule -> PlexusBindingModule
  while locating CacheLifecycleParticipant
  while locating Object annotated with *

Learn more:
  https://github.com/google/guice/wiki/ERROR_IN_CUSTOM_PROVIDER

1 error

======================
Full classname legend:
======================
CacheConfigImpl:           "org.apache.maven.buildcache.xml.CacheConfigImpl"
CacheLifecycleParticipant: "org.apache.maven.buildcache.CacheLifecycleParticipant"
LocatorWiring:             "org.eclipse.sisu.wire.LocatorWiring"
PlexusBindingModule:       "org.eclipse.sisu.plexus.PlexusBindingModule"
SessionScopeModule:        "org.apache.maven.session.scope.internal.SessionScopeModule"
WireModule:                "org.eclipse.sisu.wire.WireModule"
========================
End of classname legend:
========================

	at com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:251)
	at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1104)
	at org.eclipse.sisu.inject.Guice4$2.get(Guice4.java:233)
	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.base/java.util.AbstractCollection.addAll(AbstractCollection.java:337)
	at org.jetbrains.idea.maven.server.Maven3ServerEmbedder.getLifecycleParticipants(Maven3ServerEmbedder.java:325)
	at org.jetbrains.idea.maven.server.Maven3ServerEmbedder.notifyAfterSessionStart(Maven3ServerEmbedder.java:160)
	at org.jetbrains.idea.maven.server.Maven3ServerEmbedder.executeWithSessionScope(Maven3ServerEmbedder.java:182)
	at org.jetbrains.idea.maven.server.Maven3ServerEmbedder.executeWithMavenSession(Maven3ServerEmbedder.java:129)
	at org.jetbrains.idea.maven.server.Maven3XServerEmbedder.resolveArtifactsTransitively(Maven3XServerEmbedder.java:832)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:714)
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:598)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:844)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:721)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:720)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.IllegalStateException
	at org.apache.maven.session.scope.internal.SessionScope.lambda$static$0(SessionScope.java:38)
	at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
	at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:57)
	at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:67)
	at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:109)
	at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:124)
	at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:66)
	at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:62)
	at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:47)
	at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
	at org.apache.maven.session.scope.internal.SessionScope$CachingProvider.get(SessionScope.java:116)
	at org.apache.maven.session.scope.internal.SessionScope.lambda$scope$2(SessionScope.java:92)
	at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)
	at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:40)
	at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:60)
	at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113)
	at com.google.inject.internal.ConstructorInjector.access$000(ConstructorInjector.java:33)
	at com.google.inject.internal.ConstructorInjector$1.call(ConstructorInjector.java:98)
	at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:109)
	at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:124)
	at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:66)
	at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:93)
	at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:300)
	at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
	at org.apache.maven.session.scope.internal.SessionScope$CachingProvider.get(SessionScope.java:116)
	at org.apache.maven.session.scope.internal.SessionScope.lambda$scope$2(SessionScope.java:92)
	at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)
	at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:60)
	at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1101)
	at org.eclipse.sisu.wire.BeanProviders$7.get(BeanProviders.java:167)
	at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
	at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:57)
	at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:67)
	at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:109)
	at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:124)
	at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:66)
	at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:62)
	at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:47)
	at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:40)
	at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:60)
	at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113)
	at com.google.inject.internal.ConstructorInjector.access$000(ConstructorInjector.java:33)
	at com.google.inject.internal.ConstructorInjector$1.call(ConstructorInjector.java:98)
	at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:109)
	at org.eclipse.sisu.bean.BeanScheduler$CycleActivator.onProvision(BeanScheduler.java:230)
	at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:117)
	at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:66)
	at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:93)
	at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:300)
	at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
	at org.apache.maven.session.scope.internal.SessionScope$CachingProvider.get(SessionScope.java:116)
	at org.apache.maven.session.scope.internal.SessionScope.lambda$scope$2(SessionScope.java:92)
	at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:45)
	at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:60)
	at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1101)
	... 25 more

@slachiewicz slachiewicz requested review from gnodet and cstamas August 10, 2025 09:55
@arey
Copy link

arey commented Aug 14, 2025

I'm interested in this fix. Many of the developers in my team are affected by the issue described by @marcosemiao.

@olamy
Copy link
Member

olamy commented Aug 16, 2025

TBH I can merge this but it looks to me more a bug in the intellij plugin rather than a bug.
did you log an issue on the intellij plugin side?

@marcosemiao
Copy link
Contributor Author

@olamy
When I encountered this bug, my first thought was that it came from IntelliJ’s embedded Maven.
So I initially focused on debugging IntelliJ.

While debugging, I came across a stack trace triggered by Maven Cache Extension, assuming that IntelliJ had not initialized the MavenSession at the time of the lifecycle call.

In our case, it involves CacheLifecycleParticipant, which extends AbstractMavenLifecycleParticipant.

Looking at the stack, the issue happens when the constructor of CacheLifecycleParticipant is called. This constructor requires a CacheConfig instance, implemented here by CacheConfigImpl, which itself depends on a MavenSession instance.

At first, I thought IntelliJ had failed to initialize it, which would mean the bug was on IntelliJ’s side.

However, after reviewing the AbstractMavenLifecycleParticipant class and its documentation:

https://maven.apache.org/examples/maven-3-lifecycle-extensions.html

https://maven.apache.org/ref/3.5.0/apidocs/org/apache/maven/AbstractMavenLifecycleParticipant.html

I noticed the following:

afterSessionStart(MavenSession session)
Invoked after MavenSession instance has been created.

But CacheLifecycleParticipant does not respect this rule: instead of using afterSessionStart() before accessing MavenSession, it tries to reference it through CacheConfigImpl during the class construction.

After realizing this, I concluded that the bug was more likely caused by the Maven Build Cache Extension than by IntelliJ.

@olamy olamy added the bug Something isn't working label Aug 17, 2025
@olamy olamy added this to the 1.2.1 milestone Aug 17, 2025
@olamy
Copy link
Member

olamy commented Aug 17, 2025

@marcosemiao good catch. Very good explanation. I'm definitely convinced :)
Thanks for your contribution

@olamy olamy merged commit ad577b0 into apache:master Aug 17, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants