we have a strange behaviour in a barely new downloaded TomEE Application Server. Our Situation: We have running two applications (lets call it v1 and v2) which provide us some pdf files by a REST API which uses JasperReports. As we released v1 everything worked fine.
As we updated some internal code and released it as v2 the chaos began... (The changes in our code are barely not the origin of our problem, these are only calculating changes.)
Our chaos is, that when we access our code in v1 first, our Reports gets provided fine by v1 API. When we try to get our new Report from v2 API, we run into a class not Found Exception.
Exception in thread "AsyncFileHandlerWriter-2081853534" java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.extensions.ExtensionsEnvironment
at net.sf.jasperreports.engine.DefaultJasperReportsContext.getExtensions(DefaultJasperReportsContext.java:277)
at net.sf.jasperreports.engine.util.MessageUtil.getMessageProvider(MessageUtil.java:70)
at net.sf.jasperreports.engine.JRRuntimeException.resolveMessage(JRRuntimeException.java:166)
at net.sf.jasperreports.engine.JRRuntimeException.getMessage(JRRuntimeException.java:147)
at net.sf.jasperreports.engine.JRRuntimeException.getMessage(JRRuntimeException.java:138)
at java.base/java.lang.Throwable.getLocalizedMessage(Throwable.java:396)
at java.base/java.lang.Throwable.toString(Throwable.java:485)
at java.base/java.lang.String.valueOf(String.java:2801)
at java.base/java.lang.StringBuilder.append(StringBuilder.java:135)
at java.base/java.lang.Throwable.printEnclosedStackTrace(Throwable.java:699)
at java.base/java.lang.Throwable.printEnclosedStackTrace(Throwable.java:713)
at java.base/java.lang.Throwable.printStackTrace(Throwable.java:671)
at java.base/java.lang.Throwable.printStackTrace(Throwable.java:725)
at org.apache.juli.OneLineFormatter.format(OneLineFormatter.java:150)
at org.apache.juli.FileHandler.publish(FileHandler.java:294)
at org.apache.juli.AsyncFileHandler.publishInternal(AsyncFileHandler.java:146)
at org.apache.juli.AsyncFileHandler$LogEntry.flush(AsyncFileHandler.java:185)
at org.apache.juli.AsyncFileHandler$LoggerThread.run(AsyncFileHandler.java:161)
That far we thought about missing dependencys or missing libs, but: When we acces v2 API first, we get same Error in our v1 API.
So it seems that the API-Application which gets called first "binds" the JasperStuff and die other API cannot access it. We are actually ended with our knowledge and we hope we can get som help here.
A little Background information: We use a core package which provides some core functionality like DB-Access and JDNI Resources, CORS Filter and Security Interfaces. I don't think that core package (provided in each war separately) causes some chaos, but due to the fact that we have amongst other things 2 JDNI resources with the same name (but in diffrent applications and so in diffrent context) i think i need to leave this informatoin here.
Thank you in advance for your help.
So after struggeling a bit around and trying diffrent ways to solve the problem we finally found a working solution: We included our JasperReports (and necessary depending) libs to tomcats common.loader
property.
The effect is, that we do not have concurring JasperReports libs (altough they're same version). It is a little confusing for me that this should be the reason, but it brings us the expected result.
The hint to do so was the AsyncFileHandlerWriter
and the "feeling" that the first used context could work fine with the JasperReports libs. It felt a little bit like context concurrency but to be honest we're not sure if this is the correct solution or just a workaround for an underlaying problem.
If someone has further hints we appreciate every hint! Thanks in advance.