cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

com.mks.api.response.CommandException raised in Java API does not provide any error information

amatei
12-Amethyst

com.mks.api.response.CommandException raised in Java API does not provide any error information

Hi,

We are using Integrity Client 11.0.0.506 and Java API 4.16.506

 

When executing  the SI projectco command it throws "com.mks.api.response.CommandException"

which unfortunately contains no obvious useful fields about the error

 

I would expect to know  if the member is not found or if access to member is denied

 

The exception's getMessage() and getLocalizedMessage() methods returns null.

 

Also if I serialize the exception to string I get nothing, the result is ""

StringWriter stringWriter = new StringWriter();
ex.printStackTrace(new PrintWriter(stringWriter));
String details = stringWriter.toString();

 

Can someone provide some hints ?

 

IntegrationPointFactory factory = IntegrationPointFactory.getInstance();
IntegrationPoint integrationPoint = factory.createLocalIntegrationPoint(APIVersion.API_4_16);
integrationPoint.setAutoStartIntegrityClient(true);
Session session = integrationPoint.getCommonSession();

 CmdRunner cmdRunner = this.session.createCmdRunner();

 cmdRunner.setDefaultUsername("userNameX");

 cmdRunner.setDefaultHostname("hostNameX");

 cmdRunner.setDefaultPort(portNumber);

 

 Command cmd = new Command(Command.SI,"projectco");


cmd.addOption(new Option("project","....project path"));
cmd.addSelection(new Option("overwriteExisting"));
cmd.addSelection(new Option("nolock"));
cmd.addOption(new Option("targetfile","c:\\temp\\abc.txt"));

cmd.addSelection("fileMember.txt");
Response response = cmdRunner.execute(cmd);

 

 

2 REPLIES 2
ascott
17-Peridot
(To:amatei)

I can spot a few problems in your code.

  • cmd.addSelection(new Option("overwriteExisting"));
    • Options are different then selections your code should read:
      • cmd.addOption(new Option("overwriteExisting"));
    • Selection would be:
      • cmd.addSelection("<sring>");

I have attached sample command for si viewproject. It tries to be as bare-bones as possible but should give you an indication if your API connections are working. It should output a list of projects on the system. You only need to update the username, password, and connection settings. If you still get no response, make sure API connections are available for that server.

https://www.ptc.com/en/support/article?n=CS128718

  • Once you get the viewproject command working, you can switch over to the projectco command. Something like this:

Command cmd = new Command(Command.SI,"projectco");
cmd.addOption(new Option("nolock"));
cmd.addOption(new Option("targetfile","d:/temp/AI_Test.txt"));
cmd.addOption(new Option("project=/ALM_Sample/project.pj/watch/project.pj"));
cmd.addOption(new Option("cpid=:none"));
cmd.addSelection("AiSubsystem.txt");


Hope this helps!

-Andrew

ascott
17-Peridot
(To:amatei)

Sorry, forgot to attach the file....

Top Tags