Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.17.0
-
None
-
None
Description
When exposing connection created by Calcite through OSGI to another bundle - class not found it thrown everywhere from code as following:
ICompilerFactory compilerFactory; try { compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(); } catch (Exception e) { throw new IllegalStateException( "Unable to instantiate java compiler", e); }
This is because org.codehaus.commons.compiler.CompilerFactoryFactory uses classloader from current thread, where in OSGI exposed to different bundles thread classloader may not reach valid janino or org.codehaus.commons.compiler, appropriate for Calcite version (or at all).
I would suggest changing the mentioned code with additional fallback:
ICompilerFactory compilerFactory; try { compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory(); } catch (ClassNotFoundException e) { compilerFactory = new org.codehaus.janino.CompilerFactory(); } catch (Exception e) { throw new IllegalStateException( "Unable to instantiate java compiler", e); }
Change in:
- EnumerableInterpretable.getBindable(ClassDeclaration, String, int)
- JaninoRexCompiler.getScalar(ClassDeclaration, String)
- JaninoRelMetadataProvider.compile(String, String, MetadataDef<M>, List<Object>)
This should clear the way between calcite and an osgi world
When accepted I will make a pull request.