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>
Community moderators have prevented the ability to post new answers.
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.
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.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this worked. Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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" />
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"/>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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); } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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<String, Object> propertiesMap = new HashMap<String, Object>(); propertiesMap.put("project", project); List<String> versions = new ArrayList<String>(); 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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I posted the same issue but no luck here as well.
https://answers.atlassian.com/questions/73952/project-administration-web-sections
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I reported this Issue a few month ago: https://jira.atlassian.com/browse/JRA-28946
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is giving the same exception even with jira-admin permission.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hasProjectHistory is returning true.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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());
}
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 comments please??
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 comments please??
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 comments please??
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 comments please??
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.