-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnsatisfiedLinkError
when loading model
#57
Comments
Great, you already ran the test suite. This helps because we can see that even It does essentially this: import mph
client = mph.start()
model = client.create('empty')
model.save() That just creates an empty model and saves it. Running the above script (let's call it Now, we can do the same thing in Java. You don't need to install anything, Comsol alone will do. We're just following the Comsol Programming Manual here, specifically the "Getting Started" section (page 20), although I will make it even simpler by doing the equivalent of the above Python script. Create this import com.comsol.model.*;
import com.comsol.model.util.*;
public class empty {
public static void main(String[] args) throws java.io.IOException {
ModelUtil.initStandalone(false);
Model model = ModelUtil.create("empty");
model.save("empty.mph");
System.exit(0);
}
} Then compile it using this command on the Windows command prompt: "C:\Program Files\COMSOL\COMSOL56\Multiphysics\bin\win64\comsolcompile.exe" empty.java Adjust the path for your Comsol installation if it's a different version or you installed it in a custom location. This should create a file named "C:\Program Files\COMSOL\COMSOL56\Multiphysics\java\win64\jre\bin\java.exe" -classpath ".;C:\Program Files\COMSOL\COMSOL56\Multiphysics\plugins\*" empty This should create the afore-mentioned If it doesn't, then only Comsol can help you. And they should. This (using the Java API) is an officially supported use case. If it does work in Java, but not in Python, then, well, the only clue I got while writing this is that I get pretty much exactly the same error as you do if I comment out the line |
Thanks for your quick response! The |
Hm, then it seems like the stand-alone client does not get initialized. I have no idea why though. Can you run the $ python tests\test_standalone.py log debug
Starting local Comsol session.
Checking registry node "SOFTWARE\Comsol\COMSOL56".
Checking installation folder "C:\Program Files\COMSOL\COMSOL56\Multiphysics".
Reported version info is "COMSOL Multiphysics 5.6.0.280".
Assigned name "5.6" to this installation.
JPype version is 1.3.0.
Starting Java virtual machine.
JVM arguments: ['C:\\Program Files\\COMSOL\\COMSOL56\\Multiphysics\\java\\win64\\jre\\bin\\server\\jvm.dll']
Java virtual machine has started.
Initializing stand-alone client.
Stand-alone client initialized.
Created model "empty" with tag "model1".
Retagging "components/Component 1": "tag1" → "comp1".
Removing model "empty" with tag "model1".
Exiting the Java virtual machine. Assuming you're in the project root folder, I think it's named You can also try running in client-server mode, i.e. not with the stand-alone client. This is the default on Linux, but you're on Windows. So you would need to explicitly activate this option, like so: import mph
mph.option('session', 'client-server')
client = mph.start()
model = client.create('empty')
model.save() |
Here are the log messages from Checking registry node "SOFTWARE\Comsol\COMSOL56".
Checking installation folder "C:\Program Files\COMSOL\COMSOL56\Multiphysics".
Reported version info is "COMSOL Multiphysics 5.6.0.401".
Assigned name "5.6" to this installation.
JPype version is 1.3.0.
Starting Java virtual machine.
JVM arguments: ['C:\\Program Files\\COMSOL\\COMSOL56\\Multiphysics\\java\\win64\\jre\\bin\\server\\jvm.dll']
Java virtual machine has started.
Initializing stand-alone client.
Stand-alone client initialized.
Traceback (most recent call last):
File "SourceFile", line 90, in com.comsol.model.util.ModelUtil.createUnique
File "SourceFile", line 83, in com.comsol.model.util.ModelUtil.create
File "SourceFile", line 42, in com.comsol.model.util.ServerModelUtil.create
File "SourceFile", line 636, in com.comsol.nativeutil.d.b.m
File "SourceFile", line 22, in com.comsol.nativeutil.d.c.<clinit>
File "SourceFile", line 166, in com.comsol.nativejni.util.FlLicense.getInstance
File "SourceFile", line 71, in com.comsol.nativejni.util.FlLicense.<init>
File "SourceFile", line -2, in com.comsol.nativejni.util.FlLicense.initWS0
Exception: Java Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File ".\tests\test_standalone.py", line 57, in <module>
test_start()
File ".\tests\test_standalone.py", line 26, in test_start
model = client.create('empty')
File "C:\Users\PSPL_Workstation_1\SP\comsol\MPh-main\mph\client.py", line 356, in create
java = self.java.createUnique('model')
java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError:
com.comsol.nativejni.util.FlLicense.initWS0(Lcom/comsol/nativejni/CPointer;)V
Exiting the Java virtual machine. Adding |
Yes, stand-alone mode would be better. But client-server mode will work as well. Some things will be a bit slower, but not the simulations themselves. And you'll occasionally get the It frustrates me a bit that I have no explanation for the behavior you report. That doesn't bode well for MPh in terms of reliability. But I'm out of ideas at this point, so not much else to do about it. For the record, the following script does the same as import jpype
import jpype.imports
root = 'C:/Program Files/COMSOL/COMSOL56/Multiphysics'
jvm = root + '/java/win64/jre/bin/server/jvm.dll'
jars = root + '/plugins/*'
jpype.startJVM(jvm, classpath=jars)
from com.comsol.model.util import ModelUtil
ModelUtil.initStandalone(False)
model = ModelUtil.createUnique('empty')
model.save('empty.mph')
jpype.java.lang.Runtime.getRuntime().exit(0) Based on the error messages you got with other scripts, this one will also fail when the line containing So, sorry about that. If you discover something that might shed some light on this issue, please report back. We'll have to leave it open anyway as it's unresolved. Using client-server mode, I'd consider that a work-around. Though obviously it's also not that big a deal. |
By running this line: The above exception was the direct cause of the following exception: Traceback (most recent call last): What should I do? Thank You |
Hello, I'm facing the same issue. Still no update on how to fix it ? I'm on a floating license that might lead to other problems... Thanks |
No update, no. I cannot reproduce the error, so can't fix it. And using client-server mode seems to fix it anyway. |
Just this week, in an entirely unrelated context (nothing to do with Comsol), I ran into a strange conflict with external libraries, which would only occur when the user had Python installed from the Microsoft Store. On Windows, obviously. I just realized that the two previous error reports, further up in the thread, also used the Microsoft Store version of Python. On that hunch — and it's a mere hunch —, I would recommend that users, who run into the issue discussed here, uninstall Python and reinstall it using the official Python installer from python.org. Obviously, I have no idea if that actually fixes the issue. (I cannot reproduce it, after all.) But if you had this issue and using the official python.org installer fixed it, please report back here. Likewise, if you have this issue with the python.org Python installation, kindly let people know as well. |
This is an old issue however I ran into the same issue as the users above and following from the above comment I manually installed the python version and that fixed the problem for me. Just for future reference for anyone else that has this problem. |
@garretlanglois Thanks for the feedback! I'll add this to the documentation before the next release (whenever that may be), as it's pretty solid evidence that there's something that breaks MPh in the Microsoft Store version of Python. (Probably got something to do with different external libraries being linked against.) |
Hi,
I'm creating a new issue as per #56--the following code results in the subsequent errors:
I've referenced the edge case from #49, and the following lines do not result in any errors (when I run from a Windows machine using Powershell):
I've also looked into the test suite and am able to run just about all the test_ scripts except for
test_model.py
,test_node.py
, andtest_standalone.py
. Pasted below are the errors fromtest_model.py
andtest_standalone.py
, respectively.As was mentioned earlier, this is using an FNL license, though it is unlikely to be the source of the error. There seems to be an issue with the
createUnique
function but I am not too sure why it wouldn't work. Your assistance would be greatly appreciated.The text was updated successfully, but these errors were encountered: