Skip to content
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

For OSGI, it is necessary to redo the system for determining the current ClassLoader #404

Open
alexinsmail opened this issue Nov 28, 2023 · 0 comments

Comments

@alexinsmail
Copy link

For OSGI, it is necessary to redo the system for determining the current ClassLoader.

The construction is almost universally used

ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

For OSGI, this does not work correctly.
Each OSGI Bundle has its own ClassLoader that protects the private part from outsiders.
The logical solution is to transfer the ClassLoader to the local JasperReportsContext.

It is necessary to find all the methods where the above construction is used.
All resources and classes must be raised using JRClassLoader.
JRClassLoader should get the current ClassLoader from JasperReportsContext.

If you haven't installed ClassLoader in JasperReportsContext, you should use the above construction.

In JRGroovyCompiler, when creating a GroovyClassLoader, it is necessary to give the ClassLoader from JasperReportsContext.
Old code

CompilationUnit unit = new CompilationUnit(config);

New code

ClassLoader classLoader = jasperReportsContext.getDefaultClassLoader();
GroovyClassLoader groovyClassLoader = new GroovyClassLoader(classLoader, config);
CompilationUnit unit = new CompilationUnit(config, null, groovyClassLoader);

By default, groovy does not see JasperReport classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant