Bug 545890 - signer information does not match signer information of other classes in the same package
Summary: signer information does not match signer information of other classes in the ...
Status: CLOSED INVALID
Alias: None
Product: AspectJ
Classification: Tools
Component: LTWeaving (show other bugs)
Version: 1.9.2   Edit
Hardware: PC Windows 10
: P3 blocker (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-28 08:06 EDT by Andrei Ivanov CLA
Modified: 2019-04-24 08:36 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Ivanov CLA 2019-03-28 08:06:52 EDT
Using AspectJ 1.9.2 (and 1.9.3.RC1) with Spring Boot 2.1.3 / Spring Framework 5.5.5 and LTW (-javaagent:spring-instrument-5.1.5.jar and @EnableLoadTimeWeaving)

I tried switching the JAXB implementation to Eclipse Moxy 2.7.4, when I ran into this problem:

java.lang.SecurityException: class "org.eclipse.persistence.jaxb.JAXBMarshaller"'s signer information does not match signer information of other classes in the same package
  at java.lang.ClassLoader.checkCerts(ClassLoader.java:898) ~[?:1.8.0_181]
  at java.lang.ClassLoader.preDefineClass(ClassLoader.java:668) ~[?:1.8.0_181]
  at java.lang.ClassLoader.defineClass(ClassLoader.java:761) ~[?:1.8.0_181]
  at java.lang.ClassLoader.defineClass(ClassLoader.java:642) ~[?:1.8.0_181]
  at org.eclipse.jetty.webapp.WebAppClassLoader.foundClass(WebAppClassLoader.java:667) ~[?:?]
  at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:555) ~[?:?]
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_181]
  at org.eclipse.persistence.jaxb.JAXBContext$JAXBContextState.createMarshaller(JAXBContext.java:1581) ~[org.eclipse.persistence.moxy-2.7.4.jar:?]
  at org.eclipse.persistence.jaxb.JAXBContext.createMarshaller(JAXBContext.java:421) ~[org.eclipse.persistence.moxy-2.7.4.jar:?]
  at org.eclipse.persistence.jaxb.JAXBContext.createMarshaller(JAXBContext.java:1) ~[org.eclipse.persistence.moxy-2.7.4.jar:?]
  at org.glassfish.jersey.jaxb.internal.AbstractJaxbProvider.getMarshaller(AbstractJaxbProvider.java:269) ~[?:?]
  at org.glassfish.jersey.jaxb.internal.AbstractJaxbProvider.getMarshaller(AbstractJaxbProvider.java:231) ~[?:?]
  at org.glassfish.jersey.jaxb.internal.AbstractRootElementJaxbProvider.writeTo(AbstractRootElementJaxbProvider.java:175) ~[?:?]

The aop.xml:

<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
    <weaver options="-Xset:weaveJavaxPackages=true -verbose -showWeaveInfo -XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler">
        <include within="javax.persistence.*" />
        <include within="org.hibernate.internal.*" />
    </weaver>

    <aspects>
        <aspect name="ch.quant.core.persistence.EntityManagerAspect" />
    </aspects>
</aspectj>

The web app is deployed in a Jetty 9.4.12.v20180830 running on jvm 1.8.0_181-8u181-b13-2~deb9u1-b13

Initially I thought it's a duplicate of #542421, but, as far as I saw, the Java version is 8 and it's not even weaving the class, as it doesn't match the include filter.

Seeing that WeavingAdaptor.ensureDelegateInitialized gets called, I've added an exclusion fast pattern, <exclude within="org.eclipse.persistence.jaxb..*" />, but it didn't help 😟
Comment 1 Andrei Ivanov CLA 2019-03-29 10:13:45 EDT
It seems to be an issue with the Jetty WebAppClassLoader.
When there are no transformers defined, it invokes the parent:
https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java#L689

Otherwise, it invokes defineClass without a ProtectionDomain:
https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java#L707
Comment 2 Andrei Ivanov CLA 2019-03-29 11:32:59 EDT
And I was pointed to https://bugs.openjdk.java.net/browse/JDK-8189231, which indicates a classloader issue on Java 8, fixed in later versions 😟
Comment 3 Andrew Clement CLA 2019-03-29 16:03:21 EDT
You are doing a lot of digging there :) I presume you've tried a JDK which contains the fix for the issue you were pointed to but it doesn't help?
Comment 4 Andrew Clement CLA 2019-03-29 16:04:02 EDT
Oh wait, I see you closed this bug as not AspectJ. So maybe it did work for you when you eventually got to the end of the digging. Sorry I didn't get to this sooner to at least triage it.
Comment 5 Andrei Ivanov CLA 2019-03-29 16:10:55 EDT
I haven't yet been able to confirm, upgrading to Java 11 is planned, but I'm not sure how much time it will take.
Comment 6 Andrei Ivanov CLA 2019-04-24 08:36:55 EDT
I've added this comment to the Jetty issue [1]:

So, the problem seems to be caused by the fact that the Spring `LoadTimeWeaver` gets initialized a bit later in the application initialization process and some classes from `org.eclipse.persistence.moxy-2.7.4.jar` already get loaded (https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java#L689) with the 
package certificates.

After the `ClassFileTransformer` gets added, the rest of the classes from that jar go through a different path (https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java#L707) and that doesn't load the package certificates, even on Java 11 😞

I did find a workaround by forcing the `LoadTimeWeaver` to get initialized as early as possible and by removing a class reference from that jar from an annotation.

Not sure if there's anything that can be done from Jetty's side or the JVM or maybe I should have tried to use LTW using the AspectJ agent instead of the Spring one.

[1] https://github.com/eclipse/jetty.project/issues/1068#issuecomment-485708526