The "Unexpected runtime error " part would indicate that the
component you tried to look up threw an exception while
being initialized.
The ServiceException has a getCause() method. Catch the
ServiceException and do:
} catch (ServiceException se) {
se.getCause ().printStackTrace ();
}
And I think you'll be a step closer to solving the problem.
/LS
> -----Original Message-----
> From: Jaros³aw Pa³ka [mailto:[EMAIL PROTECTED]
> Sent: den 25 februari 2004 16:12
> To: Avalon framework users
> Subject: hasService() and lookup() inconsistent results
>
>
> Hi!!
>
> We found following inconsistency in ServiceManager in merlin 3.2.5.
>
> In one component we defined following dependency:
>
> public class B extends A{
> /**
> * @avalon.dependency
> type="com.mrt.vend.client.desktop2.view.ViewContainer"
> key="parentContainer"
> **/
> public void service(ServiceManager serviceManager) throws
> ServiceException
> {
> super.service(serviceManager);
> }
> }
>
>
> public abstract A{
>
> public void initialize() throws java.lang.Exception
> {
> if (getServiceManager().hasService("parentContainer"))
> {
> System.out.println("hasService");
>
> viewContainer =
> (ViewContainer)getServiceManager().lookup("parentContainer");
> }
> }
>
> getServiceManager().hasService("parentContainer") returns
> true, but getServiceManager().lookup("parentContainer")
> throws exception:
>
> Exception: org.apache.avalon.framework.service.ServiceException
> Message: Unexpected runtime error while attempting to
> resolve service for key: parentContainer (Key='parentContainer')
>
> Here's a part of our block.xml:
>
> <component name="MainViewContainerImpl"
> class="com.mrt.vend.client.desktop2.view.MainViewContainerImpl">
> <parameters>
> <parameter name="language" value="pl"/>
> <parameter name="country" value="PL"/>
> </parameters>
> </component>
>
> <component name="LocationViewContainerImpl"
> class="com.mrt.vend.client.desktop2.view.LocationViewContainerImpl">
> <dependencies>
> <dependency key="parentContainer"
> source="MainViewContainerImpl" />
> </dependencies>
> </component>
>
> Could you help us? Is it a problem with merlin or we are
> using it in wrong way?
>
> Jarosław Pałka
> MRT-System
> Poland
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]