ApplicationInsights-Java icon indicating copy to clipboard operation
ApplicationInsights-Java copied to clipboard

Exception Provider class xmlpull not found in modularized application

Open tobiasdiez opened this issue 4 years ago • 6 comments

When using applicationinsights-core-2.5.1 in an modularized java 12 (or 13) application, you get the following error:

Error:java: java.lang.module.FindException: Unable to derive module descriptor for applicationinsights-core-2.5.1.jar
Provider class com.microsoft.applicationinsights.core.dependencies.xmlpull.mxp1.MXParser,org.xmlpull.mxp1_serializer.MXSerializer not in module

The file /META-INF/services/com.microsoft.applicationinsights.core.dependencies.xmlpull.v1.XmlPullParserFactory indeed contains com.microsoft.applicationinsights.core.dependencies.xmlpull.mxp1.MXParser,org.xmlpull.mxp1_serializer.MXSerializer which is indeed a strange format (as there should be one class per line). I guess one should use StAX instead of XPP3 anyway...

tobiasdiez avatar Nov 11 '19 20:11 tobiasdiez

Hi @tobiasdiez, thanks for reporting this! I wonder if the problem is that org.xmlpull.mxp1_serializer.MXSerializer should be shaded.

Can you try modifying /META-INF/services/com.microsoft.applicationinsights.core.dependencies.xmlpull.v1.XmlPullParserFactory to instead contain

com.microsoft.applicationinsights.core.dependencies.xmlpull.mxp1.MXParser,com.microsoft.applicationinsights.core.dependencies.xmlpull.mxp1_serializer.MXSerializer

and see if that change would fix the issue?

trask avatar Nov 11 '19 20:11 trask

This issue is still present in 2.6:

Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for /home/runner/.gradle/caches/modules-2/files-2.1/com.microsoft.azure/applicationinsights-core/2.6.0/6eb3da0681d7bdf0aa6318c6946994a37d25f962/applicationinsights-core-2.6.0.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class com.microsoft.applicationinsights.core.dependencies.xmlpull.mxp1.MXParser,org.xmlpull.mxp1_serializer.MXSerializer not in module
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for /home/runner/.gradle/caches/modules-2/files-2.1/com.microsoft.azure/applicationinsights-core/2.6.0/6eb3da0681d7bdf0aa6318c6946994a37d25f962/applicationinsights-core-2.6.0.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class com.microsoft.applicationinsights.core.dependencies.xmlpull.mxp1.MXParser,org.xmlpull.mxp1_serializer.MXSerializer not in module

tobiasdiez avatar Apr 02 '20 09:04 tobiasdiez

In 2.6.1 it is still present: https://github.com/JabRef/jabref/pull/6594

tobiasdiez avatar Jun 09 '20 07:06 tobiasdiez

Hi @tobiasdiez, can you create a github repository with a simple repro?

trask avatar Jun 09 '20 22:06 trask

Hello. I am facing the same problem. Here's a simple test. https://github.com/jesjobom/applicationinsights-java-module-test

module-info.java

module com.jesjobom {
    requires applicationinsights.core; //automatic module
}

Error:

Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class com.microsoft.applicationinsights.core.dependencies.xmlpull.mxp1.MXParser,org.xmlpull.mxp1_serializer.MXSerializer not in module

jesjobom avatar Jun 19 '20 20:06 jesjobom

Just going to throw this out there as a something that might save someone some work, or prod something into motion.

I've got insights working for another project in a modularized build by way of adding module-info to the insights jars...

The caveat is this is dependent on having a working webservice stack, which last I looked was still not jigsaw compliant, and still relied on reflection, meaning jdeps didn't ferret out all the needed dependencies. Making insights modular looks reasonably trivial compared to the j2ee stacks needed for webservice calls.

Use at own risk. Your mileage may vary. Insert caveat here. Reminder: Jigsaw treats the 'static' keyword in module-info files as meaning "Optional" - those modules are added to the module-graph if available, but the application launch does not fail if they cannot be found. module-info for logging was created against logging version 2.6.2. module-info for core was created against core version 2.5.0 module-infos.txt

Torrenal avatar Jun 01 '21 03:06 Torrenal

Closing, there are new 3.4.0 versions applicationinsights-core and applicationinsights-web artifacts that are modularized, and specifically target Application Insights Java 3.x. Please see upgrading from 2.x.

trask avatar Sep 19 '22 19:09 trask