Flink sql 异常踩坑帖

1.Static methods in interface require -target:jvm-1.8

解决方案:在pom中修改,参考:https://blog.csdn.net/YongDaiMe/article/details/108586263,在scala打包插件中增加-target :jvm-1.8配置。

<plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>scala-compile-first</id>
            <phase>process-resources</phase>
            <goals>
                <goal>add-source</goal>
                <goal>compile</goal>
            </goals>
            <configuration>
                <addScalacArgs>-target:jvm-1.8</addScalacArgs>
            </configuration>
        </execution>
        <execution>
            <id>scala-test-compile</id>
            <phase>test-compile</phase>
            <goals>
                <goal>testCompile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

2、java和scala代码同时开发遇到打包java代码丢失问题,同步增加java和scala两个打包插件

参考:https://cloud.tencent.com/developer/article/1613727

<build>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-shade-plugin</artifactId>
			<version>2.3</version>
			<executions>
				<execution>
					<phase>package</phase>
					<goals>
						<goal>shade</goal>
					</goals>
					<configuration>
						<artifactSet>
							<excludes>
								<exclude>org.apache.flink:*</exclude>
								<exclude>org.slf4j:*</exclude>
								<exclude>log4j:*</exclude>
							</excludes>
						</artifactSet>
						<transformers>
							<transformer
									implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
								<mainClass>XXX.XXX.XXX.XXX.DataParsingWorker</mainClass>  <!--这里运行类! -->
							</transformer>
						</transformers>
					</configuration>
				</execution>
			</executions>
		</plugin>
		<plugin>
			<groupId>net.alchim31.maven</groupId>
			<artifactId>scala-maven-plugin</artifactId>
			<executions>
				<execution>
					<id>scala-compile</id>
					<phase>compile</phase>
					<goals>
						<goal>add-source</goal>
						<goal>compile</goal>
					</goals>
				</execution>
				<execution>
					<id>scala-test-compile</id>
					<phase>test-compile</phase>
					<goals>
						<goal>testCompile</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
		<plugin>
			<artifactId>maven-compiler-plugin</artifactId>
			<executions>
				<execution>
					<id>default-compile</id>
					<phase>none</phase>
				</execution>
				<execution>
					<id>default-testCompile</id>
					<phase>none</phase>
				</execution>
			</executions>
		</plugin>

		<!-- Eclipse Scala Integration -->
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-eclipse-plugin</artifactId>
			<version>2.8</version>
			<configuration>
				<downloadSources>true</downloadSources>
				<projectnatures>
					<projectnature>org.scala-ide.sdt.core.scalanature</projectnature>
					<projectnature>org.eclipse.jdt.core.javanature</projectnature>
				</projectnatures>
				<buildcommands>
					<buildcommand>org.scala-ide.sdt.core.scalabuilder</buildcommand>
				</buildcommands>
				<classpathContainers>
					<classpathContainer>org.scala-ide.sdt.launching.SCALA_CONTAINER</classpathContainer>
					<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
				</classpathContainers>
				<excludes>
					<exclude>org.scala-lang:scala-library</exclude>
					<exclude>org.scala-lang:scala-compiler</exclude>
				</excludes>
				<sourceIncludes>
					<sourceInclude>**/*.scala</sourceInclude>
					<sourceInclude>**/*.java</sourceInclude>
				</sourceIncludes>
			</configuration>
		</plugin>
		<plugin>
			<groupId>org.codehaus.mojo</groupId>
			<artifactId>build-helper-maven-plugin</artifactId>
			<version>1.7</version>
			<executions>
				<!-- Add src/main/scala to eclipse build path -->
				<execution>
					<id>add-source</id>
					<phase>generate-sources</phase>
					<goals>
						<goal>add-source</goal>
					</goals>
					<configuration>
						<sources>
							<source>src/main/scala</source>
						</sources>
					</configuration>
				</execution>
				<!-- Add src/test/scala to eclipse build path -->
				<execution>
					<id>add-test-source</id>
					<phase>generate-test-sources</phase>
					<goals>
						<goal>add-test-source</goal>
					</goals>
					<configuration>
						<sources>
							<source>src/test/scala</source>
						</sources>
					</configuration>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

3、exited with a non-zero exit code 1. Error file: prelaunch.err.

flink 创建yarn per-job模式时报错,修改yarn-site.xml 增加如下配置。参考:https://blog.csdn.net/colby_chenlun/article/details/106452034

<!--新版本指定文件-->
    <property>
        <name>yarn.resourcemanager.webapp.address.rm1</name>
        <value>hadoop102</value>
    </property>
    <property>
        <name>yarn.resourcemanager.scheduler.address.rm2</name>
        <value>hadoop103</value>
    </property>
    <property>
        <name>yarn.resourcemanager.webapp.address.rm2</name>
        <value>hadoop103</value>
    </property>

4、org.codehaus.janino.CompilerFactory cannot be cast to org.codehaus.commons.compiler.ICompilerFactory

在flink 的flink-conf.yaml中设置classloader,参考:https://blog.csdn.net/appleyuchi/article/details/111597050

classloader.resolve-order: parent-first

5、java.lang.NoSuchMethodError: scala.Predef$.refArrayOps

报错原因时集群的flink的scala版本与代码使用的scala版本不符合,解决方式是修改代码的scala版本,参考https://blog.csdn.net/Jiweilai1/article/details/88535904

6、java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

原因是采用了java的打包方式,在source下生成了meta-inf文件,解决方式是删除meta-info或者是修改pom,直接忽略。参考:https://blog.csdn.net/tongtong0704/article/details/53394183/

<groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <filters>  
                                <filter>  
                                    <artifact>*:*</artifact>  
                                    <excludes>  
                                            <exclude>META-INF/*.SF</exclude>  
                                            <exclude>META-INF/*.DSA</exclude>  
                                            <exclude>META-INF/*.RSA</exclude>  
                                        </excludes>  
                                </filter> 
                            </filters>

 


版权声明:本文为m0_54932731原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。