Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

TeamPlatform.shutdown(): cannot shutdown

Hi,

I got a problem with TeamPlatform.shutdown(). I have a widget with a button "Show Available Project Areas". The button has a listener that calls the following method

public List<String> getProjectAreas(){
List<String> projectAreas = null;

TeamPlatform.startup();
try {
// code for login and retrieving active project areas

} catch (Exception x) {
x.printStackTrace();
} finally {
if (TeamPlatform.isStarted()) {
TeamPlatform.shutdown();
}

}
return projectAreas;
}

The button event listener that calls the method is:
availableProjectAreas.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event){

List<String> projectAreas = getProjectAreas();

}
});


The problem is: I click the button for the first time, everything is ok. Then I click it for a second time, I got exceptions as:
Exception in thread "main" java.lang.IllegalStateException: Already stopped
at com.ibm.team.repository.common.internal.util.InternalTeamPlatform.shutdown(InternalTeamPlatform.java:112)
at com.ibm.team.repository.client.TeamPlatform.shutdown(TeamPlatform.java:60)
at com.ibm.team.workitem.ide.ui.example.widgets.GroupRTC.getProjectAreas(GroupRTC.java:144)

GroupRTC.java:144 is the line TeamPlatform.shutdown() in the finally block.

Can I ask here that if TeamPlatform.isStarted() returns true, why TeamPlatform.shutdown() throws an exception as "Already stopped"?

thank you very much
Lin

1

1 vote



8 answers

Permanent link

You should start the TeamPlatform when your application starts and shut
it down when your application ends.


I'm also seeing the same problem. I don't think the previous response answers the question / issue.

1 vote


Permanent link
I'm also seeing the same problem. I don't think the previous response
answers the question / issue.

It doesn't make sense to start and stop the platform within a method.

The TeamPlatform lifecycle should correspond to the application's
lifecycle in most cases. If this is not possible in your case, please
create a defect for this issue on jazz.net.

--
Regards,
Patrick
Jazz Work Item Team

1 vote


Permanent link
Hi,

I got a problem with TeamPlatform.shutdown(). I have a widget with a button "Show Available Project Areas". The button has a listener that calls the following method ]

Jazz team, please check this answer, since it may have changed in recent releases: You should skip the call to shutdown() altogether.

This has been a bug in TeamPlatform.shutdown() since the first release of RTC. I haven't checked the recent source code, but in earlier versions, there weere two private boolean variables "isStarted" and "isStopped"; both were initialized to false. Starting the team platform changes "isStarted" to true, but doesn't change isStopped. TeamPlatform.shutdown() checks whether the internal boolean "isStopped" is true or false. If it's false, it sets it to true, but doesn't really do anything else (which is why you can skip calling it during your program, and at the end of the program, garbage collection and other shutdown code takes care of releasing resources). If it's true, it throws the exception you're getting. But after that first time, it will always be true because TeamPlatform.startup() doesn't reset "isStopped" to false.

This is significant if, for example, you're calling the code from a servlet. You need to start the platform the first time the servlet executes, but if you stop it in your servlet code, you'll get the exception when another user calls the servlet.

1 vote


Permanent link
Hi,

I had the same problem when trying to execute TeamPlatform.startup() the second time via a servlet.
java.lang.IllegalStateException: Already stopped    
at com.ibm.team.repository.common.internal.util.InternalTeamPlatform.shutdown(InternalTeamPlatform.java:113)    
at com.ibm.team.repository.client.TeamPlatform.shutdown(TeamPlatform.java:61)
Surprisingly it works fine if you implement it as a standalone java program .i.e. called in the main (method) thread.

For my servlet I basically just commented out the following line:
if(TeamPlatform.isStarted())TeamPlatform.shutdown();
	

Not sure what the actual problem is though.

1 vote

Comments
I found these:

But I still encountered the same problem, though my RTC version is 6.0.3 :
java.lang.IllegalStateException: Already stopped
at com.ibm.team.repository.common.internal.util.InternalTeamPlatform.shutdown(InternalTeamPlatform.java:120)
at com.ibm.team.repository.client.TeamPlatform.shutdown(TeamPlatform.java:63)


Why would you want to comment on an 8 year old answer?


Permanent link
I have the same problem. Maybe a defect (e.g. some field isn't correctly setted when are called startup() and/or shutdown() methods)?

0 votes


Permanent link
public List<String> getProjectAreas(){
List<String> projectAreas = null;

TeamPlatform.startup();
try {
// code for login and retrieving active project areas

} catch (Exception x) {
x.printStackTrace();
} finally {
if (TeamPlatform.isStarted()) {
TeamPlatform.shutdown();
}

}
return projectAreas;
}

You should start the TeamPlatform when your application starts and shut
it down when your application ends.

--
Regards,
Patrick
Jazz Work Item Team

0 votes


Permanent link
I am using RTC 3.0.1 server and client,and we we first call TeamPlatform.startup() method before we process our xml artfacts in a method in our JAVA business logic.When we are done processing artifacts we call TeamPlatform.shutdown() method after checking if TeamPlatform.isStarted() or not ,(but in the same method)

processArtifact{
TeamPlatform.startup();
try{
//logic to process artfacts in a for loop
}
catch(){}
finally {
if (TeamPlatform.isStarted())
TeamPlatform.shutdown();
}
}
Its fine for the first artifact,but for others it throws this error
Throwable occurred: java.lang.IllegalStateException: Already stopped
at com.ibm.team.repository.common.internal.util.InternalTeamPlatform.shutdown(InternalTeamPlatform.java:113)
at com.ibm.team.repository.client.TeamPlatform.shutdown(TeamPlatform.java:61)

Can this TeamPlatform.shutdown(); method in the finally clause
be commented out totally or do we still need this at the end of the application but maybe in a different method?

0 votes


Permanent link
We are also encountering this problem. I searched for an existing RTC Defect, but didn't find one. So I created RTC Defect 173878.

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Mar 24 '10, 4:11 p.m.

Question was seen: 12,956 times

Last updated: Jul 05 '21, 6:29 a.m.

Confirmation Cancel Confirm