1回目はUnsatisfiedLinkErrorで、2回目以降はNoClassFoundError

忘備録

現象

1回目はUnsatisfiedLinkErrorで、2回目でNoClassFoundErrorになる。

ソース

class Native{
    static{
        System.loadLibrary("hoge")
    }
}

try{
    def hoge = new Native()
}catch(UnsatisfiedLinkError e){
    e.printStackTrace()
}

def fuga = new Native()

スタックトレース

groovy NativeError.groovy
java.lang.UnsatisfiedLinkError: no hoge in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
        at java.lang.Runtime.loadLibrary0(Runtime.java:845)
        at java.lang.System.loadLibrary(System.java:1084)
        at java_lang_System$loadLibrary.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
        at Native.<clinit>(NativeError.groovy:3)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
        at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186)
        at NativeError.run(NativeError.groovy:8)
        at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:257)
        at groovy.lang.GroovyShell.run(GroovyShell.java:220)
        at groovy.lang.GroovyShell.run(GroovyShell.java:150)
        at groovy.ui.GroovyMain.processOnce(GroovyMain.java:557)
        at groovy.ui.GroovyMain.run(GroovyMain.java:344)
        at groovy.ui.GroovyMain.process(GroovyMain.java:330)
        at groovy.ui.GroovyMain.processArgs(GroovyMain.java:119)
        at groovy.ui.GroovyMain.main(GroovyMain.java:99)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)
        at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)
Caught: java.lang.NoClassDefFoundError: Could not initialize class Native
java.lang.NoClassDefFoundError: Could not initialize class Native
        at NativeError.run(NativeError.groovy:13)


staticイニシャライザーで失敗してるので、2回めのインスタンス生成はNoClassDefFoundErrorになる。
「Could not initialize class Native」がポイント。


DLLのロード処理だけなので、NoClassFoundErrorになったので、最初原因が分からなかった。
GroovyじゃなくてJavaの仕様。

WindowsでGrails 2.3.3だと起動はできるようになったけど、今度は止められない(続き)


誤解がある表現だったので、捕捉。
Grails 2.3.1でも、フォークされたプロセスであるForkedTomcatServerは止まらない。


Grails 2.3.1の動き。

起動

>grails run-app
アプリを起動。

>jps |grep -v Jps
34832 GrailsStarter
31240 ForkedTomcatServer
2つのプロセスが起動する

停止

| Server running. Browse to http://localhost:8080/hellowolrd
バッチ ジョブを終了しますか (Y/N)? y

Ctl+C を実行すると受け付ける

>jps |grep -v Jps
31240 ForkedTomcatServer

GrailsStarter が止まるが、ForkedTomcatServerは残ったまま。


ForkedTomcatServerを止める

ForkedTomcatServerを止めるには grails stop-appが必要。

>grails stop-app
| Server Stopped

jps |grep -v Jps


Grails2.3.2以降だとCtrl+Cを受け付けてくれないので
「バッチ ジョブを終了しますか (Y/N)?」もでない。
2つのプロセスが止まることは期待していないんだ。
Ctrl+Cでコマンドプロンプトに制御が戻ってくることを期待していたんだけど、
返ってこなかった。
あれ?そんな挙動だったっけ?と思って2.3.1で試してみたら挙動が違った。


で、どう動くのが仕様なのか分からんが、コマンドプロンプト使わなきゃいいという
話なのでまぁいいっかと。

WindowsでGrails 2.3.3だと起動はできるようになったけど、今度は止められない

f:id:orangeclover:20131126215825j:plain

現象

f:id:orangeclover:20131126220416p:plain

Server running. Browse to http://localhost:8080/hellowolrd

URLが表示された後で、コマンドプロンプトでCtrl+Cが効かない。

そのため、停止も他のコマンドも実行できなくなる。

対処

別のコマンドプロンプトを開いて、grasils stop-appとすれば
止められる。

発生するバージョン

version ctrl+Cによる停止
grails 2.3.1
grails 2.3.2 ×
grails 2.3.3 ×

2.3.2はそのままでは起動しないので、forkオプションの回避で起動した

2.3.2からのようだ。

環境

Grails 2.3.3
Java: 1.7.0_45

Grails 2.3.2だと起動できないし、2.3.3だと停止できない・・・
Windowsつかうなってことか。
もしくは、コマンドプロンプトなんかじゃなくて、
サムライズムからIntelliJ IDEAを購入しろってことか

WindowsでGrails 2.3.2だとError Forked Grails VM exited with errorで起動しない

Grails 2.3.2でrun-appしたら以下のエラーになった。

現象

| Error Forked Grails VM exited with error
| Running Grails application
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 844
Exception in thread "main"
| Error Forked Grails VM exited with error

対処

Grails 2.3.2の場合

grails-app\conf\BuildConfig.groovy

grails.project.fork = [
    // configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
    //  compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],

    // configure settings for the test-app JVM, uses the daemon by default
    test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
    // configure settings for the run-app JVM
    run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    // configure settings for the run-war JVM
    war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    // configure settings for the Console UI JVM
    console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
Grails 2.3.3を使う

環境

PostgreSQL Studioも Internet Explorerだと使えないという呪い

IEでloginをクリックするとLoading style and images ...で
ぐるぐる回ってログインできない。

f:id:orangeclover:20131112211647g:plain

FirefoxChromeでもログインできるのでIE対応にバグがありそう。


http://www.postgresqlstudio.org/support/documentation/supportdocumentationfaq/

Is there a specific browser I need to use PostgreSQL Studio?
We haven’t tested across all of the possible browsers, but the GWT supports the following browsers:

Firefox
Internet Explorer 6, 7, 8, 9
Safari 5, 6
Chromium and Google Chrome
Opera latest version
We would love to hear feedback on how PostgreSQL Studio works in different environments, so let us know.

あれ?IE9まで?

自分の環境はIE10だ。

でも、IE9でも同じ現象になるというチケットがあるな。
Failed start-up in IE9


こういうツールだと開発者だからIEなんて使うなってことなのかな。

20%高速化されたZenbackのスクリプトコードを試してみた

平均20%+高速化!Zenbackのスクリプトコードが新しくなりました
新旧のZenbackのスクリプトコードで、直近のエントリー4つとGist、アフィリエイト、リンクを貼ってない10/5のエントリー1つで計測してみた。
2013-11-04
2013-11-02
2013-10-28
2013-10-26
2013-10-05



webpagetest

スクリプト Load Time スクリプト Load Time 高速化割合
Firxt View Repeat View Firxt View Repeat View Firxt View Repeat View
2013-11-04 16.452s 13.824s 16.184s 13.161s 1.6% 4.8%
2013-11-02 20.357s 16.880s 20.185s 16.348s 0.8% 3.1%
2013-10-28 17.810s 14.102s 17.101s 14.188s 4.0% -0.6% (遅くなった)
2013-10-26 35.567s 15.453s 19.351s 14.476s 45.6% 6.3%
2013-10-05 17.393s 13.682s 15.442s 13.247s 11.2% 3.1%

GTmetrix

  • デフォルトの設定
  • Test Server Region: Vancouver, Canada
  • Using: Firefox (Desktop) 14.0.1, Page Speed 1.12.16, YSlow 3.1.7
スクリプト Page load time スクリプト Page load time 高速化割合
2013-11-04 7.94s 6.17s 22.2%
2013-11-02 10.94s 10.09s 7.8%
2013-10-28 10.86s 7.88s 27.4%
2013-10-26 7.96s 8.08s -1.5% (遅くなった)
2013-10-05 7.11s 6.97s 2.0%

Pingdom Website speed test

  • デフォルト設定
スクリプトLoad Time スクリプトLoad Time 高速化割合
2013-11-04 11.61s 4.01s 65.5%
2013-11-02 8.50.s 6.66s 21.6%
2013-10-28 5.63s 5.71s -1.4% (遅くなった)
2013-10-26 17.70s 4.46s 74.8%
2013-10-05 6.95s 4.06s 41.6%

まとめ

1回しか図らなかったのがまずかったかな。
測定し終わって、同じページで3回測ったら測定値がぶれっぶれ。
でも、一部1%ぐらい遅くなったものもあるが、極端に遅くなったのはないし、
効果はありそう。

それ以上に自分のブログが重さをどうにかしないとダメだ。
いろんなものを貼り過ぎようだ。

amazon 250円クーポンキャンペーンでjenkinsでビルド後に鳴らす効果音を手に入れてみては?


誰でも使える MP3ダウンロード250円クーポンキャンペーン
250円分のクーポン券がもらえる。
250円分で買えるものとなると1、2曲。
流行りのあまちゃんには興味ないしという人はスルーしてるのではないだろうか。


Jenkinsでビルドしてるなら、ビルド後に効果音として、ドラクエスーパーマリオブラザーズなどの
効果音を手に入れてみてはどうだろうか。


参考

jenkinsの設定方法はこちらが詳しい。
Jenkinsでビルド後に音(BGM、SE)を鳴らしてみた