-
Notifications
You must be signed in to change notification settings - Fork 451
Description
Duplicate of #4038 for milestone 3.0.0
Describe the bug
Deploying an ear application that uses Morphia 2.5.1 and MongoDB Driver 5.6.1 (as provided in the lib/ext of the domain) into an application server like Payara (5.2022.5).
When the application starts and should map the package de.asheep.classloaderexample then no entities are mapped because line 621 of Mapper.java classes.add(Class.forName(classInfo.getName())); does not find the corresponding classes and throws an ClassNotFoundException which is ignored.
To Reproduce
Steps to reproduce the behavior:
- Build the example with
mvn clean package - Provide the mongodb 5.6.1 jars in the lib/ext directory of the domain of the application sever
- Deploy the ear file into a domain of the application sever
- Start the application
Expected behavior
The entities of the package de.asheep.classloaderexample should be found and mapped.
- Server Version: Payara 5.2022.5
- Driver Version: 5.6.1
- Morphia Version: 2.5.1
Additional context
It seems that the used ClassLoader is not the correct one. Changing the line to classes.add(Class.forName(classInfo.getName(), true, Thread.currentThread().getContextClassLoader())); will result in finding the correct classes.