How initialize a platform for PlatformContext.getPlatform()

Description
perlu
Posts: 3
Joined: Thu Jul 26, 2018 6:56 am

How initialize a platform for PlatformContext.getPlatform()

Postby perlu » Thu Jul 26, 2018 7:21 am

Hello all,

I would like to modify a work Item for my project.
For that i use :

Code: Select all

ITransactionService ITS = PlatformContext.getPlatform().lookupService(ITransactionService.class);
if(ITS.canBeginTx())
                  {
                     System.out.println(" IN ==> ITS.canBeginTx()");
                     ITS.beginTx();
                     this.wi.setTitle("TOTO");
                     ITS.commitTx();
                  }

But i have a exception : Platform was not initialized yet.

I'm serched in the API how to initialized a platforme and i found : PlatformContext.initPlatform((IPlatform));

But what is a IPlatform? it is a reference to Polarion instance? I'm a little bit lost.

Do you have a track?

Best Regards
Perlu

dan7777777
Posts: 13
Joined: Wed May 17, 2017 5:08 pm

Re: How initialize a platform for PlatformContext.getPlatform()

Postby dan7777777 » Thu Aug 02, 2018 12:57 pm

Not sure if this will help you, but I have always added a cast to that object and it works for me:

ITransactionService transactionService = (ITransactionService) PlatformContext.getPlatform().lookupService(ITransactionService.class);

perlu
Posts: 3
Joined: Thu Jul 26, 2018 6:56 am

Re: How initialize a platform for PlatformContext.getPlatform()

Postby perlu » Wed Aug 22, 2018 11:29 am

Thank you dan7777777 for your answer but it's the same for me. I have the same exception.


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 12 guests