kumuluz / kumuluzee

Lightweight open-source framework for developing microservices using standard Java EE technologies and migrating Java EE to cloud-native architecture.
https://ee.kumuluz.com
MIT License
291 stars 71 forks source link

Maven failsafe plugin gotcha #133

Open fabiosimeoni opened 5 years ago

fabiosimeoni commented 5 years ago

I've spent quite some time wondering why my integration tests would fail from the command line and not from the IDE. My Application entrypoint would simply be ignored, along with all resources and providers in my main application.

Eventually I'd narrowed this down to a combination of how kumuluz works in exploded mode and the default behaviour of the failsafe plugin, which I use to start and stop a database required for integration tests. The plugin runs after the package phase, hence after the uberjar has been created. Finding a build artefact it adds it to the classpath in lieu of the target/classes. JettyServletServer however expects to look into target\classes in exploded mode, hence fails to pick up the components (unless one adds the current project to scan-libraries, which is totally weird`).

Fortunately, one can configure explicitly this on the failsafeplugin:

<classesDirectory>${project.build.outputDirectory}</classesDirectory>

which tells it to prefertarget\classes over the built jar.

I'm reporting this because it's obscure and it's worth sharing.