I am trying to use a velocity template for a simple configuration form for a plugin. According to dpcumentation and tutorials, placing the velocity template under the src/main/resources directory in of the maven project structure. This seemed to work when developping the plugin and it runs as expected via the SDK atlas-run but will not work when loading the plugin in my test JIRA instance.
In the test JIRA instance the plugin loads and work as expected but when trying to access the configuration serlvet, a "Content Encoding Error" shows instead. As per the log, it seems the TemplateRenderer cannot find the jirabot.vm template:
Caused by: org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'jirabot.vm' at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:483) at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:354) at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1400) at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1380) at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:401)
Here are the relevant portions of the atlassian-plugin.xml:
<web-resource key="jirabot-resources" name="jirabot Web Resources"> <dependency>com.atlassian.auiplugin:ajs</dependency> <resource type="download" name="jirabot.css" location="/css/jirabot.css"/> <resource type="download" name="jirabot.js" location="/js/jirabot.js"/> <resource type="download" name="images/" location="/images"/> <context>jirabot</context> </web-resource> <servlet name="botadmin" i18n-name-key="botadmin.name" key="botadmin" class="org.teamcascade.plugins.jirabot.servlet.BotAdminServlet"> <description key="botadmin,description">IRC Bot Administration</description> <url-pattern>/botadmin</url-pattern> </servlet>
Anyone has any idea why the vlocity template can be found when running in the SDK and not in a live test instance of JIRA? Both the SDK run and the JIRA test instance are on version 5.2.8.
Thanks in advance
Community moderators have prevented the ability to post new answers.
If you have the velocity file under src/main/resources it should end up in the ROOT folder of the jar. Not under a resources directory
Maybe post your pom.xml might help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Colin: Thanks that should help locate the problem knowing where it should be to start with. I assume the SDK finds it because of the FastDev somehow. The only thing in the main directory of the JAR is the atlassian-plugin.xml at the moment it seems.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Colin: Thanks a lot for pointing me to my POM.xml. The error was caused by a <resource> filter in the <Build> section that was moving the .vm file to another location in the JAR. Just in case someone else is lazy like me and start a project based on another project POM hehe
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Colin: Thanks a lot for pointing me to my POM.xml. The error was caused by a <resource> filter in the <Build> section that was moving the .vm file to another location in the JAR. Just in case someone else is lazy like me and start a project based on another project POM:)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The error message "Content Encoding Error" makes me wonder whether the template is encoded in the way that Velocity expects. By default, Velocity expects templates to be encoded as "ISO-8859-1"; could it be that your template is encoded otherwise?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Colin: I just checked and the .vm file is in the jar under the resources/../ directory structure in the JAR. What really baffles me is that it runs fine with atlas-run. I use IDEA as an IDE usually to compile (in case there are known cavats) but even when trying to load the plugin jar generated by atlas-run I still get that error in the log. Is there any transformation done by the plugin loader (OSGi or otherwise) that would make a difference between the SDK run and an actual JIRA instance?
David: That was my first avenue of research but finally realized it wasnt loading the template at all when in the test instance.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is the .vm file definitely being added to the plugin jar file?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.