Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchMethodError: org.apache.maven.rtinfo.internal.DefaultRuntimeInformation: method 'void <init>()' not found #1583

Open
hohwille opened this issue Dec 9, 2024 · 1 comment

Comments

@hohwille
Copy link

hohwille commented Dec 9, 2024

Component(s)

maven-extension

What happened?

Description

It seems that opentelemetry-maven-extension is not working with maven 4.
Already having opentelemetry-maven-extension added to ./mvn/extensions.xml but not activating the extension by configuring an OTEL URL is breaking any build.

Steps to Reproduce

  1. Add opentelemetry-maven-extension to ./mvn/extensions.xml (tested with latest 1.41.0-alpha)
  2. run mvn clean or mvn verify

Expected Result

Successful build.

Actual Result

org.apache.maven.InternalErrorException: Internal error: com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/ErrorInjectingConstructor]: NoSuchMethodError: DefaultRuntimeInformation: method 'void <init>()' not found
...
Caused by: java.lang.NoSuchMethodError: org.apache.maven.rtinfo.internal.DefaultRuntimeInformation: method 'void <init>()' not found
    at io.opentelemetry.maven.resources.MavenResourceProvider.createResource(MavenResourceProvider.java:22)
    at io.opentelemetry.sdk.autoconfigure.ResourceConfiguration.configureResource(ResourceConfiguration.java:112)
...

Component version

1.41.0-alpha

Log output

[ERROR] Internal error: com.google.inject.ProvisionException: Unable to provision, see the following errors:
[ERROR]
[ERROR] 1) [Guice/ErrorInjectingConstructor]: NoSuchMethodError: DefaultRuntimeInformation: method 'void <init>()' not found
[ERROR]   at OpenTelemetrySdkService.<init>(OpenTelemetrySdkService.java:45)
[ERROR]   at ClassRealm[coreExtension>io.opentelemetry.contrib:opentelemetry-maven-extension:1.41.0-alpha, parent: ClassRealm[plexus.core, parent: null]]
[ERROR]       \_ installed by: WireModule -> PlexusBindingModule
[ERROR]   at OtelLifecycleParticipant.<init>(OtelLifecycleParticipant.java:32)
[ERROR]       \_ for 1st parameter
[ERROR]   at ClassRealm[coreExtension>io.opentelemetry.contrib:opentelemetry-maven-extension:1.41.0-alpha, parent: ClassRealm[plexus.core, parent: null]]
[ERROR]       \_ installed by: WireModule -> PlexusBindingModule
[ERROR]   while locating OtelLifecycleParticipant
[ERROR]   while locating Object annotated with *
[ERROR]
[ERROR] Learn more:
[ERROR]   https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR
[ERROR]
[ERROR] 1 error
[ERROR]
[ERROR] ======================
[ERROR] Full classname legend:
[ERROR] ======================
[ERROR] DefaultRuntimeInformation: "org.apache.maven.rtinfo.internal.DefaultRuntimeInformation"
[ERROR] OpenTelemetrySdkService:   "io.opentelemetry.maven.OpenTelemetrySdkService"
[ERROR] OtelLifecycleParticipant:  "io.opentelemetry.maven.OtelLifecycleParticipant"
[ERROR] PlexusBindingModule:       "org.eclipse.sisu.plexus.PlexusBindingModule"
[ERROR] WireModule:                "org.eclipse.sisu.wire.WireModule"
[ERROR] ========================
[ERROR] End of classname legend:
[ERROR] ========================: org.apache.maven.rtinfo.internal.DefaultRuntimeInformation: method 'void <init>()' not found
[ERROR] -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/ErrorInjectingConstructor]: NoSuchMethodError: DefaultRuntimeInformation: method 'void <init>()' not found
  at OpenTelemetrySdkService.<init>(OpenTelemetrySdkService.java:45)
  at ClassRealm[coreExtension>io.opentelemetry.contrib:opentelemetry-maven-extension:1.41.0-alpha, parent: ClassRealm[plexus.core, parent: null]]
      \_ installed by: WireModule -> PlexusBindingModule
  at OtelLifecycleParticipant.<init>(OtelLifecycleParticipant.java:32)
      \_ for 1st parameter
  at ClassRealm[coreExtension>io.opentelemetry.contrib:opentelemetry-maven-extension:1.41.0-alpha, parent: ClassRealm[plexus.core, parent: null]]
      \_ installed by: WireModule -> PlexusBindingModule
  while locating OtelLifecycleParticipant
  while locating Object annotated with *

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

1 error

======================
Full classname legend:
======================
DefaultRuntimeInformation: "org.apache.maven.rtinfo.internal.DefaultRuntimeInformation"
OpenTelemetrySdkService:   "io.opentelemetry.maven.OpenTelemetrySdkService"
OtelLifecycleParticipant:  "io.opentelemetry.maven.OtelLifecycleParticipant"
PlexusBindingModule:       "org.eclipse.sisu.plexus.PlexusBindingModule"
WireModule:                "org.eclipse.sisu.wire.WireModule"
========================
End of classname legend:
========================

    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:157)
    at org.apache.maven.cling.invoker.mvn.MavenInvoker.doExecute(MavenInvoker.java:497)
    at org.apache.maven.cling.invoker.mvn.MavenInvoker.execute(MavenInvoker.java:99)
    at org.apache.maven.cling.invoker.mvn.MavenInvoker.execute(MavenInvoker.java:89)
    at org.apache.maven.cling.invoker.LookupInvoker.doInvoke(LookupInvoker.java:141)
    at org.apache.maven.cling.invoker.LookupInvoker.invoke(LookupInvoker.java:113)
    at org.apache.maven.cling.ClingSupport.run(ClingSupport.java:64)
    at org.apache.maven.cling.MavenCling.main(MavenCling.java:51)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:569)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:314)
Caused by: com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/ErrorInjectingConstructor]: NoSuchMethodError: DefaultRuntimeInformation: method 'void <init>()' not found
  at OpenTelemetrySdkService.<init>(OpenTelemetrySdkService.java:45)
  at ClassRealm[coreExtension>io.opentelemetry.contrib:opentelemetry-maven-extension:1.41.0-alpha, parent: ClassRealm[plexus.core, parent: null]]
      \_ installed by: WireModule -> PlexusBindingModule
  at OtelLifecycleParticipant.<init>(OtelLifecycleParticipant.java:32)
      \_ for 1st parameter
  at ClassRealm[coreExtension>io.opentelemetry.contrib:opentelemetry-maven-extension:1.41.0-alpha, parent: ClassRealm[plexus.core, parent: null]]
      \_ installed by: WireModule -> PlexusBindingModule
  while locating OtelLifecycleParticipant
  while locating Object annotated with *

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

1 error

======================
Full classname legend:
======================
DefaultRuntimeInformation: "org.apache.maven.rtinfo.internal.DefaultRuntimeInformation"
OpenTelemetrySdkService:   "io.opentelemetry.maven.OpenTelemetrySdkService"
OtelLifecycleParticipant:  "io.opentelemetry.maven.OtelLifecycleParticipant"
PlexusBindingModule:       "org.eclipse.sisu.plexus.PlexusBindingModule"
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:1151)
    at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
    at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:53)
    at org.eclipse.sisu.wire.EntryListAdapter$ValueIterator.next(EntryListAdapter.java:113)
    at java.util.AbstractCollection.addAll(AbstractCollection.java:335)
    at org.apache.maven.DefaultMaven.getExtensionComponents(DefaultMaven.java:436)
    at org.apache.maven.DefaultMaven.callListeners(DefaultMaven.java:375)
    at org.apache.maven.DefaultMaven.afterSessionStart(DefaultMaven.java:355)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:237)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:225)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:149)
    at org.apache.maven.cling.invoker.mvn.MavenInvoker.doExecute(MavenInvoker.java:497)
    at org.apache.maven.cling.invoker.mvn.MavenInvoker.execute(MavenInvoker.java:99)
    at org.apache.maven.cling.invoker.mvn.MavenInvoker.execute(MavenInvoker.java:89)
    at org.apache.maven.cling.invoker.LookupInvoker.doInvoke(LookupInvoker.java:141)
    at org.apache.maven.cling.invoker.LookupInvoker.invoke(LookupInvoker.java:113)
    at org.apache.maven.cling.ClingSupport.run(ClingSupport.java:64)
    at org.apache.maven.cling.MavenCling.main(MavenCling.java:51)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:569)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:314)
Caused by: java.lang.NoSuchMethodError: org.apache.maven.rtinfo.internal.DefaultRuntimeInformation: method 'void <init>()' not found
    at io.opentelemetry.maven.resources.MavenResourceProvider.createResource(MavenResourceProvider.java:22)
    at io.opentelemetry.sdk.autoconfigure.ResourceConfiguration.configureResource(ResourceConfiguration.java:112)
    at io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder.build(AutoConfiguredOpenTelemetrySdkBuilder.java:441)
    at io.opentelemetry.maven.OpenTelemetrySdkService.<init>(OpenTelemetrySdkService.java:66)
    at io.opentelemetry.maven.OpenTelemetrySdkService$$FastClassByGuice$$12a2e36d.GUICE$TRAMPOLINE(<generated>)
    at io.opentelemetry.maven.OpenTelemetrySdkService$$FastClassByGuice$$12a2e36d.apply(<generated>)
    at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:82)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
    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)

Additional context

IMHO extensions are not shaded in maven and do not have classworlds ClassLoader isolation.
So it looks like you are using an internal maven API that changed in an incompatible way in Maven4.
I am quite sure that there is a way to change the API call in a way that will work with maven 3.9 and maven 4 to make your extension work with both versions not breaking existing users on maven 3.9 when fixing this bug.

@cyrille-leclerc
Copy link
Member

Can you please update the tissue to indicate it's happening with Maven 4.

The problem is caused by:

// TODO verify if there is solution to retrieve the RuntimeInformation instance loaded by the
// Maven Plexus Launcher
RuntimeInformation runtimeInformation = new DefaultRuntimeInformation();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants