java - Flink does not run my appliation due to invalidtypesexception when using java8 lambdas -
i using flink , java8. when using lambda functions tuples , generic types, compiler ends exception
/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/bin/java -didea.launcher.port=7536 "-didea.launcher.bin.path=/applications/intellij idea.app/contents/bin" -dfile.encoding=utf-8 -classpath "/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/charsets.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/deploy.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/ext/cldrdata.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/ext/dnsns.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/ext/jaccess.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/ext/jfxrt.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/ext/localedata.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/ext/nashorn.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/ext/sunec.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/ext/sunjce_provider.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/ext/sunpkcs11.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/ext/zipfs.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/javaws.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/jce.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/jfr.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/jfxswt.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/jsse.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/management-agent.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/plugin.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/resources.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/jre/lib/rt.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/lib/ant-javafx.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/lib/dt.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/lib/javafx-mx.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/lib/jconsole.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/lib/packager.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/lib/sa-jdi.jar:/library/java/javavirtualmachines/jdk1.8.0_102.jdk/contents/home/lib/tools.jar:/users/hasan.guercan/git/flink-java-project/target/classes:/users/hasan.guercan/.m2/repository/org/apache/flink/flink-java/1.0.3/flink-java-1.0.3.jar:/users/hasan.guercan/.m2/repository/org/apache/flink/flink-core/1.0.3/flink-core-1.0.3.jar:/users/hasan.guercan/.m2/repository/org/apache/flink/flink-annotations/1.0.3/flink-annotations-1.0.3.jar:/users/hasan.guercan/.m2/repository/com/esotericsoftware/kryo/kryo/2.24.0/kryo-2.24.0.jar:/users/hasan.guercan/.m2/repository/com/esotericsoftware/minlog/minlog/1.2/minlog-1.2.jar:/users/hasan.guercan/.m2/repository/org/objenesis/objenesis/2.1/objenesis-2.1.jar:/users/hasan.guercan/.m2/repository/org/apache/avro/avro/1.7.6/avro-1.7.6.jar:/users/hasan.guercan/.m2/repository/org/apache/flink/flink-shaded-hadoop2/1.0.3/flink-shaded-hadoop2-1.0.3.jar:/users/hasan.guercan/.m2/repository/xmlenc/xmlenc/0.52/xmlenc-0.52.jar:/users/hasan.guercan/.m2/repository/commons-codec/commons-codec/1.4/commons-codec-1.4.jar:/users/hasan.guercan/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar:/users/hasan.guercan/.m2/repository/commons-net/commons-net/3.1/commons-net-3.1.jar:/users/hasan.guercan/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/users/hasan.guercan/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar:/users/hasan.guercan/.m2/repository/org/mortbay/jetty/jetty-util/6.1.26/jetty-util-6.1.26.jar:/users/hasan.guercan/.m2/repository/com/sun/jersey/jersey-core/1.9/jersey-core-1.9.jar:/users/hasan.guercan/.m2/repository/commons-el/commons-el/1.0/commons-el-1.0.jar:/users/hasan.guercan/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:/users/hasan.guercan/.m2/repository/com/jamesmurty/utils/java-xmlbuilder/0.4/java-xmlbuilder-0.4.jar:/users/hasan.guercan/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/users/hasan.guercan/.m2/repository/commons-configuration/commons-configuration/1.7/commons-configuration-1.7.jar:/users/hasan.guercan/.m2/repository/commons-digester/commons-digester/1.8.1/commons-digester-1.8.1.jar:/users/hasan.guercan/.m2/repository/org/codehaus/jackson/jackson-core-asl/1.8.8/jackson-core-asl-1.8.8.jar:/users/hasan.guercan/.m2/repository/org/codehaus/jackson/jackson-mapper-asl/1.8.8/jackson-mapper-asl-1.8.8.jar:/users/hasan.guercan/.m2/repository/com/thoughtworks/paranamer/paranamer/2.3/paranamer-2.3.jar:/users/hasan.guercan/.m2/repository/org/xerial/snappy/snappy-java/1.0.5/snappy-java-1.0.5.jar:/users/hasan.guercan/.m2/repository/com/jcraft/jsch/0.1.42/jsch-0.1.42.jar:/users/hasan.guercan/.m2/repository/org/apache/zookeeper/zookeeper/3.4.6/zookeeper-3.4.6.jar:/users/hasan.guercan/.m2/repository/io/netty/netty/3.7.0.final/netty-3.7.0.final.jar:/users/hasan.guercan/.m2/repository/org/apache/commons/commons-compress/1.4.1/commons-compress-1.4.1.jar:/users/hasan.guercan/.m2/repository/org/tukaani/xz/1.0/xz-1.0.jar:/users/hasan.guercan/.m2/repository/commons-beanutils/commons-beanutils-bean-collections/1.8.3/commons-beanutils-bean-collections-1.8.3.jar:/users/hasan.guercan/.m2/repository/commons-daemon/commons-daemon/1.0.13/commons-daemon-1.0.13.jar:/users/hasan.guercan/.m2/repository/javax/xml/bind/jaxb-api/2.2.2/jaxb-api-2.2.2.jar:/users/hasan.guercan/.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar:/users/hasan.guercan/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar:/users/hasan.guercan/.m2/repository/com/google/inject/guice/3.0/guice-3.0.jar:/users/hasan.guercan/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/users/hasan.guercan/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/users/hasan.guercan/.m2/repository/org/apache/commons/commons-math3/3.5/commons-math3-3.5.jar:/users/hasan.guercan/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar:/users/hasan.guercan/.m2/repository/org/slf4j/slf4j-log4j12/1.7.7/slf4j-log4j12-1.7.7.jar:/users/hasan.guercan/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar:/users/hasan.guercan/.m2/repository/org/apache/flink/force-shading/1.0.3/force-shading-1.0.3.jar:/users/hasan.guercan/.m2/repository/org/apache/flink/flink-streaming-java_2.10/1.0.3/flink-streaming-java_2.10-1.0.3.jar:/users/hasan.guercan/.m2/repository/org/apache/flink/flink-runtime_2.10/1.0.3/flink-runtime_2.10-1.0.3.jar:/users/hasan.guercan/.m2/repository/io/netty/netty-all/4.0.27.final/netty-all-4.0.27.final.jar:/users/hasan.guercan/.m2/repository/org/javassist/javassist/3.18.2-ga/javassist-3.18.2-ga.jar:/users/hasan.guercan/.m2/repository/org/scala-lang/scala-library/2.10.4/scala-library-2.10.4.jar:/users/hasan.guercan/.m2/repository/com/typesafe/akka/akka-actor_2.10/2.3.7/akka-actor_2.10-2.3.7.jar:/users/hasan.guercan/.m2/repository/com/typesafe/config/1.2.1/config-1.2.1.jar:/users/hasan.guercan/.m2/repository/com/typesafe/akka/akka-remote_2.10/2.3.7/akka-remote_2.10-2.3.7.jar:/users/hasan.guercan/.m2/repository/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar:/users/hasan.guercan/.m2/repository/org/uncommons/maths/uncommons-maths/1.2.2a/uncommons-maths-1.2.2a.jar:/users/hasan.guercan/.m2/repository/com/typesafe/akka/akka-slf4j_2.10/2.3.7/akka-slf4j_2.10-2.3.7.jar:/users/hasan.guercan/.m2/repository/org/clapper/grizzled-slf4j_2.10/1.0.2/grizzled-slf4j_2.10-1.0.2.jar:/users/hasan.guercan/.m2/repository/com/github/scopt/scopt_2.10/3.2.0/scopt_2.10-3.2.0.jar:/users/hasan.guercan/.m2/repository/io/dropwizard/metrics/metrics-core/3.1.0/metrics-core-3.1.0.jar:/users/hasan.guercan/.m2/repository/io/dropwizard/metrics/metrics-jvm/3.1.0/metrics-jvm-3.1.0.jar:/users/hasan.guercan/.m2/repository/io/dropwizard/metrics/metrics-json/3.1.0/metrics-json-3.1.0.jar:/users/hasan.guercan/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.4.2/jackson-databind-2.4.2.jar:/users/hasan.guercan/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.4.0/jackson-annotations-2.4.0.jar:/users/hasan.guercan/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.4.2/jackson-core-2.4.2.jar:/users/hasan.guercan/.m2/repository/com/twitter/chill_2.10/0.7.4/chill_2.10-0.7.4.jar:/users/hasan.guercan/.m2/repository/com/twitter/chill-java/0.7.4/chill-java-0.7.4.jar:/users/hasan.guercan/.m2/repository/org/apache/commons/commons-math/2.2/commons-math-2.2.jar:/users/hasan.guercan/.m2/repository/org/apache/sling/org.apache.sling.commons.json/2.0.6/org.apache.sling.commons.json-2.0.6.jar:/users/hasan.guercan/.m2/repository/org/apache/flink/flink-clients_2.10/1.0.3/flink-clients_2.10-1.0.3.jar:/users/hasan.guercan/.m2/repository/org/apache/flink/flink-optimizer_2.10/1.0.3/flink-optimizer_2.10-1.0.3.jar:/users/hasan.guercan/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/users/hasan.guercan/.m2/repository/org/apache/commons/commons-lang3/3.0.1/commons-lang3-3.0.1.jar:/applications/intellij idea.app/contents/lib/idea_rt.jar" com.intellij.rt.execution.application.appmain org.apache.flink.quickstart.exercise2.replygraph exception in thread "main" org.apache.flink.api.common.functions.invalidtypesexception: return type of function 'retrieve(replygraph.java:33)' not determined automatically, due type erasure. can give type information hints using returns(...) method on result of transformation call, or letting function implement 'resulttypequeryable' interface. @ org.apache.flink.api.java.dataset.gettype(dataset.java:178) @ org.apache.flink.api.java.dataset.collect(dataset.java:407) @ org.apache.flink.api.java.dataset.print(dataset.java:1605) @ org.apache.flink.quickstart.exercise2.replygraph.retrieve(replygraph.java:41) @ org.apache.flink.quickstart.exercise2.replygraph.main(replygraph.java:56) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ com.intellij.rt.execution.application.appmain.main(appmain.java:147) caused by: org.apache.flink.api.common.functions.invalidtypesexception: generic type parameters of 'tuple3' missing. seems compiler has not stored them .class file. currently, eclipse jdt compiler preserves type information necessary use lambdas feature type-safely. see documentation more information how compile jobs containing lambda expressions. @ org.apache.flink.api.java.typeutils.typeextractor.validatelambdagenericparameter(typeextractor.java:1316) @ org.apache.flink.api.java.typeutils.typeextractor.validatelambdagenericparameters(typeextractor.java:1302) @ org.apache.flink.api.java.typeutils.typeextractor.getunaryoperatorreturntype(typeextractor.java:346) @ org.apache.flink.api.java.typeutils.typeextractor.getunaryoperatorreturntype(typeextractor.java:304) @ org.apache.flink.api.java.typeutils.typeextractor.getmapreturntypes(typeextractor.java:119) @ org.apache.flink.api.java.dataset.map(dataset.java:215) @ org.apache.flink.quickstart.exercise2.replygraph.retrieve(replygraph.java:33) ... 6 more
so have create @ least anonymous class solve problem. first code snippet represents code leads described exception:
dataset<mailentry> filtereduserreplymails = replymails.filter(entrytuple -> { string sender = entrytuple.getfield(1).tostring(); return !sender.contains("git@") && !sender.contains("jira@"); }).map((entry -> { mailentry mailentry = new mailentry(); mailentry.messageid = entry.f0.replaceall("<", "").replaceall(">", ""); mailentry.sender = entry.f1; mailentry.replyto = entry.f2; return mailentry; });
next 1 working when creating anonymous class:
dataset<mailentry> filtereduserreplymails = replymails.filter(entrytuple -> { string sender = entrytuple.getfield(1).tostring(); return !sender.contains("git@") && !sender.contains("jira@"); }).map(new mapfunction<tuple3<string, string, string>, mailentry>() { @override public mailentry map(tuple3<string, string, string> entry) throws exception { mailentry mailentry = new mailentry(); mailentry.messageid = entry.f0.replaceall("<", "").replaceall(">", ""); mailentry.sender = entry.f1; mailentry.replyto = entry.f2; return mailentry; } });
javas lambda function neat. how can solve problem without creating anonymous class?
try use returns method after map:
dataset<mailentry> filtereduserreplymails = replymails.filter(entrytuple -> { string sender = entrytuple.getfield(1).tostring(); return !sender.contains("git@") && !sender.contains("jira@"); }).map(entry -> { mailentry mailentry = new mailentry(); mailentry.messageid = entry.f0.replaceall("<", "").replaceall(">", ""); mailentry.sender = entry.f1; mailentry.replyto = entry.f2; return mailentry; }).returns(mailentry.class);
Comments
Post a Comment