bval-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Florian Pirchner (JIRA)" <j...@apache.org>
Subject [jira] [Created] (BVAL-135) Using bval-guice in OSGi
Date Wed, 04 Mar 2015 15:45:04 GMT
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)

Mime
View raw message