Bundling Velocity in a plugin does not work

Hello, I am trying to bundle velocity 1.5 in a new plugin I am creating.

When I do the normal velocity init:

try {
Velocity.init();
} catch (Exception e) {
e.printStackTrace();
}

I get the exception below. It works outside the plugin. I would guess this is a classloader problem.

Does anyone know of a solution? There must be one since I know some other plugins use Velocity.

Cheers,
Mikael Grev

java.lang.Exception: The specified class for ResourceManager (org.apache.velocity.runtime.resource.ResourceManagerImpl) does not implement org.apache.velocity.runtime.resource.ResourceManager; Velocity is not initialized correctly.
at org.apache.velocity.runtime.RuntimeInstance.initializeResourceManager(RuntimeInstance.java:589)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:241)
at org.apache.velocity.runtime.RuntimeSingleton.init(RuntimeSingleton.java:113)
at org.apache.velocity.app.Velocity.init(Velocity.java:83)
at com.miginfocom.beanpropertiesplugin.idea.WriteAccessorMethods.actionPerformed(WriteAccessorMethods.java:38)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:9)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.b(IdeKeyEventDispatcher.java:194)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:228)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:108)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:87)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

4 comments
Comment actions Permalink

Following is my code in iBATIS plugin, please try.
VelocityContext context = new VelocityContext();
context.put("package", JavaDirectoryService.getInstance().getPackage(psiDirectoryBean).getQualifiedName());
context.put("name", className);
context.put("tableName", tableData.getName());
List classFields = new ArrayList]]>();
for (DatabaseTableFieldData tableFieldData : tableData.getFields()) {
classFields.add(getClassField(tableFieldData));
}
context.put("fieldList", classFields);
StringWriter writer = new StringWriter();
VelocityEngine engine = new VelocityEngine();
engine.init();
engine.evaluate(context, writer, "iBATIS", new StringReader(config.beanTemplate));

0
Comment actions Permalink

Thanks. Unfortunately I get the same exception, now from engine.init();

I am using IDEA 7.0.4 with the corresponding IDEA plugin devkit.
Velocity 1.5 (both the main jar and the dependencies jar).

I am deploying the two jars using a Library and then marking it for export. Is there another way to include .jar dependencies in IDEA plugins?

Mikael

0
Comment actions Permalink

Do you include velocity.jar in your classpath, because IDEA has bundled it.

0
Comment actions Permalink

Thank You!

I did not know that IDEA had it bundled. That was the problem I had. It also means less baggage. :)

Mikael

0

Please sign in to leave a comment.