Loading Plugin into Rhapsody ends in ClassNotFoundException

50 Views Asked by At

I am fairly new to writing Java Plugins for Rhapsody and I have a problem implementing my Plugins into Rhapsody. I tested implementing plugins from former colleagues which worked so I tried building my code and .hep up like they did which always ended in the same exception. I ended up trying to just write a base program which simply puts out that it initialized when i start rhapsody.

package com.abcd.rhapsody.plugins;

import com.telelogic.rhapsody.core.IRPApplication;
import com.telelogic.rhapsody.core.IRPProject;
import com.telelogic.rhapsody.core.RPUserPlugin;

public class TestPlugin extends RPUserPlugin {
    protected IRPApplication m_rhpApplication = null;
protected IRPProject m_rhpProject = null;

@Override
public void RhpPluginInit(IRPApplication rpyApplication) {
    m_rhpApplication = rpyApplication;
    m_rhpProject = m_rhpApplication.activeProject();
    m_rhpApplication.writeToOutputWindow("Log", "Testplugin fully loaded. \n");
}

@Override
public void RhpPluginInvokeItem() {
}

@Override
public void OnMenuItemSelect(String menuItem) {
}

@Override
public void OnTrigger(String trigger) {
}

@Override
public boolean RhpPluginCleanup() {
    return true;
}

@Override
public void RhpPluginFinalCleanup() {
}

}

I try implementing it with the following .hep:

[Helpers]
numberOfElements=2

name1=TestPlugin
JavaMainClass1=com.abcd.rhapsody.plugins.TestPlugin
JavaClassPath1=Helper\TestPlugin6.jar
isPlugin1=1
isVisible1=1

name2=Test\PluginTest
isPluginCommand2=1
command2=TestPlugin
applicableTo2=Project,Package,Basic,Intermediate,Application
isVisible2=1

I tried everything i could find so far with changes in the .hep, jre versions and so on.

I always end up with the following Message in the log:

PLUGIN MESSAGE: Exception while loading Plugin com.abcd.rhapsody.plugins.TestPlugin
java.lang.ClassNotFoundException: com.abcd.rhapsody.plugins.TestPlugin

at java.lang.Class.forNameImpl(Native Method)

at java.lang.Class.forName(Class.java:407)

at com.telelogic.rhapsody.core.JavaPluginsManager.loadPlugin(Unknown Source)


 2  plugin classpaths: 
Helper\TestPlugin6.jar
Helper\TestPlugin6.jar

I dont really know why the log shows 2 plugin classpaths since for my understanding I only set one classpath even though the 2 classpaths are the same path.

I'm open to try whatever solution could work so thanks in advance for any advice.

1

There are 1 best solutions below

0
Louis TALVANDE On

Some fixes to apply in the .hep file:

  • when you have isPlugin1=1, you should have isVisible1=0 and not isVisible1=1, because this is the entry for the plugin and not the visible menu.
  • replace 'JavaClassPath1=Helper\TestPlugin6.jar' by 'JavaClassPath1=./Helper/TestPlugin6.jar'