-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ClassCastException - Loose app deployment incorrect for EAR configured with <skinnyModules>true</skinnyModules> #1855
Comments
Hi @mthmulders, I am currently analysing the issue and have successfully reproduced it. I will keep you updated on my progress. |
The issue is the See my PR to your repo: mthmulders/openliberty-multi-app-deploy#1 |
Thank you @ajaypaul-ibm and @tjwatson for your investigations. @tjwatson, I've merged your suggestion, ran After
But alas, I am still facing the same error message. |
Turns out this is now a liberty plugin issue with the generated loose application XML. The liberty maven plugin is not aware of the <archive targetInArchive="/it.mulders.ol-api-1.war">
<dir sourceOnDisk="/home/tjwatson/dev/liberty/examples/openliberty-multi-app-deploy/api/src/main/webapp" targetInArchive="/"/>
<dir sourceOnDisk="/home/tjwatson/dev/liberty/examples/openliberty-multi-app-deploy/api/target/classes" targetInArchive="/WEB-INF/classes"/>
<file sourceOnDisk="/home/tjwatson/dev/liberty/examples/openliberty-multi-app-deploy/api/target/tmp/META-INF/MANIFEST.MF" targetInArchive="/META-INF/MANIFEST.MF"/>
<archive targetInArchive="/WEB-INF/lib/domain-1.jar">
<dir sourceOnDisk="/home/tjwatson/dev/liberty/examples/openliberty-multi-app-deploy/domain/target/classes" targetInArchive="/"/>
<file sourceOnDisk="/home/tjwatson/dev/liberty/examples/openliberty-multi-app-deploy/domain/target/tmp/META-INF/MANIFEST.MF" targetInArchive="/META-INF/MANIFEST.MF"/>
</archive>
<archive targetInArchive="/WEB-INF/lib/jpa-1.jar">
<dir sourceOnDisk="/home/tjwatson/dev/liberty/examples/openliberty-multi-app-deploy/jpa/target/classes" targetInArchive="/"/>
<file sourceOnDisk="/home/tjwatson/dev/liberty/examples/openliberty-multi-app-deploy/jpa/target/tmp/META-INF/MANIFEST.MF" targetInArchive="/META-INF/MANIFEST.MF"/>
</archive>
<file sourceOnDisk="/home/tjwatson/.m2/repository/org/slf4j/slf4j-api/2.0.16/slf4j-api-2.0.16.jar" targetInArchive="/WEB-INF/lib/slf4j-api-2.0.16.jar"/>
<file sourceOnDisk="/home/tjwatson/.m2/repository/ch/qos/logback/logback-classic/1.5.12/logback-classic-1.5.12.jar" targetInArchive="/WEB-INF/lib/logback-classic-1.5.12.jar"/>
<file sourceOnDisk="/home/tjwatson/.m2/repository/ch/qos/logback/logback-core/1.5.12/logback-core-1.5.12.jar" targetInArchive="/WEB-INF/lib/logback-core-1.5.12.jar"/>
</archive>
It still has entries for the domain and jpa JARs even though they are also in the We will need to move this issue over to liberty maven plugin. |
If you want to see it "work" then you can copy the produced EAR file Then you can start the server (without using mvn) with: |
Thanks for the investigation @tjwatson . Just searching the code quickly I can see that our loose app deployment seems to have support for the It seems worth moving the issue over to our liberty-maven-plugin repo (which I did) then to investigate further. Thanks. |
@tjwatson @scottkurz thanks for your investigations! I can confirm it works as expected if I don't use the liberty-maven-plugin and manually start OpenLiberty, as suggested by @scottkurz. |
And note it is still possible to use liberty-maven-plugin to deploy with loose app disabled, (either |
For the time being, I'd love to have some hints on this. I tried writing some convenience scripts to speed up the build + restart Open Liberty cycle, but the feedback loop is considerably shorter than when I use From what I understand, I guess it starts with setting |
Could you consider using |
I don't use RARs or EJBs in my project, and I don't plan to use them, so it shouldn't be a problem. However, I've just tried to replace
And both applications don't get deployed. The contents of the EAR look good, though, and as you can see, SLF4J is indeed in the lib/ folder of the EAR:
|
Does that happen with the produced EAR archive also? If so then my understanding of how skinnyWars works for the maven EAR production is not correct and you would need to continue to use skinnyModules. If the EAR archive works vs. the loose application XML then this indicates a separate issue with how the liberty maven plugin handles skinnyWars. |
Oops, I noticed I didn't set <archive targetInArchive="/lib//it.mulders.ol-domain-1.jar"> Notice the double / in the path! I then checked the This improves the feedback cycle already, as I now only have to run So to summarise, I went from Am I missing something? |
If you've switched from skinnyModules=true to skinnyWars=true then you should be able to use loose apps (which defaults to true). This seemed to work fine when I tested your recreate app repo. Though I'm a bit confused because I noticed it seemed to work just fine for me on the initial commit too (back when the jpa-1 JAR was packaged within each WAR). I wonder if there is some other variable or condition in the use case required to recreate the problem, and/or maybe there's something related to the CDI scope in play? It's also possible that my inability to recreate really doesn't matter, ultimately, with any of the points discussed here.. (but thought it was worth mentioning). |
Sorry for not getting back earlier.
I've just tried to do this. In the reproducer that I shared, it seems to work. But in a larger project (which is also open source, but because it's so large I first created a small reproducer) it still doesn't work. As far as I can tell, all relevant Maven and OpenLiberty configuration is the same in both projects.
|
Thanks for responding. OK, fair enough. It just concerned me that we might be missing something without recreating that first step, but in any case, it's clear the loose app deployment for skinnyModules looks incorrect as noted. So since @tjwatson seemed to make the link from this incorrect structure to a potential classloader problem, I think we have enough detail to address this problem in the liberty-maven-plugin deploy code. |
Describe the bug
I have a project that contains a web application and a JAX-RS API, packaged together in an EAR. Both consume a shared library that is built with JPA. Running the applications yields a runtime exception in the web app or the API, but I cannot predict in which one.
The error is this:
Full stack trace:
Steps to Reproduce
mvn liberty:dev
.Expected behavior
Two WAR modules inside an EAR can share JPA-based code without interfering with each other.
Diagnostic information:
$WLP_OUTPUT_DIR/messages.log
Additional context
I have added some debug logging in the code that leverages JPA and I noticed this:
Invocation from the web app
Invocation from the API
I think it is interesting to note that the error message from the web app refers to the classloader from the API.
The text was updated successfully, but these errors were encountered: