Plugin failed to load ServletContext in jira 5.
public static ServletContext servletContext = ServletContextProvider.getServletContext();
The above statement failed to load with sdk 4.
Community moderators have prevented the ability to post new answers.
OK, so JIRA HOME is working.
I can't give you a solution because it is environment specific. For example, you deploy a WAR version of JIRA, and then your 'application' path is what?
To be honest, if you're loading resources from the 'application' as opposed to JIRA_HOME, then putting them in atlassian-jira/WEB-INF/classes and loading via getClass().getClassloader().getResourcesAsStream("bla.props") is probably the simplest way to go, works in all containers and is not deployment specific.
Personally I think config files in JIRA_HOME would be the best solution. If you happen to have a JIRA_HOME folder inside or related to a standalone JIRA deployment folder, you could probably figure out where it lives.
I am getting NullPointerException.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Assuming a remote user interaction is underway, I use the following in JIRA 5:
ServletActionContext.getServletContext();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andy, I am getting the same NullPointerException with the call ServletActionContext.getServletContext();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please expand onthe context of use (in what JIRA area are you running, what are you trying to do?) its possible you don't have one if there is no actual user http session involved, eg a postfunction.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have a custom plugin for doing some backend operations like User clean ups etc. Here i need to read some text files which are residing on jira home directory. So i need context path from the ServletContext object as I dont have to hard code the path of our linux file system. In jira 4.4.5, i used older sdk where the below statement was working as desired.
public static ServletContext servletContext = ServletContextProvider.getServletContext();
but in sdk new SDK, my plugin failed to execute because of the non availability of ServletContextProvider class hence resulted in NullPointerException.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I remember i tried with JiraHome class but i got NullPointerException. Any way i will try again and let you know.
thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Loading resources located under your JIRA home directory is I think better done with: com.atlassian.jira.config.util.JiraHome
When you have one, use jiraHome.getDataDirectory()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Constructor injection. JIRA5 is what Im using, youve mentioed it, Im assuming you're using this also?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andy,
Could you please let me know how to get the reference of JiraHome in my class?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh. I forgot to mention that my plugin is actually a service. We are not using atlassian-plugin.xml file for the configurations. So i cannot use dependency injection here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does ComponentAccessor.getComponent(JiraHome.class); also give you null?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tested now and it is not returning Null but all the paths are related to Home directory. Could you please let me know how to get the paths of application without hardcoding?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andy,
Thanks for your suggestion. i moved all the static properties files to Home directory and accessed from there using the JiraHome reference, but i have one question. When indexing takes place, will it wash the conents of the home directory which results in the loss of our properties files?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, the data folder contains things like attachments, (JEMH uses it for email archives), it won't get purged due to indexing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
While I am not sure, I can attempt to help. What exception are you getting?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Atlassians,
Any update please??
-Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Atlassians,
Any update please??
-Thanks
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.