Re: IllegalAccessError when writing to hive orc table

Posted by Jingsong Li on
URL: http://deprecated-apache-flink-user-mailing-list-archive.369.s1.nabble.com/IllegalAccessError-when-writing-to-hive-orc-table-tp36579p36611.html

Hi Paul,

> In my deployment, the hive connector (and its orc dependencies), which contains `DefaultBucketFactoryImpl`, was packaged into the job uber jar.  On the other hand, the flink runtime, which contains `HadoopPathBasedBulkFormatBuilder ` is located in the lib folder. Since the two jars are loaded by different class loaders, the classes are considered under different packages. That’s why an `java.lang.IllegalAccessError` occurred.

Thanks for your analysis, hive contains `HadoopPathBasedBulkFormatBuilder` and runtime contains `DefaultBucketFactoryImpl`. Looks like it is dangerous to use package constraints for different modules. It is better to use public. CC: [hidden email] 

> the artifact links of the hive connectors seem to be broken. Should we use https://repo.maven.apache.org/maven2/ instead?

Yes, we should use new URLs. I created https://issues.apache.org/jira/browse/FLINK-18593 JIRA for tracking this.

Best,
Jingsong 

On Tue, Jul 14, 2020 at 12:15 PM Paul Lam <[hidden email]> wrote:
Hi Jingsong,

Thanks to your pointer, I checked the dependencies and found out that it’s caused by the classloaders.

In my deployment, the hive connector (and its orc dependencies), which contains `DefaultBucketFactoryImpl`, was packaged into the job uber jar.  On the other hand, the flink runtime, which contains `HadoopPathBasedBulkFormatBuilder ` is located in the lib folder. Since the two jars are loaded by different class loaders, the classes are considered under different packages. That’s why an `java.lang.IllegalAccessError` occurred.

BTW, the artifact links of the hive connectors seem to be broken. Should we use https://repo.maven.apache.org/maven2/ instead?

Best,
Paul Lam

2020年7月13日 18:02,Jingsong Li <[hidden email]> 写道:

Hi, It looks really weird.

Is there any possibility of class conflict?
How do you manage your dependencies? Do you download bundle-jar to lib? [1]


Best,
Jingsong

On Mon, Jul 13, 2020 at 5:48 PM Paul Lam <[hidden email]> wrote:
Hi,

I’m trying out Flink 1.11 and trying to write data to Hive orc tables, but get stuck with a weird exception. Wonder if anyone had met this before?  The Java version is 1.8.0_151.

java.lang.IllegalAccessError: tried to access class org.apache.flink.streaming.api.functions.sink.filesystem.DefaultBucketFactoryImpl from class org.apache.flink.streaming.api.functions.sink.filesystem.HadoopPathBasedBulkFormatBuilder
	at org.apache.flink.streaming.api.functions.sink.filesystem.HadoopPathBasedBulkFormatBuilder.<init>(HadoopPathBasedBulkFormatBuilder.java:70)
	at org.apache.flink.connectors.hive.HiveTableSink.consumeDataStream(HiveTableSink.java:197)
	at org.apache.flink.table.planner.plan.nodes.physical.stream.StreamExecLegacySink.translateToPlanInternal(StreamExecLegacySink.scala:114)
	at org.apache.flink.table.planner.plan.nodes.physical.stream.StreamExecLegacySink.translateToPlanInternal(StreamExecLegacySink.scala:48)
	at org.apache.flink.table.planner.plan.nodes.exec.ExecNode$class.translateToPlan(ExecNode.scala:58)
	at org.apache.flink.table.planner.plan.nodes.physical.stream.StreamExecLegacySink.translateToPlan(StreamExecLegacySink.scala:48)
	at org.apache.flink.table.planner.delegation.StreamPlanner$$anonfun$translateToPlan$1.apply(StreamPlanner.scala:67)
	at org.apache.flink.table.planner.delegation.StreamPlanner$$anonfun$translateToPlan$1.apply(StreamPlanner.scala:66)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
	at scala.collection.Iterator$class.foreach(Iterator.scala:891)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
	at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
	at scala.collection.AbstractTraversable.map(Traversable.scala:104)
	at org.apache.flink.table.planner.delegation.StreamPlanner.translateToPlan(StreamPlanner.scala:66)
	at org.apache.flink.table.planner.delegation.PlannerBase.translate(PlannerBase.scala:166)
	at org.apache.flink.table.api.internal.TableEnvironmentImpl.translate(TableEnvironmentImpl.java:1248)
	at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeInternal(TableEnvironmentImpl.java:694)
	at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeOperation(TableEnvironmentImpl.java:781)
	at org.apache.flink.table.api.internal.TableEnvironmentImpl.executeSql(TableEnvironmentImpl.java:684)
	at com.netease.nie.gdc.streamfly.JobEntry.main(JobEntry.java:62)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:288)
	at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:198)
	at org.apache.flink.client.ClientUtils.executeProgram(ClientUtils.java:149)
	at org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:699)
	at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:232)
	at org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:916)
	at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:992)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:422)
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1707)
	at org.apache.flink.runtime.security.contexts.HadoopSecurityContext.runSecured(HadoopSecurityContext.java:41)
	at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:992)
Best,
Paul Lam



--
Best, Jingsong Lee



--
Best, Jingsong Lee