Skip to main content
1-Visitor
May 8, 2017
Solved

How to use and Test Java Server Side extension ?

  • May 8, 2017
  • 3 replies
  • 7149 views

Hi All,

I have a requirement. I have a value Stream associated with a thing. I am using this data to display on time series chart by using service QueryPropertyHistory. It works perfectly. Now I want to apply some complex logic on this value stream data , which can be easily doable in Java. So, I have decided to go with Java Server Side extension. How to start with this? Any example which can help me to start with this? How can get value stream data using service QueryPropertyHistory in java?

Thanks,

Azim

Best answer by ankigupta

azim hawaldar​,

As per my understanding TRACE will include ERROR and INFO mode so we don't require separate entries for ERROR and INFO for the same package.

Try to log WARN log entry in the code to see if it shows? Also, try to change the ROOT level to INFO.

I hope it helps.

3 replies

20-Turquoise
May 8, 2017

Could you please provide clarification on which extension you are talking about - did you download it from Marketplace, is it an officially ptc supported extension?

14-Alexandrite
May 9, 2017

Hi azim hawaldar​,

To begin with Java Extension, You need to:

1. Download Java Extension SDK from here.

2. Download Thingworx Eclipese plugin from Marketplace and check the user guide in the same place(Eclipse plugin is optional but it's very helpful for

your to convenienctly create a Thing/ThingTemplate, etc.)

3. Now you are ready to play with Java on Thingworx entity and services(QueryPropertyHistory for example). If you are not sure how to arrange your project structure and how to utilize the ThingWorx SDK,etc, please take reference to the document (I also attached the document here in case you could not open it).

Thanks,

Br,

Anna

ahawaldar1-VisitorAuthor
1-Visitor
May 9, 2017

Hi Anna An​,

I have started with this. I got this document in one of the ptc's link. But this did not answer my question about how to test the code in extension before we import that into composer, so that I am sure that all my code works fine. Also, i could not find how to use QueryPropertyHistory. Appreciate your help if you can give me some sample code of how to consume QueryPropertyHistory and test the code something like junit will be helpful.

Thanks,

Azim

5-Regular Member
May 9, 2017

Hi azim hawaldar​,

Please refer to following article to see if it answers your query: https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS250862

ahawaldar1-VisitorAuthor
1-Visitor
May 9, 2017

Hello Ankit Gupta​,

As per your suggestions, I added log to debug the code. But these logs are not printing in application logs. Below if my code

// class level static logger variable

private static Logger _logger = LogUtilities.getInstance().getApplicationLogger(RollingStockThingTemplate.class);

somewhere in one of the method

_logger.info("Entering Service: GenerateFFTFromStream");

Am I doing anything wrong here?

Thanks,

Azim

ahawaldar1-VisitorAuthor
1-Visitor
May 9, 2017

Hello Ankit Gupta​,

DId you got a chance to look into this? I am waiting for your response. Please check and let me know.

Thanks,

Azim

5-Regular Member
May 9, 2017

azim hawaldar​,

I will check this and will get back to you.