[ 
https://issues.apache.org/jira/browse/PHOENIX-3299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15726498#comment-15726498
 ] 

Josh Elser commented on PHOENIX-3299:
-------------------------------------

bq. But it you instantiate an object, then ask it its class name or package 
name, it will return the shaded path

This is definitely the right idea in spirit but we're dealing with code we 
don't "own" which makes it harder.

Pulled up the code from commons-compiler:

{noformat}
    public static ICompilerFactory
    getDefaultCompilerFactory() throws Exception {
        if (CompilerFactoryFactory.defaultCompilerFactory == null) {
            Properties  properties = new Properties();
            InputStream is         = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(
                "org.codehaus.commons.compiler.properties"
            );
            if (is == null) {
                throw new ClassNotFoundException(
                    "No implementation of org.codehaus.commons.compiler is on 
the class path. Typically, you'd have "
                    + "'janino.jar', or 'commons-compiler-jdk.jar', or both on 
the classpath."
                );
            }
            try {
                properties.load(is);
            } finally {
                is.close();
            }
            String compilerFactoryClassName = 
properties.getProperty("compilerFactory");
            CompilerFactoryFactory.defaultCompilerFactory = (
                
CompilerFactoryFactory.getCompilerFactory(compilerFactoryClassName)
            );
        }
        return CompilerFactoryFactory.defaultCompilerFactory;
    }
{noformat}

So, I'm guessing that if we mangle together a correct 
{{org.codehaus.commons.compiler.properties}} with the correct contents in our 
shaded jar, we could make this work.

[~maryannxue], I'd say let it boil down to the amount of time/effort (or maybe 
blood/sweat/tears) that you want to invest in trying to unwrap this. I think 
just adding an exclusion for commons-compiler/janino classes would be OK for a 
workaround (as I'd guess the likelihood of having multiples of those on the 
classpath is low).

> Janino could not work in shaded package
> ---------------------------------------
>
>                 Key: PHOENIX-3299
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3299
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.8.0
>            Reporter: Maryann Xue
>            Assignee: Maryann Xue
>
> Calcite-Phoenix would encounter this ClassNotFoundException when trying to 
> initiate its compiler. It was caused by putting janino into shaded packages.
> {code}
> imit 100": Unable to instantiate java compiler
>       at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
>       at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
>       at 
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:147)
>       at 
> org.apache.calcite.avatica.AvaticaStatement.execute(AvaticaStatement.java:199)
>       at sqlline.Commands.execute(Commands.java:822)
>       at sqlline.Commands.sql(Commands.java:732)
>       at sqlline.SqlLine.dispatch(SqlLine.java:807)
>       at sqlline.SqlLine.runCommands(SqlLine.java:1710)
>       at sqlline.Commands.run(Commands.java:1285)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:606)
>       at 
> sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:36)
>       at sqlline.SqlLine.dispatch(SqlLine.java:803)
>       at sqlline.SqlLine.initArgs(SqlLine.java:613)
>       at sqlline.SqlLine.begin(SqlLine.java:656)
>       at sqlline.SqlLine.start(SqlLine.java:398)
>       at sqlline.SqlLine.main(SqlLine.java:292)
> Caused by: java.lang.IllegalStateException: Unable to instantiate java 
> compiler
>       at 
> org.apache.calcite.rel.metadata.JaninoRelMetadataProvider.compile(JaninoRelMetadataProvider.java:417)
>       at 
> org.apache.calcite.rel.metadata.JaninoRelMetadataProvider.load3(JaninoRelMetadataProvider.java:358)
>       at 
> org.apache.calcite.rel.metadata.JaninoRelMetadataProvider.access$000(JaninoRelMetadataProvider.java:94)
>       at 
> org.apache.calcite.rel.metadata.JaninoRelMetadataProvider$1.load(JaninoRelMetadataProvider.java:113)
>       at 
> org.apache.calcite.rel.metadata.JaninoRelMetadataProvider$1.load(JaninoRelMetadataProvider.java:110)
>       at 
> com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3589)
>       at 
> com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2374)
>       at 
> com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2337)
>       at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2252)
>       at com.google.common.cache.LocalCache.get(LocalCache.java:3990)
>       at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3994)
>       at 
> com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4878)
>       at 
> org.apache.calcite.rel.metadata.JaninoRelMetadataProvider.create(JaninoRelMetadataProvider.java:448)
>       at 
> org.apache.calcite.rel.metadata.JaninoRelMetadataProvider.revise(JaninoRelMetadataProvider.java:460)
>       at 
> org.apache.calcite.rel.metadata.RelMetadataQuery.revise(RelMetadataQuery.java:186)
>       at 
> org.apache.calcite.rel.metadata.RelMetadataQuery.collations(RelMetadataQuery.java:484)
>       at 
> org.apache.calcite.rel.metadata.RelMdCollation.filter(RelMdCollation.java:187)
>       at 
> org.apache.calcite.rel.logical.LogicalFilter$2.get(LogicalFilter.java:115)
>       at 
> org.apache.calcite.rel.logical.LogicalFilter$2.get(LogicalFilter.java:113)
>       at org.apache.calcite.plan.RelTraitSet.replaceIfs(RelTraitSet.java:238)
>       at 
> org.apache.calcite.rel.logical.LogicalFilter.create(LogicalFilter.java:111)
>       at 
> org.apache.calcite.rel.logical.LogicalFilter.create(LogicalFilter.java:103)
>       at 
> org.apache.calcite.rel.core.RelFactories$FilterFactoryImpl.createFilter(RelFactories.java:225)
>       at org.apache.calcite.plan.RelOptUtil.createFilter(RelOptUtil.java:595)
>       at org.apache.calcite.plan.RelOptUtil.createFilter(RelOptUtil.java:581)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertWhere(SqlToRelConverter.java:966)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:644)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:622)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:2852)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2036)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:1914)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:1952)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:1910)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:1994)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:1994)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:641)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:622)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:2852)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:556)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertWith(SqlToRelConverter.java:3550)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:2866)
>       at 
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:556)
>       at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:228)
>       at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:193)
>       at 
> org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:733)
>       at 
> org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:597)
>       at 
> org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:567)
>       at 
> org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:215)
>       at 
> org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:594)
>       at 
> org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:613)
>       at 
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:139)
>       ... 16 more
> Caused by: java.lang.ClassNotFoundException: No implementation of 
> org.codehaus.commons.compiler is on the class path. Typically, you'd have 
> 'janino.jar', or 'commons-compiler-jdk.jar', or both on the classpath.
>       at 
> org.apache.phoenix.shaded.org.codehaus.commons.compiler.CompilerFactoryFactory.getDefaultCompilerFactory(CompilerFactoryFactory.java:59)
>       at 
> org.apache.calcite.rel.metadata.JaninoRelMetadataProvider.compile(JaninoRelMetadataProvider.java:415)
>       ... 66 more
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to