How to make Java Classes in Jira Plugin accessible to custom .JSP Pages

EthanML July 8, 2013

Hi there,

I'm working on bringing forward our custom Jira plugin forward to Jira 5.2.2 from Jira 4.1.2 .

The plugin just adds some links to the nav bar that point to some custom .jsp pages we've written, which are found in Jira's root.

I've updated all the API usage such as OSUser etc to meet new Jira standards, however I'm running in to an issue with the new version-2 type plugins - my jsp pages can't seem to access the Java classes contained in the plugin. Error given is "Only a type can be imported. com.blah.ClassX resolves to a package".

In the old version-1 plugin the plugin .jar was placed under WEB-INF/lib so the pages could access the code without a problem but obviously this is not the case with newer plugins.

I take it there is a way around this? From what I've read I suspect it may involve the use of either "Components" or "Webworks" but I don't know enough about either of these to really know how to get started.

My current atlassian-plugin.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>

<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
  <plugin-info>
    <description>${project.description}</description>
    <version>${project.version}</version>
    <vendor name="${project.organization.name}" url="${project.organization.url}"/>
    <param name="plugin-icon">images/pluginIcon.png</param>
    <param name="plugin-logo">images/pluginLogo.png</param>
  </plugin-info>
  <!-- add our i18n resource -->
  <resource type="i18n" name="i18n" location="companystabs"/>
  <!-- add our web resources -->
  <web-resource key="companytabs-resources" name="companytabs Web Resources">
    <dependency>com.atlassian.auiplugin:ajs</dependency>
    <resource type="download" name="companytabs.css" location="/css/companytabs.css"/>
<resource type="download" name="images/" location="/images"/> <context>companytabs</context>
</web-resource> <!-- import from the product container --> <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties"/> <web-section name="companyTabs" i18n-name-key="company-tabs.name" key="company-tabs" location="companyTabs" weight="1000">
<description key="company-tabs.description">The company Tabs Web-section</description>
<label key="company-tabs.label"/>
</web-section> <web-item name="Roadmap" i18n-name-key="roadmap.name" key="roadmap" section="system.top.navigation.bar" weight="1000"> <description key="roadmap.description">The company Roadmap menu item.</description>
<label key="roadmap.label"/> <link linkId="roadmap-link">/roadmap.jsp</link> </web-item> <web-item name="Service Packs" i18n-name-key="service-packs.name" key="service-packs" section="system.top.navigation.bar" weight="1000"> <description key="service-packs.description">The company Service Packs menu item.</description>
<label key="service-packs.label"/> <link linkId="service-packs-link">/supportRoadmap.jsp</link> </web-item> <web-item name="Research" i18n-name-key="research.name" key="research" section="system.top.navigation.bar" weight="1000"> <description key="research.description">The company Research menu item.</description>
<label key="research.label"></label> <link linkId="research-link">/researchList.jsp</link> </web-item> </atlassian-plugin>

Any suggestions?

Thanks

1 answer

1 accepted

2 votes
Answer accepted
Boris Georgiev _Appfire_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2013

Can you provide the source of your jsp. Do you need access to classes from JIRA or your own classes ?

You can just try to implement your jsps as webwork actions using velocity templates or you might be able to just point the action the the jsp without making it velocity file (buy putting it like that - <viewname="createuserissue">/templates/myjspfile.jsp</view> in the atlassian-plugin.xml.)

You can use these resources for reference :

https://developer.atlassian.com/display/JIRADEV/Webwork+plugin+module

https://bitbucket.org/mdoar/webwork-sample

I suggest that you first try to implement a "Hellow world" page and then try to plug your existing jsp there.

EthanML July 9, 2013

Hi Boris, thanks for responding.

The JSPs need access to our own classes, a large number of them located in the plugin under src/main/java/com/company/*classes* .

There are quite a number of JSPs and they're very long so I probably shouldn't post them here but it's all just pretty standard JSP stuff - at the top a bunch of 'import's for all the classes the page needs, then just snippets of code using these classes throughout the page and some include's .

I will look at those links and try and get my head around the webworks stuff now, thanks. Hopefully converting to using velocity isn't a lot of work or it probably won't be feasible here, or hopefully just pointing it to the JSP might work as you say.

Thanks,

Ethan

Séb P.
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 27, 2014

Did you find any solution? Having the same issue here...

Suggest an answer

Log in or Sign up to answer