XCP 2.0 - where to create java code

Options
pettitk
edited August 13, 2015 in Documentum #1

A frustration... What are you all using? We are still using composer to do Java programming in 2.0. Easier then eclipse, mainly because all the libraries are there.

xCP Designer should provide facility to create extensions within the designer. At this moment, we need to create plugins outside xcp designer and import them into designer. I was hoping for an all inclusive tool, more like what composer was. A guess we add this to the wish list...

-Kp

(this post is put in both Dev Network and Support Forum in an effort to get visibility to both audiences... wish they would combine these)

Comments

  • dnvhariprasad
    edited February 10, 2013 #2
    Options

    yes you are right that xcp2.0 does not come with composer kind of utility to create custom extensions.

    We are planning to use build file which will automatically update the jar file under $applications\<apname>lib folder.  However for the first time we still need to add the library manually.  Once it was added, we can just use eclipse to build and then come to xcp designer and click on Refresh button.

  • troysawyer
    edited February 12, 2013 #3
    Options

    I've been having some problem with getting a custom jar working. Here's what I have:

    xCPDesigner\Applications\Clean\Clean\content\modules\Easy.jar

    Easy.jar code:

    package com

    public class Easy

    {

      public static String first2()

      {

        return "yay";

      }

    }

    xCPDesigner\Applications\Clean\Clean\Artifacts\Java Modules\Easy.javamodule

    List.png

    In xCP designer I can creat a process and have a java step that see my function.

    Everything compiles and deploys fine but when I load the page I get the following error:

    pageerror.png

    Any insight would be great.

  • pettitk
    edited February 13, 2013 #4
    Options

    See the WP on customizations. Search it on powerlink/support.

    “h11306-extension-points-xcp-wp.pdf”

    I am responding via email and in my email I have attached the WP. If it doesn’t show, then pls rely on searching powerlink.

  • dnvhariprasad
    edited February 13, 2013 #5
    Options

    can you post your javamodule code? probably there might be some issue there..

  • troysawyer
    edited February 13, 2013 #6
    Options

    I'ce cut down the Java code to a simple case for testing:

    package com

    public class Easy

    {

      public static String first2()

      {

        return "yay";

      }

    }

  • troysawyer
    edited February 13, 2013 #7
    Options

    Misread here is the javamodule code:

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

    <nsJavaModule:JavaModule xmlns:nsJavaModule="http://xcp.emc.com/javamodule"

    urn="urn:xcp:com.emc.xcp.artifact.javamodule.category:Artifacts/Java Modules/Easy.javamodule"

    categoryId="com.emc.xcp.artifact.javamodule.category" name="Easy" label="Easy Function"

    implementationClass="com.Easy">

      <implementationJars contentPath="content/modules/Easy.jar"/> <!--1 or more -->

    </nsJavaModule:JavaModule>

  • dnvhariprasad
    edited February 13, 2013 #8
    Options

    from the screenshot it is showing as "Easy 2" where as you nowhere specified in your javamodule.  Probably you might have changed the code couple of times..

    if you can provide the full jar file and javamodule, I can look into the problem.

    PS:  I have implemented javamodules and are working fine for me without issues.

  • troysawyer
    edited February 13, 2013 #10
    Options

    I'm now getting another error when just greating a Process UI page for the process "tetst" I created that calls the custom java

    Error while servicing the request.

    Error code: E_CORE_SERVICE_ERROR

    [DM_WORKFLOW_E_CANT_START]error:  "The workflow 'tetst 2013-02-13' can only start, when its referenced process (4b007dea8000d192) is installed."; nested exception is javax.persistence.PersistenceException: [DM_WORKFLOW_E_CANT_START]error:  "The workflow 'tetst 2013-02-13' can only start, when its referenced process (4b007dea8000d192) is installed."

    This error is throw when I hit start on that Process UI page.

  • otman
    edited February 13, 2013 #11
    Options

    Hi Kyle & Experts,

    the Error as mentioned in your posted screenshot indicates that the application/engine can not fetch the module you've installed

    please have a look on your Easy.javamodule

    your urn put xcp ( in the hilight) as module namespace but i presume that your applcation has an other namespace than xcp

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

    <nsJavaModule:JavaModule xmlns:nsJavaModule="http://xcp.emc.com/javamodule"

    urn="urn:xcp:com.emc.xcp.artifact.javamodule.category:Artifacts/Java Modules/Easy.javamodule"

    categoryId="com.emc.xcp.artifact.javamodule.category" name="Easy" label="Easy Function"

    implementationClass="com.Easy">

      <implementationJars contentPath="content/modules/Easy.jar"/> <!--1 or more -->

    </nsJavaModule:JavaModule>

    can you please try to change the xcp in your xml with your application namespace

    urn="urn:<Application namespace>:com.emc.xcp.artifact.javamodule.category:Artifacts/Java Modules/Easy.javamodule"

    hope this helps

    Otman


  • troysawyer
    edited February 14, 2013 #12
    Options

    Good catch, that did it.

  • SandipDabhade
    edited March 3, 2015 #13
    Options

    I want to create java service in which there will be a function who accepts String argument and returns a string argument, I have developed one service  but I am not able to see the method in it on selection  of service in xcpDesignder

    1.jpg

    My Module

    <?xml version="1.0" encoding="UTF-8"?>
    <nsJavaModule:JavaModule xmlns:nsJavaModule="http://xcp.emc.com/javamodule" urn="urn:xoaf:com.emc.xcp.artifact.javamodule.category:Artifacts/Java Modules/ReplaceCheckerString.javamodule" categoryId="com.emc.xcp.artifact.javamodule.category" name="ReplaceCheckerString" label="ReplaceCheckerString" implementationClass="com.java.ReplaceCheckerString">
      <implementationJars contentPath="content/modules/ReplaceCheckerString.jar"/>
    </nsJavaModule:JavaModule>

    My Class

    package com.java;

    public class ReplaceCheckerString {

    public static String replaceCheckerString(String input) {
      String output=null;
      output="'"+input.replaceAll("/", "','")+"'";
      return output;

    }

    }


  • M.gad
    edited March 15, 2015 #14
    Options

    Hello Sandip,

    What version of Designer you are using. Try to remove these two folders (modules & Java Modules) with their contents and recreate again.


    I try to develop it on version 2.1 and it is working fine.

    In 2.1, You can use this way to create the Java Service OR Easily you can add the JAR file directly to the Java Services node under the Application tab of xCP Navigator in one step then you can use it from Execute Java Service Activity.

    Replace.jpg

  • SandipDabhade
    edited June 2, 2015 #15
    Options

    I am having one java service to write excel file, I have packaged poi jar in  exported jar and added this jar in my xcp application.

    But whenever I am selecting this java service in stateless process I am getting class not found exception.

    How to use java service with dependency libs?

  • sangeetha.d
    edited August 11, 2015 #16
    Options

    Hi,

    I am unable to get the java service methods in my java service activity inspector. I have added all the dependency jar files in content/modules and configured javamodule still it is not showing the methods.

    please help me.

  • SandipDabhade
    edited August 11, 2015 #17
    Options

    hi

    can you show me your java class?

    sangeetha.d replied to the discussion

    "XCP 2.0 - where to create java code"

    To view the discussion, visit: https://community.emc.com/message/900905?et=watches.email.thread#900905

    >

  • sangeetha.d
    edited August 13, 2015 #18
    Options

    Below is my Class file:

    /*

    *

    * TODO To change the template for this generated file go to

    * Window - Preferences - Java - Code Style - Code Templates

    */

    package com.fas.invokedeployr;

    /**

    * @author Administrator

    *

    * TODO To change the template for this generated type comment go to

    * Window - Preferences - Java - Code Style - Code Templates

    */

    import java.io.IOException;

    import com.documentum.fc.client.IDfModule;

    import com.revo.deployr.client.RClient;

    import com.revo.deployr.client.RProject;

    import com.revo.deployr.client.RProjectFile;

    import com.revo.deployr.client.RUser;

    import com.revo.deployr.client.auth.RAuthentication;

    import com.revo.deployr.client.auth.basic.RBasicAuthentication;

    import com.revo.deployr.client.factory.RClientFactory;

    import com.revo.deployr.client.params.DirectoryUploadOptions;

    import java.io.BufferedReader;

    import java.io.FileInputStream;

    import java.io.FileNotFoundException;

    import java.io.FileOutputStream;

    import java.io.FileReader;

    import java.net.URL;

    import java.nio.channels.Channels;

    import java.nio.channels.ReadableByteChannel;

    import java.text.ParseException;

    import java.util.List;

    public class InvokeDeployR implements IDfModule {

      //private static final String Null = null;

      //private static final String RETURN_MSG = "csv file generated";

      public static void main(String[] args)throws ParseException{

      String[] check=new InvokeDeployR().callToRLean();

      int i;

      for(i=0; i<check.length; i++){

      System.out.println(check[i]);

      }

      }

      // TODO Auto-generated method stub

      

      public String[] callToRLean() throws ParseException{

         RClient rClient = null;

         String[] csvOutput =new String[5];

      try{

      String endpoint ="http://172.27.167.16:7400/deployr";

             System.out.println("Using endpoint=" + endpoint);

         

             /*

              * Establish RClient connection to DeployR server.

              *

              * An RClient connection is the mandatory starting

              * point for any application using the client library.

              */

             rClient = RClientFactory.createClient(endpoint);

            

            

             System.out.println("Established anonymous " +

                     "connection, rClient=" + rClient);

             /*

              * Build a basic authentication token.

              */

             RAuthentication rAuth =

                     new RBasicAuthentication("prism_deployr","prism@123");

             /*

              * Establish an authenticated handle with the DeployR

              * server, rUser.

              */

             RUser rUser = rClient.login(rAuth);

             System.out.println("Upgraded to authenticated " +

                     "connection, rUser=" + rUser);

             /*

              * Create a temporary project (R session).

              *

              * Optionally:

              * ProjectCreationOptions options =

              * new ProjectCreationOptions();

              *

              * Populate options as needed, then:

              *

              * rProject = rUser.createProject(options);

              */

             RProject rProject = rUser.createProject();

             System.out.println("Created temporary \n" +

                     "R session, rProject=" + rProject);

            

             /*

              * Download working directory file content using

              * standard Java InputStream.

             */

            

           

             DirectoryUploadOptions uploadOptions = new DirectoryUploadOptions();

             uploadOptions.filename = "datafile.csv";

             // uploadOptions.overwrite= true;

             FileInputStream fis = new FileInputStream("D:\\DeployRInput.csv");

             RProjectFile rProjectFile = rProject.uploadFile(fis, uploadOptions);

             URL fileStream = rProjectFile.download();

             System.out.println(fileStream);

            

            

             rProject.executeScript("combined_scoringcsv.R","iFAS", "prism_deployr", "");   

           

             List<RProjectFile> fis2 = rProject.listFiles();

             URL downl = fis2.get(1).download(); 

              

             System.out.println(downl);

             ReadableByteChannel rbc = Channels.newChannel(downl.openStream());

             FileOutputStream fos = new FileOutputStream("D:\\DeployROutput.csv");

             fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);

             /*

              * Retrieve a list of files in the R session's

              * working directory.

              */

             /*   List<RRepositoryFile> files = rUser.listFiles();

                for (RRepositoryFile file : files) {

                System.out.println("Private repository, " +

                            "found file name=" +

                            file.about().filename + ", directory=" +

                            file.about().directory + ", access=" +

                            file.about().access);

                }*/

               

              

                String csvFile = "D:\\DeployROutput.csv";

            BufferedReader br = null;

            String line = "";

            String cvsSplitBy = ",";

          

          

          

            try {

            br = new BufferedReader(new FileReader(csvFile));

            while ((line = br.readLine()) != null) {

          

          

                   // use comma as separator

            String[] output = line.split(cvsSplitBy);

            

            csvOutput[0]=output[4];

            csvOutput[1]=output[5];

            csvOutput[2]=output[6];

            csvOutput[3]=output[7];

            csvOutput[4]= output[8];

            System.out.println("output [rules_score= " + output[4]

                                             + " , text_score=" + output[5] +  " , predictive_score=" + output[6] +

                                              " , Final_Score=" + output[7] + " , Fraud_Prediction =" + output[8] + "]");

          

            }

          

            } catch (FileNotFoundException e) {

            e.printStackTrace();

            } catch (IOException e) {

            e.printStackTrace();

            }

               

            

               

            } catch (Exception ex) {

                System.out.println("Runtime exception=" + ex);

     

           

            }

            return csvOutput;

      }

    }

  • sangeetha.d
    edited August 13, 2015 #19
    Options

    sorry I have copied my java code.

    how can I send my class file to you, any possible way????

    i m unable to attache files here.