Project: springxd
Issue XD-2927: Can't use Apache Velocity in custom modules
Creating a custom processor module with Apache Velocity (org.apache.velocity:velocity:1.7) as dependency results in {{java.lang.ClassNotFoundException}} during stream deployment: {code} 2015-04-08 17:35:32,595 1.1.1.RELEASE INFO DeploymentsPathChildrenCache-0 server.DeploymentListener - Deploying module [ModuleDescriptor@144d1f50 moduleName = 'custom-velocity-processor', moduleLabel = 'custom-velocity-processor', group = 'velocity-stream', sourceChannelName = [null], sinkChannelName = [null], index = 1, type = processor, parameters = map[[empty]], children = list[[empty]]] 2015-04-08 17:35:32,768 1.1.1.RELEASE WARN DeploymentsPathChildrenCache-0 support.DefaultListableBeanFactory - FactoryBean threw exception from getObjectType, despite the contract saying that it should return null if the type of its object cannot be determined yet java.lang.NoClassDefFoundError: org/apache/velocity/app/VelocityEngine org.springframework.ui.velocity.VelocityEngineFactoryBean.getObjectType(VelocityEngineFactoryBean.java:69) org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getTypeForFactoryBean(FactoryBeanRegistrySupport.java:66) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:795) org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:542) org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:436) org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:404) org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:398) org.springframework.integration.jmx.config.JmxIntegrationConfigurationInitializer.registerMBeanExporterHelperIfNecessary(JmxIntegrationConfigurationInitializer.java:42) org.springframework.integration.jmx.config.JmxIntegrationConfigurationInitializer.initialize(JmxIntegrationConfigurationInitializer.java:38) org.springframework.integration.config.IntegrationConfigurationBeanFactoryPostProcessor.postProcessBeanFactory(IntegrationConfigurationBeanFactoryPostProcessor.java:48) org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:265) org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:177) org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691) org.springframework.boot.SpringApplication.run(SpringApplication.java:321) org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139) org.springframework.xd.module.core.SimpleModule.initialize(SimpleModule.java:214) org.springframework.xd.dirt.module.ModuleDeployer.doDeploy(ModuleDeployer.java:217) org.springframework.xd.dirt.module.ModuleDeployer.deploy(ModuleDeployer.java:200) org.springframework.xd.dirt.server.DeploymentListener.deployModule(DeploymentListener.java:363) org.springframework.xd.dirt.server.DeploymentListener.deployStreamModule(DeploymentListener.java:332) org.springframework.xd.dirt.server.DeploymentListener.onChildAdded(DeploymentListener.java:179) org.springframework.xd.dirt.server.DeploymentListener.childEvent(DeploymentListener.java:147) org.apache.curator.framework.recipes.cache.PathChildrenCache$5.apply(PathChildrenCache.java:509) org.apache.curator.framework.recipes.cache.PathChildrenCache$5.apply(PathChildrenCache.java:503) org.apache.curator.framework.listen.ListenerContainer$1.run(ListenerContainer.java:92) com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:297) org.apache.curator.framework.listen.ListenerContainer.forEach(ListenerContainer.java:83) org.apache.curator.framework.recipes.cache.PathChildrenCache.callListeners(PathChildrenCache.java:500) org.apache.curator.framework.recipes.cache.EventOperation.invoke(EventOperation.java:35) org.apache.curator.framework.recipes.cache.PathChildrenCache$10.run(PathChildrenCache.java:762) java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) java.util.concurrent.FutureTask.run(FutureTask.java:262) java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) java.util.concurrent.FutureTask.run(FutureTask.java:262) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: org.apache.velocity.app.VelocityEngine java.net.URLClassLoader$1.run(URLClassLoader.java:366) java.net.URLClassLoader$1.run(URLClassLoader.java:355) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(URLClassLoader.java:354) java.lang.ClassLoader.loadClass(ClassLoader.java:425) sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) java.lang.ClassLoader.loadClass(ClassLoader.java:358)	... 39 more {code} Attached is module source code. Executing commands in {{xd-shell-commands.cmd}} file is enough to trigger the exception. Everything works when velocity jar is placed in {{$XD_HOME/lib}} and excluded from the processor module.
Story points: 1