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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Can't import a ThingShape in an extension

knordstrom
1-Visitor

Can't import a ThingShape in an extension

I'm trying to load up some objects through an extension I'm writing and I keep running into blocks when I import things. I have right now a ThingTemplate

@ThingworxBaseTemplateDefinition(name = "GenericThing")

@ThingworxPropertyDefinitions(properties = {

  @ThingworxPropertyDefinition(name = "Name", description = "Name of thing on Timeli's platform (required). Should be unique.", category = "", baseType = "STRING", isLocalOnly = false, aspects = {

  "isPersistent:true", "dataChangeType:VALUE" }), @ThingworxPropertyDefinition(name = "Samples", description = "", category = "", baseType = "THINGNAME", isLocalOnly = false, aspects = {

  "thingShape:Samples", "dataChangeType:VALUE" }) })

public class MyThingTemplate extends Thing { ...

and two ThingShape objects, Samples

@ThingworxPropertyDefinitions(properties = {

  @ThingworxPropertyDefinition(name = "Samples", description = "", category = "", baseType = "INFOTABLE", isLocalOnly = false, aspects = {

  "dataChangeType:VALUE", "isEntityDataShape:true", "dataShape:Sample" }) })

public class Samples extends ThingShape {

and Sample (singular)

@ThingworxPropertyDefinitions(properties = {

  @ThingworxPropertyDefinition(name = "Timestamp", description = "", category = "", baseType = "DATETIME", isLocalOnly = false, aspects = {

  "dataChangeType:VALUE" }), @ThingworxPropertyDefinition(name = "Value", description = "", category = "", baseType = "NUMBER", isLocalOnly = false, aspects = {

  "dataChangeType:VALUE" }) })

public class Sample extends ThingShape {

All objects are stubs in the sense there's as yet no Java code in them.

My metadata.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><Entities>

    <ExtensionPackages>

        <ExtensionPackage dependsOn="" description="" minimumThingWorxVersion="7.2.1" name="penrose" packageVersion="0.0.0004" vendor="">

            <JarResources>

                <FileResource description="" file="penrose.jar" type="JAR"/>

            </JarResources>

        </ExtensionPackage>

    </ExtensionPackages>

    <ThingPackages>

        <ThingPackage className="io.timeli.penrose.MyThingTemplate" description="" name="MyThingTemplatePackage"/>

    </ThingPackages>

    <ThingTemplates>

        <ThingTemplate aspect.isEditableExtensionObject="false" description="" name="MyThingTemplate" thingPackage="MyThingTemplatePackage"/>

    </ThingTemplates>

    <ThingShapes>

        <ThingShape aspect.isEditableExtensionObject="false" className="io.timeli.penrose.Samples" description="" name="Samples"/>

        <ThingShape aspect.isEditableExtensionObject="false" className="io.timeli.penrose.Sample" description="" name="Sample"/>

    </ThingShapes>

</Entities>

It builds on my local, of course, because there's no code to compile. But when I import, I get the following:

Import Failed: Validation Failure: ThingShape Samples Had An Invalid Class Name : [io.timeli.penrose.Samples] - Possibly Missing Extension Package

What am I missing? Please feel free to ask for more information. But it seems to me I've declared the fully qualified classname for Samples in the metadata.xml and the class file is present in the jar. The objects all extend the appropriate base classes. So what else is there to do?

11 REPLIES 11
ttielebein
14-Alexandrite
(To:knordstrom)

The only thing I can think of for this is, are you sure these classes are properly located in this package (io.timeli.penrose)? Perhaps there is an issue with the property and thingShape having the same name? I don't see why that would be a problem... are you still having issues with this?

Thanks for the response.

I'm sure of these things. What I have right now is pretty close to the most basic possible project, so I'm pretty confused.

I've set up using Eclipse (Neon) and the TW plugin. I even created another project entirely in case there was some artifact of my messing around earlier causing issues. All entities were created using the plugin, the only thing I changed was adding the "extends ThingShape" to the Samples object in case the error message was mischaracterized somehow and it was really just having difficulty implementing a ThingShape with the class.

Here's a screenshot of the project as it stands:Screenshot 2016-11-03 18.19.01.png

And here's a screenshot of trying to upload patterns.zip from my distributions directory:

Screenshot 2016-11-03 18.31.09.png

If it helps anyone (for perusing logs), the IP of the AWS instance this was attempted on is 52.5.227.117.

Keith,

Any update on this issue? Have you made any progress?

I faced the same issue, I do not have proper solution, but I noticed that the 'className' attribute for ThingShape in metadata.xml is not acceptable for some reason. If I remove it then the extension installs fine. However I am not sure if this is a proper fix, I do not have anything meaningful in my class to be able to check.

I have the same probelm.

Did you find any solution?

posipova
20-Turquoise
(To:knordstrom)

Tori Tielebein​ have you investigated this any further and/or created a ticket on customer's behalf? If not, please do, especially now with multiple people reporting.

Rafael PALLARESSajid PatelKeith Nordstrom​ what are the thingworx and sdk version you are using? Please note this article too, https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS214774&lang=en_US  although at least from the first screenshot in this thread it's obvious the version is 7.x.

ttielebein
14-Alexandrite
(To:posipova)

I cannot reproduce this using the 7.2 SDK and importing into 7.3. My ThingShape and ThingTemplate both import fine, even though they are in a package and everything. I am really not sure what the issue is here.

Hello,

I'm using ThingWorx 7.1.3 and the SDK version is 7.1.0.

I just created the ThingShape using the eclipse plugin as I create other entities.

The node created into metadata.xml is very simple:

<ThingShapes>

    <ThingShape aspect.isEditableExtensionObject="false" className="a.java.package.QueryBuilderSParam" description="" name="QueryBuilderSParam"/>

</ThingShapes>

Hi all,

I also have the same problem. This is with Thingworx 8.0 and Extension SDK 8.0, Thingworx extension builder lpgin for Eclipse 7.2 and Eclipse Mars 4.5.2. It is my understanding that these are the latest stable versions for all software.

I can verify that if you remove the className node in the ThingShape definition in the metadata.xml file then the extension will import but all my services in the custom ThingShape are not available.

I have similar issues with creating a resource library (it won't import), a script library (it won't create and services).

So we need a fix for this, otherwise all I can create through the extension plugin is a custom thing template, which is rather limiting.

Regards

Ben

I have done more experimentation with this and I have found a few issues that can be resolved. I can now actually get my ThingShape extension to import and the service(s) to show in the thing shape.

My metadata.xml I think is essentially unchanged to what is created by the Thingworx Eclipse extension, but I'll post it here in case there is some subtle difference.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<Entities>

    <ExtensionPackages>

        <ExtensionPackage dependsOn="" description="" minimumThingWorxVersion="8.0.0" name="RegainCustomTWX" packageVersion="1.1.13" vendor="Regain">

               <JarResources>

                <FileResource description="" file="regaincustomtwx.jar" type="JAR"/>

            </JarResources>

        </ExtensionPackage>

    </ExtensionPackages>

<ThingShapes>

        <ThingShape  aspect.isEditableExtensionObject="false" description="A generic thing shape to hold many custom functions" className="com.regain.thingworx.RegainGenShape" name="RegainGenShape">

        </ThingShape>

    </ThingShapes>

</Entities>

But what I also did was the following to get it to import

1. Go to the Thingworx server, and in the the ThingWorx storage area under extensions (in my case C:\ThingworxStorage\extensions), delete the extension name in question. (In my case RegainCustomTWX). This I think stops Thingworx from using an earlier version or caching. It may not even exist if you have never been able to import it before.

2. Recycle your tomcat. This seems to be the critical part. Why i is required when you have never imported I do not know but I could not get it to work unless I did this.

3. Clear your browser cache. I even restarted my client browser after clearing, but it did not ask me to relogin, so another Chrome session must have been holding the login details in a cookie

I don't know if you require all these steps. I think step 2 is the most critical but I cannot tell you why. But this is the only way I have had a successful import.

Hope this works for others. It may not, because it really has been stab in the dark to get any consistency.

Regards

Ben

Hi Keith, I haven't done work on custom extensions since the initial one I created back in June 2016,so all this is going on memory and could be wrong.

I think you have to have some code in the stub otherwise the import will fail. I don't know why this would be the case, so I could be wrong.

Additionally, what I found was you had to delete the whole extension in the Thingworx storage area. I have configured that to be C:\ThingworxStorage\Extensions and you delete the whole folder with the name of your extension. Even if it doesn't exist, you still need to recycle tomcat (or Apache) for some reason. I could never get it to import even if the import had not been successful until I recycled tomcat. I can sort of understand why, because when you import it creates the folder with your jar file(s) under the Extension subfolder and I suspect tomcat has to load the jar files.

Also, check if your XML is essentially the same as mine above. You may have tried those things already, so if you have this has been no help at all.

One last thing is to check if the version of the the extension SDK, the eclipse builder and Thingworx are all consistent. You say you are using Eclipse NEON so it should be fine.

If you want, I can post or email my java stubs, XML etc and you can try and make that work, and if it does you can then try and find the differences between mine and yours. For example, I have extended another extension, the CSV parser, to allow for appending to a CSV file. Quite happy to share the code and the zip file. You could import my extension to see if that works and if it does, then you could try and build your own version with a different name with the javav code and it should in theory just work exactly the same.

Sorry I can't be of more help.

Announcements


Top Tags