How do you create / initialize a Javassist ClassPool inside an OSGi package?

I created the Bundle in Eclipse and used the Run Frame link for the Browse tab. I created an interface (TestService) in my package and the code that should generate a proxy for it (in Helper). I call this code in the Package Activator and get:

Caused by: javassist.NotFoundException: com.test.services.TestService
at javassist.ClassPool.get(ClassPool.java:436)
at com.test.services.Helper.get(Helper.java:46)

It rushes right into the first class of ClassPool.get ():

ClassPool pool = ClassPool.getDefault();
CtClass result = pool.get(TestService.class.getName());
...

TestService is publicly available in the same package, and Bundle, as an assistant that throws an exception. Obviously, this is not enough to simply "ClassPool.getDefault ()". So what do I need to get ClassPool to consider classes inside the Bundle? Do I need to import my own packages?

+5
2

javassist OSGi / Java . . , .

+2

"source" - , bundle OSGi, "classpath" ( classloader) ClassPool, :

pool.insertClassPath(new ClassClassPath(source.getClass()));

pool.insertClassPath(new ClassClassPath(TestService.class));

, .

+10

All Articles