avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leif Mortenson <l...@silveregg.co.jp>
Subject Minor bug in ExcaliburComponentSelector when there is a configuration problem
Date Wed, 30 Jan 2002 08:33:40 GMT
I wanted whoever wrote the ExcaliburComponentSelector (Berin?) to take a
look at this and decide whether or not to fix it before the release (It
can probably wait). Given that this is a critical class.

I had a configuration error in my components.xml file. It was in a jdbc
definition within a datasources selector block. When I tried to start
the application, the DataSource threw a ConfigurationException on
startup. The problem is, that this is the stack trace that gets dumped.

---
1012378110164 ERROR [cm ]: The component instance for
'asp-service-visitor-cluster' has an invalid class name.
org.apache.avalon.framework.component.ComponentException: Could not set
up Component for hint: asp-service-visitor-cluster
at
org.apache.avalon.excalibur.component.ExcaliburComponentSelector.addComponent(ExcaliburComponentSelector.java:465)
at
org.apache.avalon.excalibur.component.ExcaliburComponentSelector.configure(ExcaliburComponentSelector.java:354)
at
org.apache.avalon.excalibur.component.DefaultComponentFactory.newInstance(DefaultComponentFactory.java:172)
at
org.apache.avalon.excalibur.component.ThreadSafeComponentHandler.initialize(ThreadSafeComponentHandler.java:84)
at
org.apache.avalon.excalibur.component.ExcaliburComponentManager.lookup(ExcaliburComponentManager.java:331)
at
com.silveregg.nikko.rserver.service.DatabaseProfileRepository.initialize(DatabaseProfileRepository.java:151)
at
org.apache.avalon.excalibur.component.DefaultComponentFactory.newInstance(DefaultComponentFactory.java:183)
rethrown from
org.apache.avalon.framework.configuration.ConfigurationException:
Expected a dbpool with index="2"
at
org.apache.avalon.excalibur.datasource.cluster.AbstractDataSourceCluster.configure(AbstractDataSourceCluster.java:145)
at
org.apache.avalon.excalibur.component.DefaultComponentFactory.newInstance(DefaultComponentFactory.java:172)
at
org.apache.avalon.excalibur.component.ThreadSafeComponentHandler.initialize(ThreadSafeComponentHandler.java:84)
at
org.apache.avalon.excalibur.component.ExcaliburComponentSelector.addComponent(ExcaliburComponentSelector.java:448)
at
org.apache.avalon.excalibur.component.ExcaliburComponentSelector.configure(ExcaliburComponentSelector.java:354)
at
org.apache.avalon.excalibur.component.DefaultComponentFactory.newInstance(DefaultComponentFactory.java:172)
at
org.apache.avalon.excalibur.component.ThreadSafeComponentHandler.initialize(ThreadSafeComponentHandler.java:84)
---

This error message is misleading because it says that a class was
misnamed, when the real problem was a configuration exception.
The problem is being caused by the following code in
ExcaliburComponentSelector.configure(). The call to addComponent is
throwing a ConfigurationException.
---
try
{
final Class clazz = m_loader.loadClass( className );
addComponent( hint, clazz, instances[i]);
}
catch( final Exception e )
{
final String message =
"The component instance for '" + hint + "' has an invalid class name.";
if (getLogger().isErrorEnabled())
{
getLogger().error( message, e );
}

throw new ConfigurationException( message, e );
}
---

I think that the code should be changed to something like this:

---
try
{
final Class clazz = m_loader.loadClass( className );
addComponent( hint, clazz, instances[i]);
}
catch( final ClassNotFoundException e )
{
final String message =
"The component instance for '" + hint + "' has an invalid class name.";
if (getLogger().isErrorEnabled())
{
getLogger().error( message, e );
}

throw new ConfigurationException( message, e );
}
catch( final Exception e) // Could just be ComponentException??
{
final String message =
"The component instance for '" + hint + "' could not be initialized.";
if (getLogger().isErrorEnabled())
{
getLogger().error( message, e );
}

throw new ConfigurationException( message, e );
}
---

The ExcaliburComponentManager class has the same problem.

Cheers,
Leif


--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message