-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Duplicate class definition for CGLIB proxy when running multiple Jetty instances in parallel #26564
Copy link
Copy link
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)
Description
Hi,
I have a spring web app with tests which start a jetty web server. The code looks something like:
// import org.eclipse.jetty.server.*
// import org.eclipse.jetty.webapp.*
final Server server = new Server(port);
final WebAppContext context = new WebAppContext();
context.setContextPath(contextPath);
context.setResourceBase(new File("src/main/webapp").getAbsolutePath());
context.setDescriptor(new File("src/main/webapp/WEB-INF/web.xml").getAbsolutePath());
context.setParentLoaderPriority(true);
context.setServer(server);
server.setHandler(context);
server.start
// Interact with server and so spring as well here.
server.stop/join/destroyThis all works well, except for when I enable parallel testing. With parallel testing (so multiple jetty servers may be running at a time and so spring will be called under the the web server at the same time) enabled I start to get attempted duplicate class definitions:
Caused by: java.lang.LinkageError: loader 'app' attempted duplicate class definition for com.AccountV1ApiCalls$$FastClassBySpringCGLIB$$6bb614f1. (com.AccountV1ApiCalls$$FastClassBySpringCGLIB$$6bb614f1 is in unnamed module of loader 'app')
at java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
at java.lang.ClassLoader.defineClass(ClassLoader.java:1017) ~[?:?]
at jdk.internal.reflect.GeneratedMethodAccessor101.invoke(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:523) ~[spring-core-5.1.4.RELEASE.jar:5.1.4.RELEASE]
... 108 more
I can't imagine that it is expected that spring would be thread-unsafe.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)