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

Is applicationinsights-core support JDK 9+ currently? #674

Closed
jdneo opened this issue May 29, 2018 · 31 comments
Closed

Is applicationinsights-core support JDK 9+ currently? #674

jdneo opened this issue May 29, 2018 · 31 comments
Assignees
Milestone

Comments

@jdneo
Copy link
Member

jdneo commented May 29, 2018

I'm getting

A required class was missing while executing com.microsoft.azure:azure-functions-maven-plugin:1.0.0-beta-2:package: javax/xml/bind/JAXBException

When using JDK 10 on my machine. Not quite sure if it is because AI Java SDK not support JDK 9+.

Then according to this answer, I added

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
</dependency>

into my pom and upgrade AI-core to the newest version: 2.1.1

Then everything works fine. But I cannot receive the telemetries then. Any suggestions on that?

@dhaval24
Copy link
Contributor

@jdneo I think this should work. I have tested this in JDK 10 in a SpringBoot application which creates a fat jar. If you are doing it otherwise, I am not sure how it exactly is done in Functions, but ensure that the jaxb-api is exposed in the final war/jar artifact which is created after mvn package.

This library should be available at run time for proper execution.

As far as support is concerned for JDK 9+, the main work for support lies in dependency collection via Application Insights Java Agent, though other parts seems to work once required modules are supplied, we still lack integrated testing on these new JDKs and hence there is no claim for official support.

@jdneo
Copy link
Member Author

jdneo commented May 29, 2018

It might work for fat jar. How about non fat jar scenario?

@littleaj littleaj changed the title [Help Wanted] Is applicationinsights-core support JDK 9+ currently? Is applicationinsights-core support JDK 9+ currently? May 31, 2018
@littleaj
Copy link
Contributor

littleaj commented May 31, 2018

@jdneo try using --add-module java.xml.bind to the JVM command line.

From preliminary research, we think the only thing that breaks us is the "modularizing" in Java 9. Since we use the xml.bind classes, you'll need to add at least that module to the command line.

I haven't had the chance to try this yet, but we will be working on this soon. Let us know if this works for you and I'll keep this ticket open until we update the documentation with the Java 9 workarounds.

@dhaval24
Copy link
Contributor

dhaval24 commented Jun 1, 2018

@littleaj I think that we should prohibit users from adding --add in the command line. The JavaEE APIs will be depreciated from Java 11 and onwards (pretty soon) and the command line flag will no longer work for people who have migrated to Java 9 and are using this technique.

https://jaxenter.com/jdk-11-java-ee-modules-140674.html

The better long term solution as mentioned in the stackoverflow answer @jdneo pointed (check proper long term solution section) would be to explicitly add the jaxb-api in the dependencies section.

Alternatively, when we release next version of SDK we can package this API as a part of our library. Though there is definitely a risk of dependency hell with the above approach as this would be very commonly used module in many enterprises and I would rather let users update their POM.

@littleaj
Copy link
Contributor

littleaj commented Jun 1, 2018

Ah, good catch. So, yes. It's a workaround that will work now if you want to get unblocked in Java 9, @jdneo; but it will likely break again if you upgrade to Java 11 after that is released.

Given this information we will likely look for other XML deserializing options to make this issue obsolete.

@jdneo
Copy link
Member Author

jdneo commented Jun 2, 2018

@dhaval24 @littleaj Thank you for all the information provided here.

Both fat-jar and --add-module java.xml.bind can solve the problem currently, but I think both of them are just kind of workaround but not a real solution. I'm not an expert for this problem but is it possible that we can let users simply add the AI-sdk as one of their Maven dependencies and then everything works fine for all JDK 8,9,10, etc... Maybe just as @littleaj said: using other XML parsing library.

Since AI Java SDK is a very important and fundamental lib for Java devs. I think if we can solve this, that will be great both for us and our customers. 😄

@dhaval24
Copy link
Contributor

dhaval24 commented Jun 3, 2018

@jdneo thanks for your suggestion. Yes I believe we should invest in long term seamless solution for all JDKs if possible. We have a feature planned to support JDK 9+ and when we tackle that in coming month or so we would make sure to address this problem in best possible way. In the mean time please feel free to share any information you get around the same in this issue here.

@timja
Copy link
Contributor

timja commented Sep 24, 2018

Hi @dhaval24 any progress on this? java 11 gets released tomorrow and we would like to look at upgrading to it?

@dhaval24
Copy link
Contributor

@timja we haven't been able to get to this yet. I hope we should get to it soon. If you have suggestions open to explore,

@alert101
Copy link

alert101 commented Jan 4, 2019

Hi @dhaval24. Any status update on this? Our project is upgraded to Java 11 shortly and we are unsure how AI will react to this.

@dhaval24
Copy link
Contributor

dhaval24 commented Jan 9, 2019

@alert101 this is still in our backlogs and we are actively tracking it. There are few key things that needs to be done for this migration:

  1. How agent gets loaded. Currently, agent is loaded in bootstrap classloader, however, with Java 9+ there has been some changes in class loading which is still unclear to me.
  2. The library relies on some libraries which were previously part of java runtime but wit Java 9+ they moved it to separate module which is not part of default runtime.

@stevenleadbeater
Copy link

I have this working locally with Java 11. Please give me permission to create a branch in this repo and I'll raise a PR

@timja
Copy link
Contributor

timja commented Mar 19, 2019

@stevenleadbeater you can fork the repo and send a PR

@ElliotZhang
Copy link

@stevenleadbeater can you create a PR? I've also looked into this but Java agent in JDK 11 hasn't been able to send anything.

@stevenleadbeater
Copy link

@ElliotZhang I was going to make a PR when they let me push my changes to a branch in this repo. Instead they've asked me to fork it and do it that way. I know its only a 10 minute job, but now I have the code done I have other things to be doing. I've built the jar, it seems to work for us, so we loaded it into our own maven repo. I'll see if I can find the time to port the code some time soon

@dhaval24
Copy link
Contributor

dhaval24 commented Apr 2, 2019

@stevenleadbeater apologies if there was any confusion here. We are always very happy to accept contributions.

By meaning to “fork the repo and send the pr” I just want to clarify that it meant sending a PR to origin repo from your fork. In that way you do need a permission to create a branch in origin repo.

I would be very happy if you make this contribution!

@stevenleadbeater
Copy link

@dhaval24 No, there is no confusion. I know what you want. Like I said though, my team is unblocked by this as we have our own jar in our own maven repo now. I've got a lot on my plate at the moment and shifting the origin to another repo pushing it up and doing all the admin like tasks of getting it in to a PR from a forked repo has just taken a back seat to other things. I'll get to it when I can although it may need some extra work around keeping support for older JDKs as I've ripped that out after considering that JDK 11 is the only supported open JDK. However, there are still places paying for JDK7 and 8 support I believe... Not sure what you guys want to do around this, obviously it's not a good idea to maintain 2 code bases for pre and post jigsaw. Perhaps we could have separate builds run for JDK9+ and JDK7-8?

@dhaval24
Copy link
Contributor

dhaval24 commented Apr 3, 2019

@stevenleadbeaeter totally understandable and appreciate your explanation. Regarding support for JDK 7 and 8, we definitely would have to keep supporting them for a while as Microsoft does support those versions and many users and enterprises are still on JDK 8. If there is no better way, we might create 2 jars.

With that in mind: would you mind elaborating the set of changes you had to do to make JDK 11 work with Java Agent. If they are small enough I can help with them.

@Flanker32
Copy link
Member

@dhaval24 I add the dependency in project to enable application insights in maven plugin with java 11 , it works but no telemetries was sent. Then i found there is an exception when read instrument key from application insights.xml, it throws an exception. And when i remove the xmlns in config xml, it could work, but it failed again with java 8 , it seems that schema differs in jre8 and java11 with maven(I tried the code and it works in a simple java project, but it failed again in a test maven mojo). Is there any method to solve this issue? For now we could only read the instrument key manually and pass it to application insight.

link to code where throw exception

exception in java 11

unexpected element (uri:"http://schemas.microsoft.com/ApplicationInsights/2013/Settings", local:"ApplicationInsights"). Expected elements are <{}ApplicationInsights>]

exception in java8

unexpected element (uri:"", local:"ApplicationInsights"). Expected elements are <{http://schemas.microsoft.com/ApplicationInsights/2013/Settings}ApplicationInsights>]

@dhaval24
Copy link
Contributor

dhaval24 commented Apr 17, 2019

@Flanker32 I have learned that the url http://schemas.microsoft.com/ApplicationInsights/2013/Settings doesn't seem to exist and newer version of jaxb are doing strict xml parsing (apparently). What happens when you just remove the xmls and try to run it in JDK 11?

@Flanker32
Copy link
Member

@dhaval24 It works well in JDK11, however, the same code failed in java8 and throw an exception unexpected element (uri:"", local:"ApplicationInsights"). Expected elements are <{http://schemas.microsoft.com/ApplicationInsights/2013/Settings}ApplicationInsights>].

The exception only exist when I run the code within a maven mojo, I created a java project and run the code and it works in both java8 and java11.

@ElliotZhang
Copy link

@Flanker32 can you share your environment settings. I removed the xmlns in ApplicationInsights.xml but then all tracings were off, even the web req operations that used to work (in JDK 11).
I am using Wildfly 16, application insight (core and agent) version 2.4.0-BETA, Oracle JDK 11.02

@J4cku
Copy link

J4cku commented May 9, 2019

Any updates on when can we expect AppInsightAgent to work with java 11?

@timja
Copy link
Contributor

timja commented May 9, 2019

@J4cku this PR fixes the startup issues on java 11:
#909

Its pending some work done on the build side but I think its fairly close, subscribe to the PR for now.

@ElliotZhang
Copy link

@timja I had applied this fix to make agent come up in my env but the problem is it doesn't send any telemetry. I guess there is some other blocking issue.

@Flanker32
Copy link
Member

@ElliotZhang Here is the pr we fix this issue microsoft/azure-maven-plugins#610, we use AI within a maven plugin project, Application Insights 2.2.1 , Oracle JDK 11.

Issues we meet is that JAXB can't parse the configuration XML and return null which made AI lose the instrumentation key to send telemetry. You may attach to AI and set a breakpoint here to see whether you meet the same issue.

@geoarchitect
Copy link

Is it possible to get some of these fixes merged into an alpha release of the spring dependencies and a new agent? You currently have a 2.4.0-BETA tag out, maybe we can do something similar?

I'm sure we could help test if you make this available.

@HarshaSuranjith
Copy link

Hi @dhaval24, does insights java agent support Java 12 ??

@timja
Copy link
Contributor

timja commented Jul 15, 2019

@dhaval24 @trask @littleaj
Any reason this is still open?

Seems like support was released in the beta version.

I've tested it on one of my apps and it works (spring-boot 2 with postgresql jdbc)

Also, is Class support likely to come back to AI-Agent.xml or is it gone for good?

Removed support for custom instrumentation in AI-Agent.xml

@littleaj littleaj modified the milestones: future, 2.5.0-BETA Jul 15, 2019
@littleaj
Copy link
Contributor

@timja Thanks, I'll close this as fixed.

Regarding class support, we've had some others ask for it so it will likely return in 2.5.0-BETA2 or GA, whichever comes first.

@littleaj
Copy link
Contributor

Java 9+ support added in #971 (2.5.0-BETA)

@ghost ghost locked as resolved and limited conversation to collaborators Jul 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.