8.6.5. Rhapsody

8.6.5.1. Installation of the Rhapsody plugin

Beginning with Rhapsody 8.2, no installation is needed. Instead, rpy2rfg internally uses a command of RhapsodyCL.exe to load the required .hep file.

If you installed rpy2rfg via rhapsody.ini, adding an rpy2rfg profile (*.hep) to your Rhapsody model, or adding the rpy2rfg.hep to your own profile/hep file, it is recommended to remove the entry. As rpy2rfg requests Rhapsody to load the necessary hep file via a command-line option, no additional installation is needed.

Note

Exception in thread “main” com.telelogic.rhapsody.core.RhapsodyRuntimeException: Can’t co-create object
One reason for this error can be that Rhapsody does not find an appropriate license.

Note

Sometimes, Rhapsody API calls cause problems, e.g. stack overflows. In such a situation, they can be omitted with the option ignore_rhapsody_methods of Architecture-RhapsodyImporter, which takes a list of methods, e.g. IRPUnit.getCurrentDirectory and IRPModelElement.getIconFileName.

8.6.5.2. Rhapsody and COM

Rhapsody uses COM to communicate between Java plugins and the main application. Files necessary for COM communication are registered in the Windows registry globally. The location in the registry is the same for all Rhapsody 8.x versions up to 8.3.0. Rhapsody 8.3.1 uses a different location.

The globally registered files are not ABI compatible between different Rhapsody versions. So when choosing e.g. Rhapsody 8.2.1 for importing but Rhapsody 8.3.0 is registered, the import will fail.

rpy2rfg registry check

The registry check is only active on Windows. It is executed after retrieving the Rhapsody version (through a COM call), so rpy2rfg may still crash with a weird Rhapsody exception when this early call fails. Rhapsody 8.3.1 uses a different registry key, so the check is disabled on Rhapsody 8.3.1+.

To avoid crashing with weird exceptions thrown by Rhapsody, the registered .tlb file is checked. If the given Rhapsody path (path to the RhapsodyCL.exe) does not match the registered path in the registry, rpy2rfg will abort. The abort can be disabled with the option ignore_rhapsody_check_error or keep_flying of Architecture-RhapsodyImporter. ignore_rhapsody_check_error will just ignore the result of the registry check, whereas keep_flying will ignore further fatal errors. rpy2rfg still prints the error message.

Register Rhapsody in the registry

Try one of the following. The top option is the most preferred one. The commands are executed in the Rhapsody installation directory. They likely will need administrator rights.

  • rhapsody.exe /RegServer

  • regsvr32 Rhapsodyserver.dll

  • rhapsody.reg

See https://web.archive.org/web/20191226181806/https://www.ibm.com/developerworks/community/forums/html/topic?id=f5e8e705-f0c7-4854-a39c-309ee445c3fe for more information.

Debugging Rhapsody not loading rpy2rfg or crashing during rpy2rfg loading

RhapsodyCL Return Codes

Overview of the log files in IBM Rational Rhapsody

If you cannot edit the rhapsody.ini, you can copy it next to your model’s .rpy(x) file and edit the copy. It seems that Rhapsody unofficially also searches for the rhapsody.ini in the current working directory or next to the .rpy(x) file.

To narrow down the step which fails, please execute the following steps which load more rpy2rfg-relevant code each step. Be aware that the argument of -cmd=load_hep must be quoted IFF it contains special characters like spaces but not otherwise.

Does work:

-cmd=load_hep C:\Users\user\MyModel\MyModel.rpyx
-cmd=load_hep "C:\Users\user\My Model\My Model.rpyx"

Does not work:

-cmd=load_hep "C:\Users\user\MyModel\MyModel.rpyx"
-cmd=load_hep C:\Users\user\My Model\My Model.rpyx

Step 1 (just load the model without anything Axivion rpy2rfg related):

cd /d "<path-to-model-directory>"
"<path-to-rhapsody>\RhapsodyCL.exe" -verbose -cmd=loadjvm -cmd=GetCommandResult -cmd=open "<path-to-model.rpy(x)>" -cmd=GetCommandResult -cmd=close NoSave -cmd=exit -cmd=GetCommandResult
echo ErrorLevel: %ERRORLEVEL%

Step 2 (set required environment):

rem e.g.: "set AXIVION_BASE_DIR=C:\Program Files (x86)\Bauhaus"
set "AXIVION_BASE_DIR=<path-to-axivion-suite>"
cd /d "<path-to-model-directory>"
"<path-to-rhapsody>\RhapsodyCL.exe" -verbose -cmd=loadjvm -cmd=GetCommandResult -cmd=open "<path-to-model.rpy(x)>" -cmd=GetCommandResult -cmd=close NoSave -cmd=exit -cmd=GetCommandResult
echo ErrorLevel: %ERRORLEVEL%

Step 3 (load rpy2rfg):

rem e.g.: "set AXIVION_BASE_DIR=C:\Program Files (x86)\Bauhaus"
set "AXIVION_BASE_DIR=<path-to-axivion-suite>"
cd /d "<path-to-model-directory>"
"<path-to-rhapsody>\RhapsodyCL.exe" -verbose -cmd=loadjvm -cmd=GetCommandResult -cmd=open "<path-to-model.rpy(x)>" -cmd=GetCommandResult -cmd=load_hep "%AXIVION_BASE_DIR%\doc\Rhapsody\rpy2rfg.hep" -cmd=GetCommandResult -cmd=close NoSave -cmd=exit -cmd=GetCommandResult
echo ErrorLevel: %ERRORLEVEL%

Step 4 (execute rpy2rfg):

rem e.g.: "set AXIVION_BASE_DIR=C:\Program Files (x86)\Bauhaus"
set "AXIVION_BASE_DIR=<path-to-axivion-suite>"
cd /d "<path-to-model-directory>"
"<path-to-rhapsody>\RhapsodyCL.exe" -verbose -cmd=loadjvm -cmd=GetCommandResult -cmd=open "<path-to-model.rpy(x)>" -cmd=GetCommandResult -cmd=load_hep "%AXIVION_BASE_DIR%\doc\Rhapsody\rpy2rfg.hep" -cmd=GetCommandResult -cmd=call "rpy2rfg" -cmd=GetCommandResult -cmd=close NoSave -cmd=exit -cmd=GetCommandResult
echo ErrorLevel: %ERRORLEVEL%