users@glassfish.java.net

JRuby with GlassFish 3.0.1

From: Major Péter <majorpetya_at_sch.bme.hu>
Date: Mon, 18 Oct 2010 21:24:52 +0200

Hi,

Just a little feedback:
I was trying to move my Redmine (rails based app) installation from
Apache + fcgid to GlassFish 3.0.1 + JRuby + Apache AJP.

1st issue:
If you're using JDK1.6u18 or higher, then you're going to encounter with
the following bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6923688

The approved workaround from the JRuby guys was to either patch JRuby or
use latest trunk. So I've builded myself a JRuby 1.6.0.dev and
configured it properly with GF.

2nd issue:
How the hell is it possible to set the environment for a Rails app on
deploytime?
Arun Gupta on his blog stated:
> Just include RAILS_ENV=production at the CLI to change the environment.

Okay but where exactly? This didn't had any effect with asadmin deploy
command, so probably I should start the whole server with this property,
but really, is this the best solution for this?
I've tried many things and the final winner was to use
-Drails.env=production JVM property (still not pretty).

3rd issue:
You can't really use JRuby with the plain mysql adapter, and installing
with mkmf is not supported, so I've tried to use the jdbcmysql and the
jdbc driver. I've created a JNDI connectionpool, but at the apploading
stage I always saw the following stacktrace:
No default ThreadPool defined
com.sun.corba.ee.spi.orbutil.threadpool.NoSuchThreadPoolException
        at
org.glassfish.enterprise.iiop.util.S1ASThreadPoolManager.getThreadPool(S1ASThreadPoolManager.java:241)
        at
org.glassfish.enterprise.iiop.util.S1ASThreadPoolManager.getDefaultThreadPool(S1ASThreadPoolManager.java:271)
        at
com.sun.enterprise.connectors.work.CommonWorkManager.<init>(CommonWorkManager.java:104)
        at
com.sun.enterprise.connectors.work.WorkManagerFactory.createWorkManager(WorkManagerFactory.java:122)
        at
com.sun.enterprise.connectors.work.WorkManagerFactory.getWorkManagerProxy(WorkManagerFactory.java:193)
        at
com.sun.enterprise.connectors.ConnectorRuntime.getWorkManagerProxy(ConnectorRuntime.java:928)
        at
com.sun.enterprise.connectors.BootstrapContextImpl.initializeWorkManager(BootstrapContextImpl.java:155)
        at
com.sun.enterprise.connectors.BootstrapContextImpl.<init>(BootstrapContextImpl.java:99)
        at
com.sun.enterprise.connectors.ActiveOutboundResourceAdapter.init(ActiveOutboundResourceAdapter.java:127)
        at
com.sun.enterprise.connectors.ActiveRAFactory.instantiateActiveResourceAdapter(ActiveRAFactory.java:130)
        at
com.sun.enterprise.connectors.ActiveRAFactory.createActiveResourceAdapter(ActiveRAFactory.java:101)
        at
com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter(ResourceAdapterAdminServiceImpl.java:216)
        at
com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter(ResourceAdapterAdminServiceImpl.java:338)
        at
com.sun.enterprise.connectors.ConnectorRuntime.createActiveResourceAdapter(ConnectorRuntime.java:327)
        at
com.sun.enterprise.connectors.service.ConnectorService.loadDeferredResourceAdapter(ConnectorService.java:164)
        at
com.sun.enterprise.connectors.service.ConnectorService.loadResourcesAndItsRar(ConnectorService.java:133)
        at
com.sun.enterprise.connectors.service.ConnectorService.checkAndLoadPool(ConnectorService.java:307)
        at
com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl.createConnectorResource(ConnectorResourceAdminServiceImpl.java:91)
        at
com.sun.enterprise.connectors.ConnectorRuntime.createConnectorResource(ConnectorRuntime.java:266)
        at
com.sun.enterprise.resource.deployer.JdbcResourceDeployer.deployResource(JdbcResourceDeployer.java:107)
        at
org.glassfish.javaee.services.ResourceProxy.create(ResourceProxy.java:84)
        at
com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:432)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:525)


To fix this I was using jdbcmysql without JNDI connection pooling
(config from http://www.ruby-forum.com/topic/171910)

4th issue:
AJP Proxying a JRuby app results in a 404 page! I'm already proxying a
Hudson instance from the same domain, and that works flawlessly, but AJP
proxying a JRuby app just always returns a GF 404 page. As soon as I
started to use HTTP proxy the Redmine just started to work...

Maybe I'm just unlucky, but seriously 4 issue during a single
deployment? (okay 2-3, you can't really do much about the JDK bug, and
the connectionpool stuff could be a jdbcmysql problem :) )

p.s.: I think next time I'm going to stay with FCGID + Apache instead...

Regards,
Peter