Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Exceptions while plugging into new Project Administration section

srinivasp
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.
August 9, 2012

I followed the same way mentioned in the documentation for adding a new tab to the project administration section and it is working. But in the logs i am getting the following exception when i access the page.

Exception
---------
[INFO] [talledLocalContainer] 2012-08-09 16:36:25,676 http-2990-2 ERROR admin 996x1486x1 71aiyo 10.105.180.24 /plugins/servlet/xproduct/admin [webwork.util.ValueStack] query="html" {[id="html" type="8" values=""]}
[INFO] [talledLocalContainer] java.lang.reflect.InvocationTargetException
[INFO] [talledLocalContainer]   at sun.reflect.GeneratedMethodAccessor452.invoke(Unknown Source)
[INFO] [talledLocalContainer]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[INFO] [talledLocalContainer]   at java.lang.reflect.Method.invoke(Method.java:597)
[INFO] [talledLocalContainer]   at webwork.util.InjectionUtils$DefaultInjectionImpl.invoke(InjectionUtils.java:70)
[INFO] [talledLocalContainer] Caused by: java.lang.IllegalStateException: The current project has not been set.
[INFO] [talledLocalContainer]   at com.atlassian.jira.projectconfig.util.ServletRequestProjectConfigRequestCache.getProject(ServletRequestProjectConfigRequestCache.java:25)
[INFO] [talledLocalContainer]   at com.atlassian.jira.projectconfig.contextproviders.ContextProviderUtils.getProject(ContextProviderUtils.java:57)
[INFO] [talledLocalContainer]   at com.atlassian.jira.projectconfig.contextproviders.ContextProviderUtils.getDefaultContext(ContextProviderUtils.java:81)
[INFO] [talledLocalContainer]   at com.atlassian.jira.projectconfig.contextproviders.HeaderContextProvider.getContextMap(HeaderContextProvider.java:61)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.web.descriptors.DefaultWebPanelModuleDescriptor$ContextAwareWebPanel.getHtml(DefaultWebPanelModuleDescriptor.java:141)
[INFO] [talledLocalContainer]   at com.atlassian.jira.web.sitemesh.AdminDecoratorHelper$Header.getHtml(AdminDecoratorHelper.java:194)
[INFO] [talledLocalContainer]   ... 137 more
Servlet
-------
@Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
    {
    	String username = userManager.getRemoteUsername(request);
        if (username != null && !userManager.isSystemAdmin(username)){
            redirectToLogin(request, response);
            return;
        }
        Project project = historyManager.getCurrentProject(
				Permissions.PROJECT_ADMIN,
				authenticationContext.getLoggedInUser());
        Map<String, Object> propertiesMap = new HashMap<String, Object>();
		propertiesMap.put("project", project);
        response.setContentType("text/html;charset=utf-8");
        renderer.render("admin.vm", propertiesMap, response.getWriter());
    }
admin.vm
---------
<head>
    <title>$i18n.getText("version.admin.label")</title>
    <meta name="decorator" content="admin" />
    <meta name="application-base-url" content="$applicationProperties.getBaseUrl()">
	<meta name="projectKey" content="$project.getKey()"/>
    <meta name="projectId" content="$project.getId()"/>
    <meta name="admin.active.tab" content="xproduct-admin-link"/>
    <meta name="admin.active.section" content="atl.jira.proj.config"/>
    $webResourceManager.requireResource("com.atlassian.plugins.tutorial.xproduct-admin-ui-plugin:resources")
  </head>

11 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

4 votes
Answer accepted
Akira Tsuchiya
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.
April 26, 2013

Hello,

1. I have never used Servlet as the Controller Class in the Project Configuration Tab Panel.
So I am not sure on how to correctly configure the MVC model when using Servlet as the Controller
in the JIRA plugin architecture.
I always use JiraWebActionSupport, not Servlet, as the Controller.

2. From your test result mentioned above, JIRA does not seem to pass HTTP request parameter(object)
from Servlet Controller to Velocity View only with the code below.

request.setAttribute("project", project);

3. So try and add the code snippet below in addition to the code above.
request.setAttribute("com.atlassian.jira.projectconfig.util.ServletRequestProjectConfigRequestCache:project", project);

4. Let me know the test result.

srinivasp
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.
April 29, 2013

Awesome.. I tried step 3 and there are no exceptions now. I am able to see the project header as well on this page but the only issue now is under the project header, "key", "URl" and "Category" are appearing as bullet points instead of rendering on a single line. Could you please let me know how to render the items(key, url, category) on a single line which is how it was coming for the other options(summary, issue types etc.)

IshanL
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 14, 2013

this worked. Thanks

1 vote
Akira Tsuchiya
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.
April 29, 2013

Step 1. Edit the atlassian-plugin.xml.

Step 1-1. Find the <web-resource> tab with the key of 'resources' in the atlassian-plugin.xml.
Comment out the original <web-resource key="resources"> section.
Add the new <web-resource key="resources"> section as below.
If no <web-resource> is defined, just add it.

<web-resource key="resources" name="Test Resources">
<dependency>jira.webresources:autocomplete</dependency>
<dependency>jira.webresources:jira-fields</dependency>
<dependency>com.atlassian.jira.jira-project-config-plugin:project-config-global</dependency>
<dependency>com.atlassian.gadgets.embedded:gadget-standalone-resources</dependency>
<transformation extension="js">
<transformer key="jsI18n"/>
</transformation>
<transformation extension="soy">
<transformer key="jiraSoyTransformer"/>
</transformation>
<dependency>com.atlassian.jira.jira-soy-plugin:soy-deps</dependency>
</web-resource>

Step 1-2. Confirm that atlassian-plugin key is described as below.
<atlassian-plugin key="com.atlassian.plugins.tutorial.xproduct-admin-ui-plugin" ***>

Step 2. Edit the admin.vm.

Change the <meta name="decorator"/> tab from 1 to 2.
1. <meta name="decorator" content="admin" />
2. <meta name="decorator" content="atl.admin" />

srinivasp
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.
April 30, 2013

Hi Akira, In my web-resource section, few dependencies are missed and so i added them in the atlassian-plugin.xml file. Now I am able to see the header properly alined on pages. Thank you for posting the required code. You really saved me alot. Much appreciated!

1 vote
Akira Tsuchiya
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.
April 25, 2013

I think that the problem happens because the Servlet does not correctly
pass the 'project' instance to the Velocity Servlet.
Due to this issue, the error below is printed in the log.

[Caused by: java.lang.IllegalStateException: The current project has not been set.]

To avoid the issue, try the [Code Snippet 2] or [Code Snippet 3] instead of [Code Snippet 1].
If you encounter this problem again, let me know.

[Code Snippet 1]
Map<String, Object> propertiesMap = new HashMap<String, Object>();
propertiesMap.put("project", project);

[Code Snippet 2]
request.setAttribute("project", project);

[Code Snippet 3]
[Servlet:]
String projectKey = project.getKey();
long projectId = project.getId();
request.setAttribute("projectKey", projectKey);
request.setAttribute("projectId", projectId);
[admin.vm:]
<meta name="projectKey" content="$projectKey"/>
<meta name="projectId" content="$projectId"/>

srinivasp
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.
April 26, 2013

Hi Akira,

Thank you for your comment. I have tried the third way but I got the same exception. Could you please let me know how to access the project object on the VM file mentioned in Code snippet 2(i.e. setting the project to request object)?

Also I found couple of issues

1. Project header is not aligned propertly.

2. There is no header on the page which was redirected from the actual page.

I tried to attach images but unfortunately the Image link on AAC is not functioning.

0 votes
Eric Dalgliesh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 24, 2012

A possible cause of this is that this exception occurs when there is no current project but the current project is attempted to be retrieved. That method (getSelectedProjectObject) should not be used in the global admin decorator because there are many pages without a current project (for example, the create user page). Instead you should only call it on your specific pages - not in the decorator.

What should be done is something like what ReturnToConfigContextProvider does:

final String projectKey = (String) session.getAttribute(SessionKeys.CURRENT_ADMIN_PROJECT);

if (StringUtils.isNotBlank(projectKey))
{
    final ProjectService.GetProjectResult projectResult = projectService.getProjectByKeyForAction(authenticationContext.getLoggedInUser(), projectKey, ProjectAction.EDIT_PROJECT_CONFIG);
    if (projectResult.isValid())
    {
        final Project project = projectResult.getProject();
        contextBuilder.add("project", project);
    }
}


srinivasp
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.
November 8, 2012

Hi Eric, I am still getting the same exception.

HttpSession session = request.getSession();
        final String projectKey = (String) session.getAttribute(SessionKeys.CURRENT_ADMIN_PROJECT); 
        System.out.println("projectKey :: "+projectKey);
        ProjectService projectService = ComponentManager.getComponent(ProjectService.class);
        if (StringUtils.isNotBlank(projectKey)){    
        	final ProjectService.GetProjectResult projectResult = projectService.getProjectByKeyForAction(authenticationContext.getLoggedInUser(), projectKey, ProjectAction.EDIT_PROJECT_CONFIG);    
        	if (projectResult.isValid())    { 
        		final Project project = projectResult.getProject();
        		 Map&lt;String, Object&gt; propertiesMap = new HashMap&lt;String, Object&gt;();
        		 propertiesMap.put("project", project);
        			List&lt;String&gt; versions = new ArrayList&lt;String&gt;(); 
        					
        			for(Version version : project.getVersions()){
        				if(!version.isArchived())
        					versions.add(version.getName());
        			}
        			
        			Collections.reverse(versions);
        			propertiesMap.put("versions", versions);
        			response.setContentType("text/html;charset=utf-8");
        	        renderer.render("admin.vm", propertiesMap, response.getWriter());
        	}
        }

Is this cause for the missing title?

srinivasp
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.
November 8, 2012
0 votes
ConradR
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.
October 21, 2012

I reported this Issue a few month ago: https://jira.atlassian.com/browse/JRA-28946

0 votes
MattS
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.
August 16, 2012

I bet it's either a permission problem - does it work if someone with jira admin permission runs it? Or maybe a bug in how some projects are cached somewhere.

srinivasp
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.
August 16, 2012

It is giving the same exception even with jira-admin permission.

0 votes
brainicorn
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 15, 2012

I believe this error is caused because you're trying to get the project from the history before and history has been created.

You should probably do:

historyManager.hasProjectHistory(Permissions.PROJECT_ADMIN,
                authenticationContext.getLoggedInUser())

before you call getCurrentProject to make sure there's a history

srinivasp
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.
August 16, 2012

hasProjectHistory is returning true.

srinivasp
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.
August 16, 2012

I tried this way also but it is giving the same exception.

Project project = ComponentManager.getComponentInstanceOfType(ProjectManager.class).getProjectObjByKey(projectKey);

Map<String, Object> propertiesMap = new HashMap<String, Object>();

propertiesMap.put("project", project);

propertiesMap.put("version", selectedVersion);

response.setContentType("text/html;charset=utf-8");

if(flag.equalsIgnoreCase("details")){

renderer.render("releaseinfo.vm", propertiesMap, response.getWriter());

}

0 votes
srinivasp
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.
August 14, 2012

Hi Atlassians, Any comments please??


0 votes
srinivasp
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.
August 13, 2012

Hi Atlassians, Any comments please??

0 votes
srinivasp
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.
August 10, 2012

Hi Atlassians, Any comments please??

0 votes
srinivasp
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.
August 9, 2012

Hi Atlassians, Any comments please??

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events