dev@glassfish.java.net

Re: UnsatisfiedDepedencyException

From: Amy Roh <Amelia.Roh_at_Sun.COM>
Date: Wed, 20 Aug 2008 10:41:45 -0700

Jerome Dochez wrote:
> Amy Roh wrote:
>> Kedar Mhaswade wrote:
>>> Is this a regression?
>> No :-)
>>> Are you injecting like:
>>>
>>> @Inject(name="http-listener-1")
>>> HttpListener ls1;
>> I have injected HttpService like below to listen to its events when
>> its list of http-listener, virtual-server, or other sub-component
>> changes.
>>
>> @Inject
>> public HttpService httpService;
> this is what you should inject. so when a new http-listener is added,
> you don't get notified ?
> if yes, have you filed a bug ?

Right. This part mostly works as expected (it gets notified when a new
http-listener is added) except "property" change to http-service doesn't
get notified - an issue [0] has been filed already.
HttpServiceConfigListener for HttpService is called when any of its
sub-elements are added/changed/removed except Property (ex. asadmin set
http-service.property.accessLoggingEnabled).

Also, since the ConfigListener does not get notified for a parent's
listener, HttpServiceConfigListener does not get notified if
HttpService's child VirtualServer or HttpListener is mutated such as

[1] asadmin set http-service.virtual-server.*server*.default-web-module=
[2] asadmin set
http-service.virtual-server.*vs2*.http-listeners=my-listener=

[1] can be handled if I
  
@Inject(name="server")
 public VirtualServer virtualServer;

However, why does the name have to be specified and how do we handle for
the unknown dynamically created random VirtualServer and HttpListener
such as [2] VirtualServer.name = vs2.

Thanks,
Amy

[0] https://glassfish.dev.java.net/issues/show_bug.cgi?id=5438

>
> jerome
>
>> If I inject
>>
>> @Inject(name="http-listener-1")
>> public HttpListener httpListener;
>>
>> only changes to HttpListener named "http-listener-1" trigger
>> ConfigListener which HttpListener is injected into. This doesn't
>> work for dynamically created HttpListener named let's say
>> "test-listener", correct?
>> Same goes for VirtualServer
>>
>> @Inject(name="server")
>> public VirtualServer virtualServer;
>>
>> If I create a virtual-server named vs2, changes to vs2 will not
>> trigger the above ConfigListener...
>>
>> Thanks,
>> Amy
>>
>>>
>>> ?
>>>
>>> Thanks.
>>>
>>> Amy Roh wrote:
>>>> I'm trying to better understand the root cause of
>>>> UnsatisfiedDepedencyException. For example, injecting
>>>> com.sun.enterprise.config.serverbeans.HttpService works fine in
>>>> HttpServiceConfigListener (which gets instantiated as the last step
>>>> of WebContainer.postConstruct()). However, HttpListener or
>>>> VirtualServer injection fails with the exception. Shouldn't
>>>> HttpListener and VirtualServer be available for injection by the
>>>> time web container is getting started?
>>>>
>>>> [#|2008-08-18T13:28:26.417-0700|SEVERE||javax.enterprise.system.tools.deployment|_ThreadID=12;_ThreadName=Thread-3;|Cannot
>>>> start container web
>>>> org.jvnet.hk2.component.UnsatisfiedDepedencyException: Unsatisfied
>>>> dependency exception : public
>>>> com.sun.enterprise.config.serverbeans.HttpListener
>>>> com.sun.enterprise.web.reconfig.HttpServiceConfigListener.httpListener
>>>> at
>>>> org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:100)
>>>>
>>>> at
>>>> com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:100)
>>>>
>>>> at
>>>> com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:86)
>>>>
>>>> at
>>>> com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:75)
>>>> at
>>>> com.sun.enterprise.web.WebContainer.postConstruct(WebContainer.java:662)
>>>>
>>>> at
>>>> com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:150)
>>>>
>>>> at
>>>> com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:86)
>>>>
>>>> at
>>>> com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:75)
>>>> at
>>>> com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
>>>>
>>>> at
>>>> com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
>>>> at
>>>> com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
>>>>
>>>> at
>>>> org.glassfish.internal.data.ContainerInfo.getContainer(ContainerInfo.java:75)
>>>>
>>>> at
>>>> com.sun.enterprise.v3.server.ApplicationLifecycle.startContainers(ApplicationLifecycle.java:798)
>>>>
>>>> at
>>>> com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:435)
>>>>
>>>> at
>>>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:270)
>>>>
>>>> at
>>>> com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:221)
>>>>
>>>> at
>>>> com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:98)
>>>>
>>>> at
>>>> com.sun.enterprise.v3.server.ApplicationLoaderInjector.postConstruct(ApplicationLoaderInjector.java:61)
>>>>
>>>> at
>>>> com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:150)
>>>>
>>>> at
>>>> com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:86)
>>>>
>>>> at
>>>> com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:75)
>>>> at
>>>> com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
>>>>
>>>> at
>>>> com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
>>>> at
>>>> com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
>>>>
>>>> at
>>>> com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:162)
>>>>
>>>> at
>>>> com.sun.enterprise.v3.server.AppServerStartup$1.run(AppServerStartup.java:103)
>>>>
>>>> Caused by: org.jvnet.hk2.component.UnsatisfiedDepedencyException:
>>>> Unsatisfied dependency exception : public
>>>> com.sun.enterprise.config.serverbeans.HttpListener
>>>> com.sun.enterprise.web.reconfig.HttpServiceConfigListener.httpListener
>>>> at
>>>> org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:95)
>>>>
>>>> ... 25 more
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>