Giter Site home page Giter Site logo

ClassCastException about dd-trace-java HOT 16 CLOSED

datadog avatar datadog commented on June 18, 2024
ClassCastException

from dd-trace-java.

Comments (16)

codylerum avatar codylerum commented on June 18, 2024 1

@tylerbenson Super simple

https://gist.github.com/codylerum/5341b1f1703708558be255e67ab18ff0

from dd-trace-java.

codylerum avatar codylerum commented on June 18, 2024 1

@tylerbenson updated to 0.22.0 and all seems to be working fine.

from dd-trace-java.

mar-kolya avatar mar-kolya commented on June 18, 2024

Hi @snusontable! Thanks for your bug report!

It turns out that we may have been working on a problem that is similar to yours. Could you please try this snapshot version of the agent: https://4867-89221572-gh.circle-artifacts.com/0/home/circleci/dd-trace-java/libs/dd-java-agent-0.10.0-SNAPSHOT.jar and let is know if that resolves your problem.

Thanks!

from dd-trace-java.

snuson avatar snuson commented on June 18, 2024

Hey.
Thanks for the incredibly fast response. Unfortunately we still get the exception and an error:

EXCEPTION java.lang.ClassCastException: datadog.trace.instrumentation.java.concurrent.ExecutorInstrumentation$CallableWrapper cannot be cast to company.common.asynchronous.immediatetasking.TaskWrapper company.common.asynchronous.immediatetasking.WrapperFutureTask.<init>(WrapperFutureTask.java:42) company.common.asynchronous.immediatetasking.TaskExecutorThreadPool.newTaskFor(TaskExecutorThreadPool.java:57) java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:133) company.common.asynchronous.immediatetasking.TaskExecutorThreadPool.submit(TaskExecutorThreadPool.java:48) company.common.asynchronous.immediatetasking.TaskExecutor.addTask(TaskExecutor.java:246) company.common.asynchronous.immediatetasking.TaskExecutor.addTask(TaskExecutor.java:218) company.common.asynchronous.immediatetasking.TaskExecutor.execute(TaskExecutor.java:99)...

and

Error logging in. Error: java.lang.ClassCastException: datadog.trace.instrumentation.java.concurrent.ExecutorInstrumentation$CallableWrapper cannot be cast to company.common.asynchronous.immediatetasking.TaskWrapper

from dd-trace-java.

mar-kolya avatar mar-kolya commented on June 18, 2024

Hi. Thanks for your response.

I'm sorry to hear that fix we are currently working on doesn't solve your problem.

So it looks like some of the instrumentation DataDog Java agent does may indeed be in conflict with your code. More specifically DataDog Java agent wraps all Runnables and Callables in ExecutorInstrumentation${Runnable,Callable}Wrapper in order to be able to trace those calls. It looks like some of your code expects your specific instances of TaskWrapper and DataDog's wrapping is causing problems.

It would be helpful to see relevant parts of company.common.asynchronous.immediatetasking.TaskExecutor, company.common.asynchronous.immediatetasking.TaskExecutorThreadPool, company.common.asynchronous.immediatetasking.WrapperFutureTask and company.common.asynchronous.immediatetasking.TaskWrapper - which ever parts you may share to be able to better understand your usage and potentially come up with the solution.

Thanks!

from dd-trace-java.

codylerum avatar codylerum commented on June 18, 2024

Running into the same issue now after moving from 0.7.0 -> 0.12.0

This is running in a Wildfly 11 container.

2018-08-09 14:11:56,042 SEVERE [org.glassfish.enterprise.concurrent] (EE-ManagedExecutorService-default-Thread-83) java.lang.ClassCastException: datadog.trace.instrumentation.java.concurrent.ExecutorInstrumentation$RunnableWrapper cannot be cast to org.glassfish.enterprise.concurrent.internal.ManagedFutureTask

I've rolled back to 0.7.0 as this was stopping my managed executor from running

from dd-trace-java.

codylerum avatar codylerum commented on June 18, 2024

This is a very standardized Java EE way of executing code.

ManagedExecutorService

Simply calling ManagedExecutorService#execute and passing in a call that implements Runnable.

from dd-trace-java.

tylerbenson avatar tylerbenson commented on June 18, 2024

@codylerum Thanks for the report. We will look into it. It would be helpful if you could provide a snippet of code with how you're interacting with ManagedExecutorService (construct, call into, etc)

from dd-trace-java.

asidorenko-emburse avatar asidorenko-emburse commented on June 18, 2024

Running into the same issue here, on Wildfly 10.1 and 0.13.0 of the agent:

java.lang.ClassCastException: datadog.trace.instrumentation.java.concurrent.ExecutorInstrumentation$RunnableWrapper cannot be cast to org.glassfish.enterprise.concurrent.internal.ManagedFutureTask

Our interaction with ManagedExecutorService is also a very simple one:

executor.execute( code );

from dd-trace-java.

realark avatar realark commented on June 18, 2024

Thanks @codylerum @asidorenko-nexonia. We're working on a long-term fix. It's a top priority, but the change is deep so it may be a few releases before it's ready.

For now the best workaround is to disable the concurrent instrumentation: -Ddd.integration.java_concurrent.enabled=false

from dd-trace-java.

codylerum avatar codylerum commented on June 18, 2024

@realark Any ETA on this? At this point we are just hanging back on the 0.7.0 release

from dd-trace-java.

tylerbenson avatar tylerbenson commented on June 18, 2024

@codylerum we made some improvements in 0.16.0 that may improve things for your specific case (3d78afb) but we are actively working on a longterm solution. (See latest work here: #564)

Either way, you can still apply the setting that @realark mentioned to disable the executor instrumentation. That should allow you to update either way.

from dd-trace-java.

realark avatar realark commented on June 18, 2024

@codylerum @asidorenko-nexonia Thanks for your patience. We have a fix out in our latest 0.19.0 release. I'd appreciate it if you could try running with the fix yourselves. We've done a lot of testing on our end but the instrumentation is pretty generic so there may be an environment we didn't consider.

from dd-trace-java.

tylerbenson avatar tylerbenson commented on June 18, 2024

@codylerum @asidorenko-nexonia any chance you were able to verify the fix in the latest versions? I'd like to close out this issue.

from dd-trace-java.

asidorenko-emburse avatar asidorenko-emburse commented on June 18, 2024

@tylerbenson I can confirm the fix is good. We're currently running 0.21.0 without issues. Thanks!

from dd-trace-java.

tylerbenson avatar tylerbenson commented on June 18, 2024

Great, thanks!

from dd-trace-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.