On Jun 29, 2010, at 7:22 AM, Karan Malhi wrote:
> I gave a wrong ejb class name in the <ejb-class> element, was hoping to get
> a ValidationFailedException. However, Validation was never even invoked and
> the AppModulePreProcessor (which is higher up in the chain) threw an
> OpenEJBException.
> *Here is what I was trying to do:*
>
> EjbJar ejbJar = *new* EjbJar();
>
> StatelessBean *bean* = ejbJar.addEnterpriseBean(*new* StatelessBean(
> "wrongClass", "WrongClass"));
>
> config.configureApplication(ejbJar);
>
>
> *Here is the code(*AppModulePreProcessor.deploy() *) which throws the
> Exception. *
>
>
> *try* {
>
> clazz = classLoader.loadClass(bean.getEjbClass());
>
> } *catch* (ClassNotFoundException e) {
>
> *throw* *new* OpenEJBException("Unable to load bean class: " +
> bean.getEjbClass(), e);
>
> }
>
>
>
> The above scenario kind of does not give the user an opportunity to use the
> validation feature.
Right. It should be fixed in some way definitely. The how is less obvious.
I seem to recall at one point the code before that particular part of
validation did not throw an exception and simply ignored it so it would be
caught later.
Perhaps the most straight forward thing is to replace the throws with a
validation failed() call and exit the related loop or method.
The other approach might be to do it very early and potentially remove all the
related beans, classes, etc. But that seems like it might result in the kind
of awkward failure messages you get from java compiler -- I guess depending on
what was removed.
-David