Hi xwiki-users,
I seem to be having trouble including JARs in my Groovy classpath. I'm
trying the following:
{{groovy jars="attach:test-1.0.jar"}}
try {
def x = Class.forName("com.test.TestMe")
out.println(x)
}
catch(e) {
out.println("FAILURE: " + e)
}
{{/groovy}}
This ends up with the text "FAILURE: ClassNotFoundException", but if I
change the first line to:
Class.forName("com.test.TestMe", false, this.getClass().getClassLoader())
it seems to work. But, when I try this instead:
{{groovy jars="attach:wiki:Sandbox.Test"}}
try {
def x = Class.forName("com.test.TestMe", false,
this.getClass().getClassLoader())
out.println(x)
}
catch(e) {
out.println("FAILURE: " + e)
}
{{/groovy}}
it "red-boxes" me with a NullPointerException at the end (at
com.xpn.xwiki.doc.DefaultDocumentAccessBridge.getAttachmentContent(DefaultDocumentAccessBridge.java:510)).
And, same issue if I try it without the ClassLoader.
Ultimately, I'm trying to wrap this in a WikiMacro, but none of these
options work if I put the code in a WikiMacro object. Anyone have luck with
JAR attachments? Thanks in advance!
Show replies by date