異常說明
java.lang.SecurityException: class “javax.servlet.FilterRegistration“‘s signer information does not match signer information of other classes in the same package
解決誤區
在ideal中運行本地spark出現class “javax.servlet.FilterRegistration” 不匹配,在網上查了很多:
1. 有讓刪除javax.servlet開頭的庫的【未解決】
有讓參考http://stackoverflow.com/questions/28086520/spark-application-throws-javax-servlet-filterregistration 的【不知所云,未解決】
有讓【未解決】
正確解決方案
於是我們需要在pom.xml中,視情況把不同版本的servlet-api給“除掉”,這裡我選擇的是除掉hadoop-common中的舊版本servlet-api:
<dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-common</artifactId> <exclusions> <exclusion> <groupId>javax.servlet</groupId> <artifactId>*</artifactId> </exclusion> </exclusions></dependency>
依次檢查完所有的間接依賴,一個個處理好,再重新編譯器,測試,直到程式可以正常跑起來。
這裡需要特別注意,如果程式運行前export的CLASSPATH中的某個路徑裡有舊的jar包,一定要清理乾淨再測試,否則可能你已經在pom.xml中解決了問題,但無論怎麼測都不行,仍然還是jar包衝突,結果發現是CLASSPATH中的某個路徑下的舊jar包沒清理乾淨導致的,那就浪費時間了。