This is a class loading error (as most errors in OSGi :)). Velocity is a separate bundle, so perhaps Cayenne can't see it for some reason. In the GitHub example the following Velocity bundle is in use:
install file:/Users/cayenne/.m2/repository//org/apache/servicemix/bundles/org.apache.servicemix.bundles.velocity/1.7_6/org.apache.servicemix.bundles.velocity-1.7_6.jar Perhaps you should try it too? Andrus > On Apr 21, 2015, at 3:50 PM, mporru <matteo.po...@abodata.com> wrote: > > Hi all, > I'm trying version 4.0.0.M2 under OSGi (Equinox). Following the example I > found here: > https://github.com/andrus/cayenne-osgi-example > > I have added to my workspace three bundles: > - org.apache.cayenne.server, > - org.apache.cayenne.di > - and finally the third-parties jars included into the package: > commons-collections-3.2.1.jar, commons-logging-1.1.jar, velocity-1.6.3.jar, > vpp-2.2.1.jar. > These has been added also as dependencies to the previous two bundles. > > I'm able to compile and properly start all the bundles above. Initialization > is done as follows: > Module osgiModule = > OsgiModuleBuilder.forProject(Activator.class).withDriver(Driver.class).module(); > myRuntime = ServerRuntime("cayenne-osgi-example.xml", osgiModule); > > When I invoke: *myRuntime.newContext();* the following exception is thrown: > *java.lang.reflect.InvocationTargetException - Error instantiating class > 'org.apache.cayenne.velocity.VelocitySQLTemplateProcessor'* > > Digging in a little bit with the source code I can see the that the erro is > thrown at org.apache.cayenne.di.spi.ConstructorInjectingProvider<T>.get() as > follows: > * > org.apache.velocity.exception.VelocityException: The specified class for > ResourceManager (org.apache.cayenne.velocity.SQLTemplateResourceManager) > does not exist or is not accessible to the current classloader.* > > If I'm reading this correctly the environment is missing > SQLTemplateResourceManager... but double checking it, I see the class is > inside the org.apache.cayenne.server package itself (which apprently is > started correctly). > > Can anyone please give me some hints? > Thanks and BR, > Matteo > > > > -- > View this message in context: > http://cayenne.195.n3.nabble.com/Cayenne-4-0-M2-and-OSGi-classloading-issue-tp4026812.html > Sent from the Cayenne - Dev mailing list archive at Nabble.com. >