Skip to main content
1-Visitor
February 11, 2020
Solved

NullPointer Exception when getting current session

  • February 11, 2020
  • 2 replies
  • 2448 views

Hello, I have been demoing the otk java examples and decided to create my own project.
My custom action listener class is working fine within the otkexamples project.

Now that I created my own project, I am having issues in my main class. I practically copied and pasted the structure of otkExamplesmain.java but removed all the example methods.

The exception is throwing when trying to get the current session on launch when setting up the ribbon commands. I must have missed something when setting up my project but cannot figure out what that is.

Exception caught: java.lang.NullPointerException
com.ptc.cipjava.CIPRemoteApp.getTransport(CIPRemoteApp.java:40)

 private void SetupRibbonCommands()
{
try
{
System.out.println("Get Session");
session = pfcSession.GetCurrentSession();
wSession = (WSession)session;

wSession.RibbonDefinitionfileLoad(ribbonFile);

//startCreoson();
addAbasCommands();

}
Best answer by abasRyan

After playing around, and comparing the contents of each jar, there was something off in my artifacts settings. I noticed it was packaging the external otk libraries in with the jar, I'm not sure why. It's runnning correctly now that the otk library is not packaged in the jar. I'm not sure what the main issues were in intellij and if someone could comment on that it would be great.


Library settings.
Artifact settings
etc

2 replies

abasRyan1-VisitorAuthorAnswer
1-Visitor
February 11, 2020

After playing around, and comparing the contents of each jar, there was something off in my artifacts settings. I noticed it was packaging the external otk libraries in with the jar, I'm not sure why. It's runnning correctly now that the otk library is not packaged in the jar. I'm not sure what the main issues were in intellij and if someone could comment on that it would be great.


Library settings.
Artifact settings
etc

15-Moonstone
February 12, 2020

session = pfcGlobal.GetProESession();