You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bval.apache.org by "Florian Pirchner (JIRA)" <ji...@apache.org> on 2015/03/04 16:45:04 UTC
[jira] [Created] (BVAL-135) Using bval-guice in OSGi
Florian Pirchner created BVAL-135:
-------------------------------------
Summary: Using bval-guice in OSGi
Key: BVAL-135
URL: https://issues.apache.org/jira/browse/BVAL-135
Project: BVal
Issue Type: Bug
Reporter: Florian Pirchner
Hi,
tried to use bval-guice in OSGi environments. Added @org.apache.bval.guice.Validate to an OSGi service method. But getting class loader problems.
Sample code:
{code:title=OSGiService.java|borderStyle=solid}
public class RepositoryService implements IRepositoryService {
@Override
@Validate(validateReturnedValue = true)
public void addToRepository(@NotNull String name) {
System.out.println("Called with " + name);
}
}
{code}
While the service method is invoked, the class org.apache.bval.jsr303.ClassValidator#unwrap(Class<T> type) tries to load the class org.apache.bval.jsr303.extensions.MethodValidatorImpl. It is contained in the same bundle, so OSGi should not have a problem loading it.
But the impl delegates the loading to ClassUtils.getClass(type.getName() + "Impl"). Since ClassUtils is part of the bundle commons-lang3, the class can not be loaded and an Exception is thrown.
Maybe you could change the call to ClassUtils.getClass(getClass().getClassLoader(), type.getName() + "Impl") and everything should be fine.
Thanks, Florian
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)