afnf.net

Spring Boot 1.5 への移行

blog-java2ブログエンジンをSpring Boot 1.5.6にアップグレードしてみました。

2件の修正を行ったのでご紹介。

Spring Boot 1.5の変更点については@kazuki43zooさんのQiitaエントリが参考になります。

フィルタ内部実装変更

以前紹介した CachingResourceUrlEncodingFilter.java について、内部実装に変更があったので対応しました。

Spring Boot 1.5系でもcache bustingに問題があるかは未確認。

IT周りの変更

Spring Boot とは特に関連が無いのですが、Headless Chromeが使えるようになったので導入しました。Windows環境では、正常にITが実行できました。ということでPhantomJSはお役御免。

ただし問題があって、CentOS 7.3上ではChromeDriverが動作しません。

まずChromeDriver 2.31 (Chrome 60ベース)ですが、glibc 2.18に依存しています。しかし、CentOS 7.xのglibcは2.17です。結果、以下のようなエラーになります。

$ /usr/local/bin/chromedriver -h
/usr/local/bin/chromedriver: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /usr/local/bin/chromedriver)

異なるバージョンのglibcを共存させるのは可能らしいですが・・・

これこれこれによれば、ChromeDriver 2.32? (Chrome 61ベース)でglibc 2.17に差し戻されるようです。


じゃあとりあえず、ということでChromeDriver 2.30を試そうとすると、以下のようなエラーが出ます。

org.openqa.selenium.WebDriverException: unknown error: an X display is required for keycode conversions, consider using Xvfb
  (Session info: headless chrome=60.0.3112.101)
(中略)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:122)
at net.afnf.blog.selenium.ClickAndWaitRemoteWebElement.sendKeys(ClickAndWaitRemoteWebElement.java:106)
at net.afnf.blog.it.Selenium03_IT.test301_init(Selenium03_IT.java:41)

これこれにある通り、ChromeDriver 2.30のsendKeysの不具合だそうで・・・ぐぬぬ

Xvfbを入れるのは負けた感じがするので放置。


さらにWindows/Linuxの両方で、FirefoxのWebDriverが動作しなくなりました。

  • Firefox 48以降は拡張機能に署名が必須になった
  • MozillaがSelenium拡張への署名を拒否している
  • 移行先のGeckoDriverはSelenium 3.0以降でないと使えないらしい
  • Spring Boot 1.x系はSelenium 2.x系に依存している

ということで詰んでます。試しに Spring Boot 1.5 + GeckoDriver + Selenium 3.0をトライしてみましたが、正常動作せず。Spring Boot 2.0までお預けでしょうか。

comments (0)

blog-java2 engine (build:2019-02-23 17:57 JST)