dev@glassfish.java.net

Issues with container config using org.glassfish.api.admin.config.Container

From: Vivek Pandey <Vivek.Pandey_at_Sun.COM>
Date: Mon, 06 Jul 2009 19:28:35 -0700

I am working on jruby container specific configuration. I have defined a
JrubyContainer config class(@Configured) which has @Attribute and
@Element annotations defined.
 
See http://pastie.org/536512

I expected that on startup of the container, the JrubyContainerConfig
will be injected (wither read from domain.xml, if present, or just with
default values) and the values set explicitly on this will be persisted
in domain.xml. Atleast this is what I intend to achieve. However on
startup the injection it self fails. Please note that there is no
<jruby-container> element in domain.xml.

@Service(name = "org.glassfish.scripting.jruby.JRubyContainer")
@Scoped(Singleton.class)
public class JRubyContainer implements Container, PostConstruct,
PreDestroy {

    @Inject
    org.glassfish.scripting.jruby.config.JrubyContainerConfig config;
    
    ...
}

However, on the server startup, I get an exception complaining the
injection of JrubyContainerConfig failed:

---------
INFO: Cannot inject org.glassfish.scripting.jruby.config.JRubyContainer
org.glassfish.scripting.jruby.JRubyContainer.config in
componentorg.glassfish.scripting.jruby.JRubyContainer_at_15f01497
Jul 6, 2009 10:18:07 AM
com.sun.enterprise.v3.server.ApplicationLifecycle startContainers
SEVERE: Cannot start container jruby
org.jvnet.hk2.component.UnsatisfiedDepedencyException: Unsatisfied
dependency exception :
org.glassfish.scripting.jruby.config.JrubyContainer
org.glassfish.scripting.jruby.JrubyContainer.config
    at
org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:102)
    at
com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:170)
    at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:89)
    at java.security.AccessController.doPrivileged(Native Method)
    at
com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:86)
-----------

When I defined the jruby-container config element inside domain.xml and
then start v3, I See the above error go away and injection happening
correctly. I suspect this is some kind of bug or do I really need to
have the following xml element in the domain.xml to start with? The fact
that my container config is based on
org.glassfish.api.admin.config.Container, so the presence of the config
element should appear in the domain.xml automatically.

<jruby-container jruby-home="">
  <jruby-runtime-pool />
</jruby-container>

-vivek.