2008年12月3日水曜日

Redmine on GlassFish -6

またまた Redmine on GlassFish です。

今回は on GlassFish というよりは "with GlassFish gem" 。

手軽さが売り物の GlassFish gem、ということで、あっという間にデプロイ&起動が完了するかと思いきや、今回もやっぱりいくつかのハマりどころがありました。

まず、何も考えずに、

cd c:\host\redmine
jruby -S glassfish

とやってみたところ、こんなエラーが発生。

---
C:\host\redmine>jruby -S glassfish
2008/12/03 0:51:06 com.sun.enterprise.glassfish.bootstrap.ASMain main
情報: Launching GlassFish on Apache Felix OSGi platform
2008/12/03 0:51:06 com.sun.enterprise.glassfish.bootstrap.ASMainOSGi findDerbyClient
情報: Cannot find javadb client jar file, jdbc driver not available

Welcome to Felix.
=================

2008/12/03 0:51:07 OSGiModuleImpl start
情報: Started bundle org.glassfish.core.kernel [23]
2008/12/03 0:51:07 OSGiModuleImpl start
情報: Started bundle org.glassfish.common.common-util [12]
2008/12/03 0:51:07 OSGiModuleImpl start
情報: Started bundle GlassFish-Application-Common-Module [19]
2008/12/03 0:51:07 APIClassLoaderService createAPIClassLoader
情報: APIClassLoader = Class Loader for Bundle [GlassFish-Application-Common-Module [19] ]
2008/12/03 0:51:07 HK2Main$HK2ServiceTrackerCustomizer addingService
情報: registering service = org.apache.felix.framework.StartLevelImpl@2942da, contract = org.osgi.service.startlevel.StartLevel, name = null
2008/12/03 0:51:07 HK2Main$HK2ServiceTrackerCustomizer addingService
情報: registering service = org.apache.felix.framework.PackageAdminImpl@162f16,contract = org.osgi.service.packageadmin.PackageAdmin, name = null
2008/12/03 0:51:07 OSGiModuleImpl start
情報: Started bundle org.glassfish.branding.branding [22]
no resource bundle found for version, using default GlassFish version
2008/12/03 0:51:07 AppServerStartup run
情報: [Thread[GlassFish Kernel Main Thread,5,main]] started
2008/12/03 0:51:07 OSGiModuleImpl start
情報: Started bundle org.glassfish.common.internal-api [15]
2008/12/03 0:51:07 OSGiModuleImpl start
情報: Started bundle org.glassfish.admin.config-api [25]
2008/12/03 0:51:07 OSGiModuleImpl start
情報: Started bundle org.glassfish.deployment.deployment-autodeploy [16]
2008/12/03 0:51:07 OSGiModuleImpl start
情報: Started bundle org.glassfish.deployment.deployment-common [17]
2008/12/03 0:51:08 OSGiModuleImpl start
情報: Started bundle org.glassfish.flashlight.flashlight-framework [18]
2008/12/03 0:51:08 com.sun.enterprise.v3.services.impl.GrizzlyProxy start
情報: Listening on port 3000
2008/12/03 0:51:08 com.sun.enterprise.v3.services.impl.GrizzlyService postConstruct
情報: Network listener http-listener-2 on port 8181 disabled per domain.xml
2008/12/03 0:51:08 com.sun.enterprise.v3.services.impl.GrizzlyProxy start
情報: Listening on port 4848
2008/12/03 0:51:08 com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setStateMsg
情報: The Admin Console Application is not yet installed.
2008/12/03 0:51:09 OSGiModuleImpl start
情報: Started bundle org.glassfish.scripting.gf-jruby-connector [8]
2008/12/03 0:51:10 OSGiModuleImpl start
情報: Started bundle org.glassfish.scripting.grizzly-jruby-module [9]
2008/12/03 0:51:11 com.sun.grizzly.jruby.rack.RackApplicationChooser getFactory
情報: Detected Rails application
2008/12/03 0:51:11 com.sun.grizzly.jruby.rack.RackApplicationChooser getFactory
情報: Rails Version: 2.0
2008/12/03 0:51:11 com.sun.grizzly.pool.DynamicPool logDynamicStatus
情報: Pool started without dynamic resizing enabled. Pool will not attempt to determine the upper and lower bounds that it should be using, and will stay at 1
2008/12/03 0:51:11 com.sun.grizzly.jruby.rack.RackApplicationPoolAdapter initializeObject
致命的: Error initializing rack application!
2008/12/03 0:51:11
致命的: com.sun.grizzly.jruby.rack.RackInitializationException: No such file or
directory - No such file or directory - C:/host/redmine/C:
from C:/jruby/trunk/bin/../lib/ruby/1.8/pathname.rb:453:in `realpath'
from /C:/host/redmine/config/../vendor/rails/railties/lib/initializer.rb
:496:in `set_root_path!'
from /C:/host/redmine/config/../vendor/rails/railties/lib/initializer.rb
:460:in `initialize'
from /C:/host/redmine//config/boot.rb:19:in `run'
from /C:/host/redmine//config/boot.rb:19
from /C:/host/redmine//config/boot.rb:11:in `require'
from /C:/host/redmine//config/environment.rb:11
from /C:/host/redmine//config/environment.rb:1

2008/12/03 0:51:11
致命的: at com.sun.grizzly.jruby.rack.DefaultRackApplicationFactory.createApplication(DefaultRackApplicationFactory.java:171)
2008/12/03 0:51:11
致命的: at com.sun.grizzly.jruby.rack.DefaultRackApplicationFactory.newApplication(DefaultRackApplicationFactory.java:72)
2008/12/03 0:51:11
致命的: at com.sun.grizzly.jruby.rack.RackApplicationPoolAdapter.initializeObject(RackApplicationPoolAdapter.java:43)
2008/12/03 0:51:11
致命的: at com.sun.grizzly.jruby.rack.RackApplicationPoolAdapter.initializeObject(RackApplicationPoolAdapter.java:16)
2008/12/03 0:51:11
致命的: at com.sun.grizzly.pool.DynamicPool$1.run(DynamicPool.java:394)
2008/12/03 0:51:11
致命的: at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
2008/12/03 0:51:11
致命的: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
2008/12/03 0:51:11
致命的: at java.lang.Thread.run(Thread.java:619)
2008/12/03 0:51:11
致命的: Caused by: org.jruby.exceptions.RaiseException: No such file or directory - C:/host/redmine/C:
2008/12/03 0:51:11
致命的: at (unknown).initialize(C:/jruby/trunk/bin/../lib/ruby/1.8/pathname.rb:420)
2008/12/03 0:51:11
致命的: at Pathname.realpath_rec(C:/jruby/trunk/bin/../lib/ruby/1.8/pathname.rb:453)
2008/12/03 0:51:11
致命的: at Pathname.realpath(/C:/host/redmine/config/../vendor/rails/railties/lib/initializer.rb:496)
2008/12/03 0:51:11
致命的: at Rails::Configuration.set_root_path!(/C:/host/redmine/config/.
./vendor/rails/railties/lib/initializer.rb:460)
2008/12/03 0:51:11
致命的: at Rails::Configuration.initialize(/C:/host/redmine//config/boot.rb:19)
2008/12/03 0:51:11
致命的: at #<Class:01x1a8739b>.run(/C:/host/redmine//config/boot.rb:19)
2008/12/03 0:51:11
致命的: at (unknown).(unknown)(/C:/host/redmine//config/boot.rb:11)
2008/12/03 0:51:11
致命的: at Kernel.require(/C:/host/redmine//config/environment.rb:11)
2008/12/03 0:51:11
致命的: at (unknown).(unknown)(/C:/host/redmine//config/environment.rb:1
)
2008/12/03 0:51:11
致命的: at (unknown).(unknown)(:1)
2008/12/03 0:51:11
致命的: Exception in thread "pool-8-thread-1"
2008/12/03 0:51:11
致命的: java.lang.IllegalStateException: Rack initialization failed!
2008/12/03 0:51:11
致命的: at com.sun.grizzly.jruby.rack.RackApplicationPoolAdapter.initializeObject(RackApplicationPoolAdapter.java:49)
2008/12/03 0:51:11
致命的: at com.sun.grizzly.jruby.rack.RackApplicationPoolAdapter.initializeObject(RackApplicationPoolAdapter.java:16)
2008/12/03 0:51:11
致命的: at com.sun.grizzly.pool.DynamicPool$1.run(DynamicPool.java:394)
2008/12/03 0:51:11
致命的: at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
2008/12/03 0:51:11
致命的: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
2008/12/03 0:51:11
致命的: at java.lang.Thread.run(Thread.java:619)
2008/12/03 0:51:11 com.sun.grizzly.jruby.RailsAdapter <init>
情報: Jruby version is: 1.1.5
2008/12/03 0:51:11 org.glassfish.scripting.rails.RailsDeployer load
情報: Loading Rails application redmine at /
2008/12/03 0:51:11 com.sun.enterprise.v3.server.AppServerStartup run
情報: GlassFish v3 Prelude startup time : Felix(1016ms) startup services(3781ms)
total(4797ms)
---

なんかよく分からないけれど、「C:/host/redmine/C:なんてファイルやディレクトリはないよ」と文句を言われている模様。
あちこち検索してみたもののコレという情報が見つからないので、やむをえずコードを追ってみることに。

---
** endor/rails/railties/lib/initializer.rb
@root_path =
# Pathname is incompatible with Windows, but Windows doesn't have
# real symlinks so File.expand_path is safe.
if RUBY_PLATFORM =~ /(:?mswin|mingw)/
 File.expand_path(::RAILS_ROOT)
# Otherwise use Pathname#realpath which respects symlinks.
else
 Pathname.new(::RAILS_ROOT).realpath.to_s
end
---

この部分、コメントに「Windowsの場合はFile.expand_pathを使った方が安全」と書いてあるくせに、なぜかOSの判定に失敗しているようで、else以下に制御がわたってrealpathメソッドが呼ばれている。
どうもそのrealpathの中でおかしなことになっているっぽいので、荒業ながら、

Pathname.new(::RAILS_ROOT).realpath.to_s

の部分をコメントアウトし、elseの前にある、

File.expand_path(::RAILS_ROOT)

をもってきてみました。
どうせWindowsで使うんだし(←無謀…)


---
** endor/rails/railties/lib/initializer.rb
@root_path =
# Pathname is incompatible with Windows, but Windows doesn't have
# real symlinks so File.expand_path is safe.
if RUBY_PLATFORM =~ /(:?mswin|mingw)/
 File.expand_path(::RAILS_ROOT)
# Otherwise use Pathname#realpath which respects symlinks.
else
 Pathname.new(::RAILS_ROOT).realpath.to_s
end
---

これでどうだ!と、再度 jruby -S glassfish を実行してみたところ、今度はさっきよりもっと派手なエラーが出て、やっぱりアプリケーションは立ち上がりません。

---
C:\host\redmine>jruby -S glassfish
2008/12/03 0:59:55 com.sun.enterprise.glassfish.bootstrap.ASMain main
情報: Launching GlassFish on Apache Felix OSGi platform
2008/12/03 0:59:55 com.sun.enterprise.glassfish.bootstrap.ASMainOSGi findDerbyCl
ient
情報: Cannot find javadb client jar file, jdbc driver not available

Welcome to Felix.
=================

2008/12/03 0:59:56 OSGiModuleImpl start
情報: Started bundle org.glassfish.core.kernel [23]
2008/12/03 0:59:56 OSGiModuleImpl start
情報: Started bundle org.glassfish.common.common-util [12]
2008/12/03 0:59:56 OSGiModuleImpl start
情報: Started bundle GlassFish-Application-Common-Module [19]
2008/12/03 0:59:56 APIClassLoaderService createAPIClassLoader
情報: APIClassLoader = Class Loader for Bundle [GlassFish-Application-Common-Mod
ule [19] ]
2008/12/03 0:59:56 HK2Main$HK2ServiceTrackerCustomizer addingService
情報: registering service = org.apache.felix.framework.StartLevelImpl@15e3dc4, c
ontract = org.osgi.service.startlevel.StartLevel, name = null
2008/12/03 0:59:56 HK2Main$HK2ServiceTrackerCustomizer addingService
情報: registering service = org.apache.felix.framework.PackageAdminImpl@e3fd79,
contract = org.osgi.service.packageadmin.PackageAdmin, name = null
2008/12/03 0:59:56 OSGiModuleImpl start
情報: Started bundle org.glassfish.branding.branding [22]
no resource bundle found for version, using default GlassFish version
2008/12/03 0:59:56 AppServerStartup run
情報: [Thread[GlassFish Kernel Main Thread,5,main]] started
2008/12/03 0:59:56 OSGiModuleImpl start
情報: Started bundle org.glassfish.common.internal-api [15]
2008/12/03 0:59:56 OSGiModuleImpl start
情報: Started bundle org.glassfish.admin.config-api [25]
2008/12/03 0:59:57 OSGiModuleImpl start
情報: Started bundle org.glassfish.deployment.deployment-autodeploy [16]
2008/12/03 0:59:57 OSGiModuleImpl start
情報: Started bundle org.glassfish.deployment.deployment-common [17]
2008/12/03 0:59:57 OSGiModuleImpl start
情報: Started bundle org.glassfish.flashlight.flashlight-framework [18]
2008/12/03 0:59:57 com.sun.enterprise.v3.services.impl.GrizzlyProxy start
情報: Listening on port 3000
2008/12/03 0:59:57 com.sun.enterprise.v3.services.impl.GrizzlyService postConstr
uct
情報: Network listener http-listener-2 on port 8181 disabled per domain.xml
2008/12/03 0:59:57 com.sun.enterprise.v3.services.impl.GrizzlyProxy start
情報: Listening on port 4848
2008/12/03 0:59:57 com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter setSt
ateMsg
情報: The Admin Console Application is not yet installed.
2008/12/03 0:59:58 OSGiModuleImpl start
情報: Started bundle org.glassfish.scripting.gf-jruby-connector [8]
2008/12/03 0:59:59 OSGiModuleImpl start
情報: Started bundle org.glassfish.scripting.grizzly-jruby-module [9]
2008/12/03 1:00:00 com.sun.grizzly.jruby.rack.RackApplicationChooser getFactory
情報: Detected Rails application
2008/12/03 1:00:00 com.sun.grizzly.jruby.rack.RackApplicationChooser getFactory
情報: Rails Version: 2.0
2008/12/03 1:00:00 com.sun.grizzly.pool.DynamicPool logDynamicStatus
情報: Pool started without dynamic resizing enabled. Pool will not attempt to de
termine the upper and lower bounds that it should be using, and will stay at 1
2008/12/03 1:00:05
致命的: JRuby limited openssl loaded. gem install jruby-openssl for full support
.
http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL
2008/12/03 1:00:05
致命的:

2008/12/03 1:00:10
情報: GLoc v1.1 running in development mode. Strings can be modified at runtime.

2008/12/03 1:00:10
情報:

2008/12/03 1:00:10 com.sun.grizzly.jruby.rack.RackApplicationPoolAdapter initial
izeObject
致命的: Error initializing rack application!
2008/12/03 1:00:10
致命的: com.sun.grizzly.jruby.rack.RackInitializationException: no such file to
load -- rack
from <script>:1

2008/12/03 1:00:10
致命的: at com.sun.grizzly.jruby.rack.DefaultRackApplicationFactory.crea
teApplication(DefaultRackApplicationFactory.java:171)
2008/12/03 1:00:10
致命的: at com.sun.grizzly.jruby.rack.DefaultRackApplicationFactory.newA
pplication(DefaultRackApplicationFactory.java:72)
2008/12/03 1:00:10
致命的: at com.sun.grizzly.jruby.rack.RackApplicationPoolAdapter.initial
izeObject(RackApplicationPoolAdapter.java:43)
2008/12/03 1:00:10
致命的: at com.sun.grizzly.jruby.rack.RackApplicationPoolAdapter.initial
izeObject(RackApplicationPoolAdapter.java:16)
2008/12/03 1:00:10
致命的: at com.sun.grizzly.pool.DynamicPool$1.run(DynamicPool.java:394)
2008/12/03 1:00:10
致命的: at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Thread
PoolExecutor.java:885)
2008/12/03 1:00:10
致命的: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPool
Executor.java:907)
2008/12/03 1:00:10
致命的: at java.lang.Thread.run(Thread.java:619)
2008/12/03 1:00:10
致命的: Caused by: org.jruby.exceptions.RaiseException
2008/12/03 1:00:10
致命的: at Kernel.raise(C:/host/redmine/vendor/rails/activerecord/lib/..
/../activesupport/lib/active_support/dependencies.rb:499)
2008/12/03 1:00:10
致命的: at Object.require(<script>:1)
2008/12/03 1:00:10
致命的: at (unknown).(unknown)(:1)
2008/12/03 1:00:10
致命的: Exception in thread "pool-8-thread-1"
2008/12/03 1:00:10
致命的: java.lang.IllegalStateException: Rack initialization failed!
2008/12/03 1:00:10
致命的: at com.sun.grizzly.jruby.rack.RackApplicationPoolAdapter.initial
izeObject(RackApplicationPoolAdapter.java:49)
2008/12/03 1:00:10
致命的: at com.sun.grizzly.jruby.rack.RackApplicationPoolAdapter.initial
izeObject(RackApplicationPoolAdapter.java:16)
2008/12/03 1:00:10
致命的: at com.sun.grizzly.pool.DynamicPool$1.run(DynamicPool.java:394)
2008/12/03 1:00:10
致命的: at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Thread
PoolExecutor.java:885)
2008/12/03 1:00:10
致命的: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPool
Executor.java:907)
2008/12/03 1:00:10
致命的: at java.lang.Thread.run(Thread.java:619)
2008/12/03 1:00:10 com.sun.grizzly.jruby.RailsAdapter <init>
情報: Jruby version is: 1.1.5
2008/12/03 1:00:10 org.glassfish.scripting.rails.RailsDeployer load
情報: Loading Rails application redmine at /
2008/12/03 1:00:10 com.sun.enterprise.v3.server.AppServerStartup run
情報: GlassFish v3 Prelude startup time : Felix(1032ms) startup services(14078ms
) total(15110ms)
---

ログがしきりにRack、Rackと叫んでいるのを見て、
「そういえばこのJRubyにRackのgem入れてなかったかも…」
と思い立ち、さっそくgemをインストール。

---
jruby -S gem install rack
---

そして再びRedmineのルートディレクトリ内で、

---
jruby -S glassfish
---

…ばんざーい、今度は無事起動しました!
まぁ画面は前回と全く同じですが、せっかくなのではっておきます :-)


 

0 件のコメント: