# Trying external-plugin-test on "real setup" fails with "Cannot resolve type description for co.elastic.apm.agent.bci.classloading.LookupExposer"

**URL:** <https://discuss.elastic.co/t/trying-external-plugin-test-on-real-setup-fails-with-cannot-resolve-type-description-for-co-elastic-apm-agent-bci-classloading-lookupexposer/260923>\
**Category:** APM\
**Tags:** java\
**Created:** [January 13, 2021, 12:04am UTC](https://discuss.elastic.co/t/trying-external-plugin-test-on-real-setup-fails-with-cannot-resolve-type-description-for-co-elastic-apm-agent-bci-classloading-lookupexposer/260923 "2021-01-13T00:04:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mputz86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mputz86/32/82131_2.png) [@mputz86](https://discuss.elastic.co/u/mputz86)\
**Post date:** [January 13, 2021, 12:04am UTC](https://discuss.elastic.co/t/trying-external-plugin-test-on-real-setup-fails-with-cannot-resolve-type-description-for-co-elastic-apm-agent-bci-classloading-lookupexposer/260923/1 "2021-01-13T00:04:39Z")

</div>

Hey there,

when I try out the external-plugin-test from integration-tests, it fails with "Cannot resolve type description for co.elastic.apm.agent.bci.classloading.LookupExposer".  
So probably something is missing / not loaded correctly - maybe I am doing something wrong. Hopefully, someone can point me in the right direction?

Setup:

- The main does just the attach and then calls `traceMe()`.
- `TestClass` with a `traceMe()` method is the method which I try to instrument (i.e. I set the System properties).
- I did a small change to the original plugin: I print out "Called trace me" in the `traceMe()`. And this is printed, just after and just before the "Cannot resolve type description for co.elastic.apm.agent.bci.classloading.LookupExposer".

Versions:  
APM-Agent Version: 1.19.0 (also tried briefly with 1.20.0, but failed there as well).  
Attachment: Via `co.elastic.apm.attach.ElasticApmAttacher.attach();` . Tried the javaagent as well, no difference.

Expected:

- To be working like in the test? 🙂

Log (short):

```auto
Instrumented class: externalplugin.TestClass
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
2021-01-13 00:57:01,795 [Attach Listener] INFO co.elastic.apm.agent.util.JmxUtils - Found JVM-specific OperatingSystemMXBean interface: com.sun.management.OperatingSystemMXBean
2021-01-13 00:57:01,820 [Attach Listener] INFO co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.19.0 as externalplugin-test on Java 14.0.1 Runtime version: 14.0.1+7 VM version: 14.0.1+7 (AdoptOpenJDK) Mac OS X 10.15.7
2021-01-13 00:57:01,821 [Attach Listener] INFO co.elastic.apm.agent.configuration.StartupInfo - VM Arguments: [-Delastic.apm.plugin.instrumented_class=externalplugin.TestClass, -Delastic.apm.plugin.instrumented_method=traceMe, -Dfile.encoding=UTF-8, -Duser.country=DE, -Duser.language=en, -Duser.variant]
2021-01-13 00:57:01,826 [Attach Listener] INFO co.elastic.apm.agent.bci.ElasticApmAgent - Loading plugin external-plugin-test-1.19.0.jar
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
2021-01-13 00:57:03,138 [Attach Listener] INFO co.elastic.apm.agent.impl.ElasticApmTracer - Tracer switched to RUNNING state
2021-01-13 00:57:03,163 [main] ERROR co.elastic.apm.agent.bci.IndyBootstrap - Cannot resolve type description for co.elastic.apm.agent.bci.classloading.LookupExposer
java.lang.IllegalStateException: Cannot resolve type description for co.elastic.apm.agent.bci.classloading.LookupExposer
	at co.elastic.apm.agent.shaded.bytebuddy.pool.TypePool$Resolution$Illegal.resolve(TypePool.java:157) ~[?:?]
	at co.elastic.apm.agent.shaded.bytebuddy.pool.TypePool$Default$WithLazyResolution$LazyTypeDescription.delegate(TypePool.java:912) ~[?:?]
	at co.elastic.apm.agent.shaded.bytebuddy.description.type.TypeDescription$AbstractBase$OfSimpleType$WithDelegation.getDeclaredAnnotations(TypeDescription.java:8348) ~[?:?]
	at co.elastic.apm.agent.shaded.bytebuddy.matcher.DeclaringAnnotationMatcher.matches(DeclaringAnnotationMatcher.java:48) ~[?:?]
	at co.elastic.apm.agent.shaded.bytebuddy.matcher.DeclaringAnnotationMatcher.matches(DeclaringAnnotationMatcher.java:27) ~[?:?]
	at co.elastic.apm.agent.shaded.bytebuddy.matcher.ElementMatcher$Junction$Disjunction.matches(ElementMatcher.java:160) ~[?:?]
	at co.elastic.apm.agent.bci.IndyPluginClassLoaderFactory.getOrCreatePluginClassLoader(IndyPluginClassLoaderFactory.java:73) ~[?:?]
	at co.elastic.apm.agent.bci.IndyBootstrap.bootstrap(IndyBootstrap.java:317) [?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
	at java.lang.IndyBootstrapDispatcher.bootstrap(IndyBootstrapDispatcher.java:31) [?:?]
	at java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:138) [?:?]
	at java.lang.invoke.CallSite.makeSite(CallSite.java:315) [?:?]
	at java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:259) [?:?]
	at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:249) [?:?]
	at externalplugin.TestClass.traceMe(TestClass.java:9) [main/:?]
	at externalplugin.TestClass.<init>(TestClass.java:5) [main/:?]
	at externalplugin.Main.main(Main.java:20) [main/:?]
Called trace me
2021-01-13 00:57:03,208 [main] ERROR co.elastic.apm.agent.bci.IndyBootstrap - Cannot resolve type description for co.elastic.apm.agent.bci.classloading.LookupExposer
java.lang.IllegalStateException: Cannot resolve type description for co.elastic.apm.agent.bci.classloading.LookupExposer
	at co.elastic.apm.agent.shaded.bytebuddy.pool.TypePool$Resolution$Illegal.resolve(TypePool.java:157) ~[?:?]
	at co.elastic.apm.agent.shaded.bytebuddy.pool.TypePool$Default$WithLazyResolution$LazyTypeDescription.delegate(TypePool.java:912) ~[?:?]
	at co.elastic.apm.agent.shaded.bytebuddy.description.type.TypeDescription$AbstractBase$OfSimpleType$WithDelegation.getDeclaredAnnotations(TypeDescription.java:8348) ~[?:?]
	at co.elastic.apm.agent.shaded.bytebuddy.matcher.DeclaringAnnotationMatcher.matches(DeclaringAnnotationMatcher.java:48) ~[?:?]
	at co.elastic.apm.agent.shaded.bytebuddy.matcher.DeclaringAnnotationMatcher.matches(DeclaringAnnotationMatcher.java:27) ~[?:?]
	at co.elastic.apm.agent.shaded.bytebuddy.matcher.ElementMatcher$Junction$Disjunction.matches(ElementMatcher.java:160) ~[?:?]
	at co.elastic.apm.agent.bci.IndyPluginClassLoaderFactory.getOrCreatePluginClassLoader(IndyPluginClassLoaderFactory.java:73) ~[?:?]
	at co.elastic.apm.agent.bci.IndyBootstrap.bootstrap(IndyBootstrap.java:317) [?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
	at java.lang.IndyBootstrapDispatcher.bootstrap(IndyBootstrapDispatcher.java:31) [?:?]
	at java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:138) [?:?]
	at java.lang.invoke.CallSite.makeSite(CallSite.java:315) [?:?]
	at java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:259) [?:?]
	at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:249) [?:?]
	at externalplugin.TestClass.traceMe(TestClass.java:10) [main/:?]
	at externalplugin.TestClass.<init>(TestClass.java:5) [main/:?]
	at externalplugin.Main.main(Main.java:20) [main/:?]
2021-01-13 00:57:03,216 [elastic-apm-init-instrumentation-shutdown-hook] INFO co.elastic.apm.agent.impl.ElasticApmTracer - Tracer switched to STOPPED state

BUILD SUCCESSFUL in 3s
3 actionable tasks: 2 executed, 1 up-to-date
00:57:04: Task execution finished 'Main.main()'

```

---

<div class="post-metadata">

**Author:** ![mputz86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mputz86/32/82131_2.png) [@mputz86](https://discuss.elastic.co/u/mputz86)\
**Post date:** [January 13, 2021, 9:14am UTC](https://discuss.elastic.co/t/trying-external-plugin-test-on-real-setup-fails-with-cannot-resolve-type-description-for-co-elastic-apm-agent-bci-classloading-lookupexposer/260923/2 "2021-01-13T09:14:38Z")

</div>

Soo, digging a little bit deeper, it is probably due to missing to add the `LookupExporter` to some classloader. But I have no idea where and how.

That's because when I remove the `LookupExporter` introducing commit, 98707982806d720666c57e60f87c54de46220e93, everything works like expected.

Here is a project with the minimal test, where switching between the official libs and the libs without the bootstrap lookup fix can be used to see how the behaviour for external plugins changed with this commit (see `build.gradle`). See `Main.java` on how to run (there are System properties to be set).  
Git repo for this [https://github.com/mputz86/elastic-apm-external-plugin-test](https://github.com/mputz86/elastic-apm-external-plugin-test) .

---

<div class="post-metadata">

**Author:** ![mputz86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mputz86/32/82131_2.png) [@mputz86](https://discuss.elastic.co/u/mputz86)\
**Post date:** [January 13, 2021, 9:49am UTC](https://discuss.elastic.co/t/trying-external-plugin-test-on-real-setup-fails-with-cannot-resolve-type-description-for-co-elastic-apm-agent-bci-classloading-lookupexposer/260923/3 "2021-01-13T09:49:09Z")

</div>

A workaround, which supports the assumption, that `LookupExporter` must be put somewhere else/loaded differently: Add the `co.elastic.apm.agent.bci.classloading.LookupExposer` to the external plugin sources (since it is an independent class anyway).

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [January 14, 2021, 7:00am UTC](https://discuss.elastic.co/t/trying-external-plugin-test-on-real-setup-fails-with-cannot-resolve-type-description-for-co-elastic-apm-agent-bci-classloading-lookupexposer/260923/4 "2021-01-14T07:00:32Z")

</div>

Hi and welcome to the APM forum!  
Thanks for reporting. I could easily reproduce the issue using the provided project, so thanks for that as well! It will ease the analysis process.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [January 14, 2021, 12:25pm UTC](https://discuss.elastic.co/t/trying-external-plugin-test-on-real-setup-fails-with-cannot-resolve-type-description-for-co-elastic-apm-agent-bci-classloading-lookupexposer/260923/5 "2021-01-14T12:25:20Z")

</div>

@mputz86 unfortunately, it may take a while before we can prioritize looking into this. In order for us not to lose sight of this, please open a bug report on our [GitHub repo](https://github.com/elastic/apm-agent-java) with all the relevant details.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 4, 2021, 8:25am UTC](https://discuss.elastic.co/t/trying-external-plugin-test-on-real-setup-fails-with-cannot-resolve-type-description-for-co-elastic-apm-agent-bci-classloading-lookupexposer/260923/6 "2021-02-04T08:25:21Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [February 15, 2021, 1:20pm UTC](https://discuss.elastic.co/t/trying-external-plugin-test-on-real-setup-fails-with-cannot-resolve-type-description-for-co-elastic-apm-agent-bci-classloading-lookupexposer/260923/7 "2021-02-15T13:20:24Z")

</div>

@mputz86 I finally got the chance to look into this. I created [a PR](https://github.com/elastic/apm-agent-java/pull/1660) with a proposed fix. Please try the [snapshot agent attach jar](https://apm-ci.elastic.co/job/apm-agent-java/job/apm-agent-java-mbp/job/PR-1660/6/artifact/src/github.com/elastic/apm-agent-java/apm-agent-attach/target/apm-agent-attach-1.21.1-SNAPSHOT.jar) and see if it fixes the issue.
