So I’ve run into error that I’ve not encountered before when using VP and more specifically, using the plugin scripts mechanism.
To give some context, we use a Mac VM to execute scripts throughout the day. When I’m connected to the device using Screen Sharing, I am able to execute these commands from within the terminal no problem. eg; example of updating a VP project using the plugin script
cd "/Applications/Visual Paradigm.app/Contents/Resources/app/scripts/" && sh UpdateTeamworkProject.sh -workspace "/Users/x/Library/Application Support/VisualParadigm/ws/" -project "/Users/x/Library/Application Support/VisualParadigm/ws/teamwork_client/projects/y/y.vpp"
However when accessing the device using ssh and running the same script as above, I get the following error from java:
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class sun.lwawt.macosx.LWCToolkit
at java.desktop/sun.awt.PlatformGraphicsInfo.createToolkit(PlatformGraphicsInfo.java:47)
at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:592)
at java.desktop/sun.awt.CGraphicsEnvironment.<clinit>(CGraphicsEnvironment.java:73)
at java.desktop/sun.awt.PlatformGraphicsInfo.createGE(PlatformGraphicsInfo.java:43)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:93)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.<clinit>(GraphicsEnvironment.java:84)
at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:106)
at v.aid.ad.a(:299)
at v.aid.ad.g(:261)
at v.avz.bm.a(:834)
at v.avz.bm.a(:239)
at v.avc.b.a(:83)
at com.vp.cmd.UpdateTeamworkProject.a(:38)
at com.vp.cmd.UpdateTeamworkProject.main(:23)
I am running the following version of VP: 16.1 and the current Java version is: 8 update 301.
Thanks for responding @Jick . I’ve just uploaded the log file.
UPDATE:
I’ve just done some further investigation. Within the Screen Sharing app, I opened up VP on the Mac VM; I also ssh onto the Mac VM and I executed the command shared in the original post. In doing so, it returns the following error:
Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Workspace in use.
However, if I then create a new workspace, try to rerun the command using ssh in the terminal, I still get the same error as in the OP. It’s almost as though it can’t initialise the application or something when remotely connecting to that device.
I have tried doing the same approach as above but on an physical device (Mac Mini) as opposed to a VM and this doesn’t throw any problem. It updates a given project fine.
I have updated the plugin.sh file with the change you mentioned however the java.lang.NoClassDefFoundError still persists when ssh onto the Mac VM.
plugin.sh file below:
#!/bin/sh
cd ../bin
if [ "v$HEADLESS" = "v" ]; then
HEADLESS=true
fi
JAVA="../jre/bin/java"
if [ ! -f "$JAVA" ]; then
JAVA="../../jre/bin/java"
fi
if [ ! -f "$JAVA" ]; then
JAVA="../../jre.bundle/Contents/Home/jre/bin/java"
fi
if [ ! -f "$JAVA" ]; then
JAVA="../../.install4j/jre.bundle/Contents/Home/jre/bin/java"
fi
if [ ! -f "$JAVA" ]; then
JAVA="java"
fi
"$JAVA" -Xms4096m -Xmx8192m -XX:MaxPermSize=4096m -Djava.awt.headless=$HEADLESS -cp ...
You mentioned setting the environment variable for a single session, where in VP or what config file do I need to set this?
Is the trace the same? It could be the same error but with a different trace. If the trace is the same, then it is likely that the headless variable wasn’t applied correctly… If the trace is different, could you send me to have a look?
Yes, the stack is the same error. Error shown below:
Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class sun.lwawt.macosx.LWCToolkit
at java.desktop/sun.awt.PlatformGraphicsInfo.createToolkit(PlatformGraphicsInfo.java:47)
at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:597)
at java.desktop/sun.awt.CGraphicsEnvironment.<clinit>(CGraphicsEnvironment.java:72)
at java.desktop/sun.awt.PlatformGraphicsInfo.createGE(PlatformGraphicsInfo.java:43)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:93)
at java.desktop/java.awt.GraphicsEnvironment$LocalGE.<clinit>(GraphicsEnvironment.java:84)
at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:106)
at v.aid.ad.a(:299)
at v.aid.ad.g(:261)
at v.avz.bm.a(:834)
at v.avz.bm.a(:239)
at v.avc.b.a(:83)
at com.vp.cmd.UpdateTeamworkProject.a(:38)
at com.vp.cmd.UpdateTeamworkProject.main(:23)
The log file contains the following:
[2021/08/17 08:45:28] [message] Aug 17, 2021 8:45:28 AM com.jidesoft.plaf.aqua.AquaPreferences loadGlobalPreferences
WARNING: AquaPreferences failed to load Mac OS X global system preferences - parseInt: unsupported byte count:16
[2021/08/17 08:45:28] [message] Connect to repository https://x.vpository.com [Success]
Just to add, I am running Big Sur on the Mac VM. The device in which it was working successfully on was using Catalina.
First of all, please try to set in the environment variable, run:
“HEADLESS=true ./plugin.sh”
We have developed a test program to help to diagnose the problem. Please down the zip here:
Then, unzip the downloaded file to obtain the Test.class file. Copy the Test.class file to the script folder. Then, change the last line of plugin.sh to:
“$JAVA” -Xms4096m -Xmx8192m -XX:MaxPermSize=4096m -Djava.awt.headless=$HEADLESS -cp . Test
The output is expected to be:
java.awt.headless: true
GraphicsEnvironment.isHeadless(): true
As requested, I downloaded the file, unzipped and saved it within the scripts directory. I changed the plugin.sh as shown below:
#!/bin/sh
cd ../bin
if [ "v$HEADLESS" = "v" ]; then
HEADLESS=true
fi
JAVA="../jre/bin/java"
if [ ! -f "$JAVA" ]; then
JAVA="../../jre/bin/java"
fi
if [ ! -f "$JAVA" ]; then
JAVA="../../jre.bundle/Contents/Home/jre/bin/java"
fi
if [ ! -f "$JAVA" ]; then
JAVA="../../.install4j/jre.bundle/Contents/Home/jre/bin/java"
fi
if [ ! -f "$JAVA" ]; then
JAVA="java"
fi
"$JAVA" -Xms4096m -Xmx8192m -XX:MaxPermSize=4096m -Djava.awt.headless=$HEADLESS -cp . Test
Then I run the following command within the terminal:
sh Plugin.sh -project "/Users/admin/Library/Application Support/VisualParadigm/ws/teamwork_client/projects/X/X.vpp"
However it returns the following:
Java HotSpot(TM) 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Error: Could not find or load main class Test
Caused by: java.lang.ClassNotFoundException: Test
Thanks for pointing that out, that seemed to fix the issue!
Out of curiosity on the physical device, we have set HEADLESS=false and yet we can still SSH onto the device and run VP without the UI. But on the Mac VM by setting it too true, it works.