ClassNotFoundException when executing Spring Boot Application Using Spark Submit

ClassNotFoundException when executing Spring Boot Application Using Spark Submit

I solved it by using SHADE maven plugin.

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <version>1.5.2.RELEASE</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                    </filters>
                    <transformers>
                        <transformer
                            implementation=org.apache.maven.plugins.shade.resource.AppendingTransformer>
                            <resource>META-INF/spring.handlers</resource>
                        </transformer>
                        <transformer
                            implementation=org.springframework.boot.maven.PropertiesMergingResourceTransformer>
                            <resource>META-INF/spring.factories</resource>
                        </transformer>
                        <transformer
                            implementation=org.apache.maven.plugins.shade.resource.AppendingTransformer>
                            <resource>META-INF/spring.schemas</resource>
                        </transformer>
                        <transformer
                            implementation=org.apache.maven.plugins.shade.resource.ServicesResourceTransformer />
                        <transformer
                            implementation=org.apache.maven.plugins.shade.resource.ManifestResourceTransformer>
                            <mainClass>com.yourpackage.MainClass</mainClass>
                        </transformer>
                    </transformers>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

ClassNotFoundException when executing Spring Boot Application Using Spark Submit

Leave a Reply

Your email address will not be published. Required fields are marked *