Engineering

 View Only
  • 1.  Using Rhapsody JAVA API

    Posted Thu October 06, 2022 04:31 PM
    System : Linux 64 bit
    Rhapsody version: Rhapsody 8.3 64bit

    I am trying to use JAVA API to modify or regenerate GUIDs for model which is open in the background

    I have a bash script which basically sets the rhapsody paths and invokes this - 

     $RHAPSODY_PATH/jdk/jre/bin/java -Djava.library.path=$RHAPSODY_PATH/Share/JavaApi -classpath .:$RHAPSODY_PATH/Share/JavaApi/rhapsody.jar SampleClass 

    Now the sampleClass looks like this - 

           public class SampleClass {
                 public static void main (String [ ] args) {
                    String modelName = args[0];
                    String root = args[1];
    
                    IRPApplication app = 
                        RhapsodyAppServer.getActiveRhapsodyApplication();
                    if (app == null){
                        System.out.println(" failure ");
                    }
               }
            }
    When I run the bashscript, I also open the rhapsody project in the background so the app here is a valid object and am able to call the methods such as getElement, getName, getGuids etc but when the program exits - I get an error ---> Now there is no core file in the directory I am so I don't know where it is being dumped but what is the problem and solution to this? All I am doing is getting the active rhapsody application which is valid.

    ./runSampleClass Segmentation fault (core dumped) $RHAPSODY_PATH/jdk/jre/bin/java -Djava.library.path=$RHAPSODY_PATH/Share/JavaApi -classpath .:$RHAPSODY_PATH/Share/JavaApi/rhapsody.jar SampleClass $1 $2

    ------------------------------
    VIVEK JAGANATHAN
    ------------------------------

    #Engineering
    #Sustainability


  • 2.  RE: Using Rhapsody JAVA API

    Posted Tue October 11, 2022 10:33 AM
    Hi Vivek , 
    I am little confused with the below comments. 

    When I run the bashscript, I also open the rhapsody project in the background so the app here is a valid object and am able to call the methods such as getElement, getName, getGuids etc but when the program exits - I get an error

    If I understand while running the BASH script without Rhapsody , you are getting error . 
    Hence if you want you can create the Rhapsody app in the api itself  calling the below function . 
    createRhapsodyApplication()

    If still there is a problem , please create a case with IBM and we can look into more details.

    ------------------------------
    Arta Chaudhury
    ------------------------------



  • 3.  RE: Using Rhapsody JAVA API

    Posted Tue October 11, 2022 12:00 PM
    Hi Arta,

     Thanks for the reply! I am running the bash script which opens the said rhapsody model in the background.

    // If I understand while running the BASH script without Rhapsody , you are getting error . // This is not true - rhapsody is open..

    In the bash script - 
    // Starting rhapsody model in the background
     $RHAPSODY_PATH/bin/rhapsody.exe $guid_proj & 

    And that's why this is a valid object (app) and getting an element, guid etc is all valid and right. It's just that on exiting I get the above error.

     IRPApplication app = 
                        RhapsodyAppServer.getActiveRhapsodyApplication();​


    Thanks
    Vivek



    ------------------------------
    VIVEK JAGANATHAN
    ------------------------------



  • 4.  RE: Using Rhapsody JAVA API

    Posted Thu October 13, 2022 10:21 AM
    Hi Vivek , 
    I understand that while exiting Rhapsody you are getting segmentation fault . 
    It appears that the crash happens when exiting rhapsody, as it may be trying to write to the log file or anything like that.

    So could you please try to check the exit process of Rhapsody in the script and try to close from GUI and check if you are getting the same error . 

    I would suggest you to open a case with IBM Rhapsody support , we can look in details . 

    Kind Regards
    Arta

    ------------------------------
    Arta Chaudhury
    ------------------------------



  • 5.  RE: Using Rhapsody JAVA API

    Posted Thu October 13, 2022 11:00 PM
    Hello Arta,

     I tried out the following given as a snippet here -> https://www.ibm.com/support/pages/rational-rhapsody-java-api-%E2%80%93-code-snippets-helper-apps#5 (IV. Language type being used in Rational Rhapsody model) and my java program exits with a segmentation fault.. All I do here is open the rhapsody in the background and run this code.. The rhapsody is still open when the program exits. 

    // I would suggest you to open a case with IBM Rhapsody support , we can look in details .
    How would I do that? I don't have customer number etc.. 
     

    import com.telelogic.rhapsody.core.IRPApplication;
    import com.telelogic.rhapsody.core.RhapsodyAppServer;

    public class Test
    {
    public static void main(String[] args)
    {

    IRPApplication myApp = RhapsodyAppServer.getActiveRhapsodyApplication();
    System.out.println(myApp.getLanguage());
    }
    }

    ------------------------------
    VIVEK JAGANATHAN
    ------------------------------