閱讀822 返回首頁    go 微軟 go Office


注意maven打包的filter

## 注意maven打包的filter

應用新加了往蘋果APVS推消息的功能,引入了一個證書文件cert.p12,在使用時遇到如下錯誤:

<pre>

javapns.communication.exceptions.KeystoreException: Keystore exception: Detect premature EOF

        at javapns.communication.KeystoreManager.wrapKeystoreException(KeystoreManager.java:224)

        at javapns.communication.KeystoreManager.loadKeystore(KeystoreManager.java:79)

        at javapns.communication.KeystoreManager.loadKeystore(KeystoreManager.java:46)

        at javapns.communication.KeystoreManager.loadKeystore(KeystoreManager.java:29)

        at javapns.communication.ConnectionToAppleServer.<init>(ConnectionToAppleServer.java:61)

        at javapns.notification.ConnectionToNotificationServer.<init>(ConnectionToNotificationServer.java:17)

        at javapns.notification.PushNotificationManager.initializeConnection(PushNotificationManager.java:107)

</pre>

異常發生在導入證書時,猜猜像是讀解析內容非預期的遇到EOF了,可能文件有問題。

我們的應用用maven打包,證書放在配置目錄或資源目錄都如此,調試了一下,改成讀源文件目錄下的證書文件,沒問題了。這就能確定是maven打包後把文件內容改了。

去看maven腳本:

<pre>

   <plugin>

    <groupId>org.apache.maven.plugins</groupId>

    <artifactId>maven-war-plugin</artifactId>

    <version>2.1-beta-1</version>

    <configuration>

     <warName>communitypushclient</warName>

     <webResources>

      <resource>

       <directory>src/main/webapp/WEB-INF</directory>

       <filtering>true</filtering>

       <targetPath>WEB-INF</targetPath>

      </resource>

      <resource>

       <directory>../server/src/main/conf</directory>

       <filtering>true</filtering>

       <targetPath>WEB-INF</targetPath>

      </resource>

      <resource>

       <directory>../server/src/main/resources</directory>

       <filtering>true</filtering>

       <targetPath>WEB-INF/classes</targetPath>

      </resource>

     </webResources>

    </configuration>

   </plugin>

</pre>

原因很明顯了,證書文件放在resources目錄下,配置了filter,會對文件中變量進行替換。雖說證書文件中沒有什麼可替換的,但是這裏maven有處理文件,用UTF-8對文件進行轉碼保存,文件增大了,二進製的內容完全就不對了。把<filtering>true</filtering>改成false即好了。
本文來源於"阿裏中間件團隊播客",原文發表時間"  2012-04-24 

最後更新:2017-05-18 20:36:44

  上一篇:go  《Flink官方文檔》Batch Examples(二)
  下一篇:go  《Flink官方文檔》Batch Examples(一)