{"action":"created","issue":{"url":"https://api.github.com/repos/opentracing-contrib/java-agent/issues/43","repository_url":"https://api.github.com/repos/opentracing-contrib/java-agent","labels_url":"https://api.github.com/repos/opentracing-contrib/java-agent/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/opentracing-contrib/java-agent/issues/43/comments","events_url":"https://api.github.com/repos/opentracing-contrib/java-agent/issues/43/events","html_url":"https://github.com/opentracing-contrib/java-agent/issues/43","id":366357859,"node_id":"MDU6SXNzdWUzNjYzNTc4NTk=","number":43,"title":"Class Loaders and Common Dependencies","user":{"login":"keitwb","id":614344,"node_id":"MDQ6VXNlcjYxNDM0NA==","avatar_url":"https://avatars2.githubusercontent.com/u/614344?v=4","gravatar_id":"","url":"https://api.github.com/users/keitwb","html_url":"https://github.com/keitwb","followers_url":"https://api.github.com/users/keitwb/followers","following_url":"https://api.github.com/users/keitwb/following{/other_user}","gists_url":"https://api.github.com/users/keitwb/gists{/gist_id}","starred_url":"https://api.github.com/users/keitwb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keitwb/subscriptions","organizations_url":"https://api.github.com/users/keitwb/orgs","repos_url":"https://api.github.com/users/keitwb/repos","events_url":"https://api.github.com/users/keitwb/events{/privacy}","received_events_url":"https://api.github.com/users/keitwb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-03T14:07:48Z","updated_at":"2018-10-03T14:45:08Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Some projects use their own class loader (e.g. spring boot, servlet servers) that is a child of the standard Java system classpath class loader, which is in turn a child of the bootstrap and ext class loaders.\r\n\r\nThings get pretty hairy when you bundle the java agent with the OT instrumentation libraries and those instrumentation libs contain dependencies that are provided by these child class loaders (e.g. the web-servlet-filter instrumentation depends on `javax.servlet-api`, which I have noticed is sometimes only available in a \"custom\" class loader provided by the framework).\r\n\r\nIf I'm understanding it correctly, classes loaded by a parent class loader cannot \"see\" classes that only exist in child class loaders.  The java agent runs in either the bootloader or system class loader (depending on the `Boot-Class-Path` manifest option) and thus can never see provided deps in non-standard class loaders.  Moreover, it is not possible to simply create rules to use the custom class loader to load the instrumentation libraries because class loaders defer up the hierarchy first, which means the libs will be loaded from the agent bundle in the same manner.\r\n\r\nI think this means that the agent either needs to include the provided dependencies itself (which is limited to only a single version of those dependencies, which increases risk of dependency mismatch with the instrumented application), **or** the instrumentation libraries need to be bundled separately from the agent and then loaded via the custom class loader via a custom rule/code.\r\n\r\nHas anybody else dealt with this before or has any insights/thoughts?"},"comment":{"url":"https://api.github.com/repos/opentracing-contrib/java-agent/issues/comments/426664419","html_url":"https://github.com/opentracing-contrib/java-agent/issues/43#issuecomment-426664419","issue_url":"https://api.github.com/repos/opentracing-contrib/java-agent/issues/43","id":426664419,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNjY2NDQxOQ==","user":{"login":"objectiser","id":164562,"node_id":"MDQ6VXNlcjE2NDU2Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/164562?v=4","gravatar_id":"","url":"https://api.github.com/users/objectiser","html_url":"https://github.com/objectiser","followers_url":"https://api.github.com/users/objectiser/followers","following_url":"https://api.github.com/users/objectiser/following{/other_user}","gists_url":"https://api.github.com/users/objectiser/gists{/gist_id}","starred_url":"https://api.github.com/users/objectiser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/objectiser/subscriptions","organizations_url":"https://api.github.com/users/objectiser/orgs","repos_url":"https://api.github.com/users/objectiser/repos","events_url":"https://api.github.com/users/objectiser/events{/privacy}","received_events_url":"https://api.github.com/users/objectiser/received_events","type":"User","site_admin":false},"created_at":"2018-10-03T14:45:08Z","updated_at":"2018-10-03T14:45:08Z","author_association":"COLLABORATOR","body":"Yes I have found the same problem, and causes issues when trying to use the agent with JEE servers.\r\n\r\nUnfortunately this is a side effect of using the rules to bootstrap the framework instrumentations, which is good from a reuse perspective.\r\n\r\nHowever if the same instrumentation was fully encoded in the rules we would not have this issue with the class dependencies - but on the other hand we would be duplicating the framework instrumentations and therefore increasing the maintenance burden.\r\n"}}
{"actor":{"display_login":"objectiser"}}