Hi, I'm trying to add a custom data type to my smart service. Wit

Hi,

I'm trying to add a custom data type to my smart service. Without CDT declaration, I can install the smart service but if I add it, I get this message in the application-server.log :

com.atlassian.plugin.PluginException: com.appiancorp.type.config.pojo.PojoTypeImportException: Could not generate XSDs for the classes [class com.solypse.etde.etde_import]. Cause: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions (APNX-1-4166-001)

I just added the "netbean" cdt example, it's my first test and I'm not so good with Java so excuse me if the answer is obvious.

I'm using Appian 7 and jre 1.6

Thanks,

Olivier

appian-plugin.xml :
---------------------------------
...
          <datatype key="et_importDTin" name="Et Import Data Type">
<class>com.solse.et.et_import</class>
</datatype>

<smart-service name="et_import" key="et_import"
class="com.solse.et.et_import" />
</appian-plugin>
---------------------...

OriginalPostID-57953

OriginalPostID-57953

  Discussion posts and replies are publicly visible

  • ...-
    code :

    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;
    import javax.xml.bind.annotation.XmlType;

    @XmlRootElement(name="et_import", namespace="com.solse.et")
    @XmlType(name="et_import", namespace="com.solse.et", propOrder={"first", "second"})

    @PaletteInfo(paletteCategory = "Integration Services", palette = "Connectivity Services")
    public class et_import extends AppianSmartService {

              private static class SampleBean {
    private int first;
    private String second;

    @XmlElement
    public int getFirst() {
    return first;
    }
    public void setFirst(int first) {
    this.first = first;
    }

    @XmlElement
    public String getSecond() {
    return second;
    }
    public void setSecond(String second) {
    this.second = second;
    }
    }
              private static final Logger LOG = Logger.getLogger(et_import.class);
              private final SmartServiceContext smartServiceCtx;
              private String param0;
              privat...
  • ...e String return0;

              @Override
              public void run() throws SmartServiceException {
                        // TODO Auto-generated method stub
                        log(Thread.currentThread().getStackTrace()[1].getMethodName());
              }

              public et_import(SmartServiceContext smartServiceCtx) {
                        super();
                        this.smartServiceCtx = smartServiceCtx;
                        log(Thread.currentThread().getStackTrace()[1].getMethodName());
                        ...
  • Sorry, I remaned the functions and the message corresponding to the code above is

    Caused by: com.appiancorp.type.config.pojo.PojoTypeImportException: Could not generate XSDs for the classes [class com.solse.et.et_import]. Cause: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions (APNX-1-4166-001)
  • The way that I typically create CDTs as java objects are as their own java file outside of my plugin. To do so take the following steps:

    1. Create another java file called SampleBean.java with the correct package name and package imports which for you would be the JAXB Annotation example from this page: forum.appian.com/.../Defining_a_Custom_Data_Type

    with this at the top:

    package com.solse.et;

    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;
    import javax.xml.bind.annotation.XmlType;

    2. Change the private static class SampleBean to public class SampleBean

    3. Change your datatype in your plugin to be:

    <datatype key="et_importDTin" name="Et Import Data Type">
    <class>com.solse.et.SampleBean</class>
    </datatype>

    Let me know if that works for you.
  • Thank you very very much Michael, it's much cleaner and works !

    What I have to understand now is how to use it, that's to say set parameters from appian or get them back. Do I have to import it ?

  • Could you give me your use case so I could more clearly understand what you are trying to do? Are you trying to use the cdt as an input or output from your smart service?

    If you actually take a look in Appain in the designer view
    System->Data Management->Manage Data you can see the new CDT that was imported from the plugin.
  • Ok, that's fine, I see it. What I want to do is to be able to pass a bunch of values from an appian process to a java program, modify them, and returns results to the process. Inside java I think I have to write SampleBean sb = new SampleBean(); to get the values. I have to initialize them inside the process before but don't know how so far as it's the first time I use CDT (and Smart service either). For the output, I have to initialize output parameters and then find how to fetch them from the process ? Without using too much of your time, thanks for a few guidelines, it will help !
  • It actually doesn't sound like you need to be creating cdts with java code at all.

    You can have your smart service take in and return primitive types like this example: forum.appian.com/.../Custom_Smart_Service_Plug-ins
  • I have to think about it, as I'm not sure to understand. You mean that I can get and set existing CDT values created directly in Appian with xsd ? I didn't thought about this idea. In which cases would it be interesting to create CDT with java ?
  • I was more saying that it is simpler to pass primitives into a smart service, do some calculations, return those primitives, and then assign the result to fields in a cdt - if that is what you are trying to do. Genenrally, creating CDT's with java is not really necessary unless you are building in a lot of functionality into the class - not just using the class as a holder for variables.