cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tagging with ADK for Java

darya_romanova
Newcomer


Hello,


I want to combine two purepaths by means of ADK for Java. My first purepath starts when the user is being registered and the method
registration(User user), which saves new user in DB, is called in server side. Inside this method I wrote:


if(tagging == null){
DynaTraceADKFactory.initialize();
tagging = DynaTraceADKFactory.createTagging();
}
byte[] tag = user.getUsername().getBytes();
Tagging.CustomTag customTag = tagging.createCustomTag(tag);
tagging.linkClientPurePath(false, customTag);


My second purepath starts on another JVM when a user with the appropriate username is requested and the method
getUserByUsername(String username), which gets user from DB, is called. Inside this method I wrote:


if(tagging == null){
DynaTraceADKFactory.initialize();
tagging = DynaTraceADKFactory.createTagging();
}
byte[] tag = username.getBytes();
tagging.setCustomTag(tag);
tagging.startServerPurePath();
User user = userService.getByUsername(username);
tagging.endServerPurePath();


First application is web-site, which deployed on Apache Tomcat 7. Apache Tomcat 7 is running with dynatrace agent and has com.dynatrace.adk-6.2.6.1006.jar in his lib directory (C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib). And ADK is also included as Maven dependance into application.


Second application is REST web-service on another JVM, which also deployed on Apache Tomcat 7.


So, my proplem is when I try to register user I get an error from server
java.lang.NoSuchMethodError: com.dynatrace.diagnostics.agent.TraceTag.setCustomTag(Ljava/lang/Object;)V


Is there any suggestions what should I do?

12 REPLIES 12

peter_karlhuber
Dynatrace Pro
Dynatrace Pro

Hi Darya,

the "setCustomTag" method needs a byte array; you can pass the "tag" directly to it, or you can use "customTag.getTag()", but you might have to initialize this object here first. Let me know if it works, thanks,

best regards,

Peter


Hi Peter,

I'm sorry but I don't understand your answer. As I wrote before, in the server side of my first application I had written:


byte[] tag = user.getUsername().getBytes(); // it gets username as a byte array
// it creates an object of Tagging.CustomTag
//and pass a byte array to its constractor
Tagging.CustomTag customTag = tagging.createCustomTag(tag);


My problem appiers when the method
tagging.linkClientPurePath(false, customTag); is called. So, I get an error from server
java.lang.NoSuchMethodError: com.dynatrace.diagnostics.agent.TraceTag.setCustomTag(Ljava/lang/Object;)V


I don't understand, why it can not find the method "setCustomTag" inside ADK library?

Best regards,

Darya

Hi Darya,

I referred to the code that I saw in the notification email that was sent by confluence:

if(tagging == null){
DynaTraceADKFactory.initialize();
tagging = DynaTraceADKFactory.createTagging();
}
byte[] tag = username.getBytes();
tagging.setCustomTag(customTag);
tagging.startServerPurePath();
User user = userService.getByUsername(username);
tagging.endServerPurePath();


where an object is passed to the setCustomTag method instead of a byte array.

The error message indicates that in some place you might still have a method call like this, where you pass this method an object instead of a byte array, please check all the occurrences of "setCustomTag" and make sure you're passing a byte array.

Best regards,

Peter

PS: if that doesn't help, open a support ticket.

Peter,

the method which is not found is "TraceTag.setCustomTag()", which is not to be confused with "Tagging.setCustomTag()" and is not exposed by the ADK at all.

as I said in my below answer, I would assume some sort of version conflict.

Christian

oops, thanks for pointing that out...

dave_mauney
Dynatrace Champion
Dynatrace Champion

Hi Darya,

It seems you are calling with one argument, and the method is looking for 2 (boolean and object).

HTH,

dave

Hi Dave,

I'm sorry, could you specify the name of the method you're speaking about?

Best regards,

Darya

Hi Darya,

Sorry to confuse you. I read one of the method names wrong. I actually cannot see any issue with what you are doing in the code. You may want to open a support case.

dave

c_schwarzbauer
Dynatrace Champion
Dynatrace Champion

Hi Darya,

based on your sample and the error message (which is referring a method that you cannot call from the ADK at all) I would assume some sort of version problem.

you already said you're using the ADK in version 6.2.6, can you tell us which version of the Agent you're using?

also a the complete stacktrace of the error and maybe the agent logs would be helpful.

however, opening a support case would be good, anyway.

best, Christian

Hi Christian,

Thank you for your help! Version of the Agent, that I'm using, is 6.5.13.1014. Also I included complete stacktrace of the error and the agent logs (complete-stacktrace.txt , dt-apache-tomcat-app-test-1360.log , dt-apache-tomcat-app-test-bootstrap-1360.log)

Best regards,

Darya

hi Darya,

so I had a look at the Java ADK jar in exactly the same version as you're using and also in the code history and I can basically guarantee you: there is no such method call in the ADK jar provided by us. 🙂

however, I have a strong assumption that there has been some tampering with the bytecode, because of

  • the "com.serviceteem.aspect.AspectSite.ajc$...(AspectSite.aj:46)" call on the stacktrace, indicating heavily to AspectJ
  • the line number 190 which does not really match with the actual line numbers in the line number table of the original class file

so I'm assuming that this aspect modifies the bytecode of the ADK in some way to change the method signature of that call. does that sound reasonable to you?

to investigate further we would need information like:

  • the configuration of the AspectJ aspect(s) used here
  • the modified classes, which should be possible to get from the agent with class dumping and maybe also changing the order of agents on the command line

however, if you want to investigate further, I'd suggest to create a support ticket at this point. you can also mention me on that ticket and/or provide the ticket number here, so I can take a look.

HTH, Christian

Alram_Lechner
Newcomer

Hi Darya,

Sorry for the late answer. Just working on similiar issue and got reference to this question.

I hope, you where able solve the issue in the meantime. If not - the solution is to not use the Tagging ADK published on MavenCentral. Please use the Tagging ADK from our official download site:

https://downloads.dynatrace.com/downloads/download...

com.dynatrace.adk.jar (which should be used) is included in native jar download.

greetings Alram