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

Dynamic instrumentation with javaagent is broken #1298

Open
lambrospetrou opened this issue Aug 4, 2023 · 2 comments
Open

Dynamic instrumentation with javaagent is broken #1298

lambrospetrou opened this issue Aug 4, 2023 · 2 comments

Comments

@lambrospetrou
Copy link

lambrospetrou commented Aug 4, 2023

Hello,
I have been trying to use a project (presto-gateway) that uses ActiveJDBC, and due to the deployment environment we need to use the dynamic instrumentation using -javaagent. We use version 2.3 in this project.

However, the dynamic instrumentation fails with this error message:

Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:491)
	at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:503)
Caused by: org.javalite.instrumentation.InstrumentationException: java.lang.NoSuchMethodException: org.javalite.activejdbc.ModelFinder.modelFound(java.lang.String)
	at org.javalite.instrumentation.JavaAgent.premain(JavaAgent.java:59)
	... 6 more
Caused by: java.lang.NoSuchMethodException: org.javalite.activejdbc.ModelFinder.modelFound(java.lang.String)
	at java.base/java.lang.Class.getDeclaredMethod(Class.java:2675)
	at org.javalite.instrumentation.JavaAgent.premain(JavaAgent.java:57)
	... 6 more
*** java.lang.instrument ASSERTION FAILED ***: "result" with message agent load/premain call failed at src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 42

I have traced that the instrumentation library attempts to load a ModelFinder::modelFound method (see code), but that method is commented out in that class (see code).

Is dynamic instrumentation not working properly, or is there a different way to enable that?

The README does not provide any indication on this issue.

@lambrospetrou lambrospetrou mentioned this issue Aug 4, 2023
@ipolevoy
Copy link
Member

ipolevoy commented Aug 4, 2023

@yanchevsky looks like you commented out these lines. Do you remember what was the reason?

@ipolevoy
Copy link
Member

ipolevoy commented Aug 5, 2023

Additional investigation:

The example: activejdbc-simple from the examples project fails with the same exception using these commands:

mvn clean package -DskipTests=true
mvn dependency:unpack-dependencies
java -javaagent:/home/igor/.m2/repository/org/javalite/activejdbc-instrumentation/3.0/activejdbc-instrumentation-3.0.jar  -classpath target/dependency:target/classes activejdbc.examples.simple.Main

java -javaagent:/home/igor/.m2/repository/org/javalite/activejdbc-instrumentation/3.0/activejdbc-instrumentation-3.0.jar -classpath target/dependency:target/classes activejdbc.examples.simple.Main

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

3 participants