MPh-py / MPh

Pythonic scripting interface for Comsol Multiphysics
https://mph.readthedocs.io
MIT License
263 stars 67 forks source link

License error -5 No such product #56

Closed cescoo1 closed 2 years ago

cescoo1 commented 2 years ago

Hi,

first of all thanks for MPh package! I tried to follow the documentation but I get this error message. I may add, that I have a 'Classkit' Comsol License and a 'Reasearchkit' License on the machine. To make it more complicated, there are two versions of Comsol installed 5.5 and 5.6., of each license. But I only have access to the 'Classkit' version. I don't know if the problem lays in the 'Research-kit' license or if the issue is of a different nature.

Lastly, even if I select a Comsol, say 5.6. the error changes to: ' LookupError: Could not locate Comsol 5.6 installation.'

It would be great, if you could help me with this issue. Thank you!!!

import mph
#client = mph.start(cores=1,version=5.6)
client = mph.start(cores=1)
model = client.load('capacitor.mph')
print(client.names())

Traceback (most recent call last):
File "SourceFile", line 168, in com.comsol.model.util.ModelUtil.load
File "SourceFile", line 139, in com.comsol.model.util.ServerModelUtil.load
File "AccessController.java", line -2, in java.security.AccessController.doPrivileged
File "SourceFile", line 1, in com.comsol.model.util.ServerModelUtil$39.run
File "SourceFile", line 142, in com.comsol.model.util.ServerModelUtil$39.a
File "SourceFile", line 312, in com.comsol.model.util.ModelInternalUtil.load
File "SourceFile", line 326, in com.comsol.model.util.ModelInternalUtil.load
File "SourceFile", line 1189, in com.comsol.model.util.ModelManager.loadModel
File "SourceFile", line 961, in com.comsol.model.util.ModelManager.a
File "SourceFile", line 984, in com.comsol.model.util.ModelManager.a
File "SourceFile", line 1238, in com.comsol.model.util.ModelManager.a
File "SourceFile", line 107, in com.comsol.model.util.saveload.AbstractModelLoader.load
File "SourceFile", line 185, in com.comsol.model.util.saveload.AbstractMphLoader.a
File "SourceFile", line 508, in com.comsol.model.util.saveload.AbstractModelLoader.a
File "SourceFile", line 109, in com.comsol.model.util.saveload.AbstractModelLoader.a
File "SourceFile", line 218, in com.comsol.model.util.saveload.AbstractMphLoader.b
File "SourceFile", line 248, in com.comsol.model.util.saveload.AbstractMphLoader.c
File "SourceFile", line 337, in com.comsol.model.util.saveload.AbstractMphLoader.a
File "SourceFile", line 588, in com.comsol.model.util.saveload.AbstractMphLoader.d
File "SourceFile", line 3143, in com.comsol.model.dbmodel.ModelDb.postLoadInitialize
File "SourceFile", line 3275, in com.comsol.model.method.ModelMethod.doPostLoadInitialize
File "SourceFile", line 2395, in com.comsol.model.method.ModelMethod.fullVariableUpdate
File "SourceFile", line 1657, in com.comsol.model.method.ModelMethod.a
File "SourceFile", line 142, in com.comsol.model.util.MultiphysicsLicenseManager.checkOutRequiredLicenses
File "SourceFile", line 280, in com.comsol.nativeutil.d.b.e
File "SourceFile", line 286, in com.comsol.nativeutil.d.b.a
File "SourceFile", line 33, in com.comsol.nativeutil.d.c.a
File "SourceFile", line 182, in com.comsol.nativejni.util.FlLicense.hasFeature
File "SourceFile", line -2, in com.comsol.nativejni.util.FlLicense.hasFeature
File "Detail: No such feature exists.
Feature:       COMSOL
License path:  C:\Program Files\COMSOL\COMSOL56\Multiphysics\license\license.dat;
FlexNet Licensing error:-5,412", line 0, in license.cpp. Row: 439
com.comsol.nativejni.FlNativeException: Exception:
com.comsol.nativejni.FlNativeException: License error -5 No such product exists
Messages:
License error -5 No such product exists

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "SourceFile", line 168, in com.comsol.model.util.ModelUtil.load File "SourceFile", line 139, in com.comsol.model.util.ServerModelUtil.load File "AccessController.java", line -2, in java.security.AccessController.doPrivileged File "SourceFile", line 1, in com.comsol.model.util.ServerModelUtil$39.run File "SourceFile", line 142, in com.comsol.model.util.ServerModelUtil$39.a File "SourceFile", line 312, in com.comsol.model.util.ModelInternalUtil.load File "SourceFile", line 326, in com.comsol.model.util.ModelInternalUtil.load File "SourceFile", line 1189, in com.comsol.model.util.ModelManager.loadModel File "SourceFile", line 961, in com.comsol.model.util.ModelManager.a File "SourceFile", line 984, in com.comsol.model.util.ModelManager.a File "SourceFile", line 1238, in com.comsol.model.util.ModelManager.a File "SourceFile", line 107, in com.comsol.model.util.saveload.AbstractModelLoader.load File "SourceFile", line 185, in com.comsol.model.util.saveload.AbstractMphLoader.a File "SourceFile", line 508, in com.comsol.model.util.saveload.AbstractModelLoader.a File "SourceFile", line 109, in com.comsol.model.util.saveload.AbstractModelLoader.a File "SourceFile", line 218, in com.comsol.model.util.saveload.AbstractMphLoader.b File "SourceFile", line 248, in com.comsol.model.util.saveload.AbstractMphLoader.c File "SourceFile", line 337, in com.comsol.model.util.saveload.AbstractMphLoader.a File "SourceFile", line 588, in com.comsol.model.util.saveload.AbstractMphLoader.d File "SourceFile", line 3143, in com.comsol.model.dbmodel.ModelDb.postLoadInitialize File "SourceFile", line 3275, in com.comsol.model.method.ModelMethod.doPostLoadInitialize File "SourceFile", line 2395, in com.comsol.model.method.ModelMethod.fullVariableUpdate File "SourceFile", line 1657, in com.comsol.model.method.ModelMethod.a File "SourceFile", line 142, in com.comsol.model.util.MultiphysicsLicenseManager.checkOutRequiredLicenses File "SourceFile", line 280, in com.comsol.nativeutil.d.b.e File "SourceFile", line 286, in com.comsol.nativeutil.d.b.a File "SourceFile", line 37, in com.comsol.nativeutil.d.c.a Exception: Java Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "c:/Users/frsc03/py_coms/Comsol.py", line 9, in model = client.load('capacitor.mph') File "c:\Users\frsc03\py_coms\mainenv\lib\site-packages\mph\client.py", line 324, in load model = Model(self.java.load(tag, str(file))) com.comsol.util.exceptions.LicenseException: Exception: com.comsol.nativejni.FlNativeException: License error -5 No such product exists (rethrown as com.comsol.util.exceptions.LicenseException) Messages: Could not obtain license for#COMSOL Multiphysics

    License error -5 No such product exists
john-hen commented 2 years ago

Hi. So, another license issue…

Let me address the easy part first: You get the LookupError because you passed version=5.6. That's a floating-point number, but needs to be a string: version='5.6'. Remember that there are Comsol versions which contain letters too, like 5.3a. Having multiple Comsol installations to choose from is not a problem at all, this was a design goal for MPh from the start. So that we can run benchmarks with the same model across different Comsol versions.

As for the license, that's something MPh tries to stay away from as much as possible. All it does is, essentially, start Comsol and then tell it what to do. But when Comsol loads a model, it (Comsol) checks the license and makes sure that you have the one for the core platform as well as for any add-on module ("product") that the model might require.

I've only ever had (and therefore tested with) the regular commercial "CPU-Locked License". But Comsol has a number of license options. I have no experience with any of the others, and also no idea how commonly there are used. "Research Kit" isn't even on that list and this is the first time I'm hearing that term.

For the "Class Kit" license we added support in #40. You need to set the corresponding config option with mph.option('classkit', True) before calling mph.start().

If that doesn't do it, then the question becomes: How do you start the Comsol server executable (comsolmphserver on Windows, comsol mphserver on Linux/macOS) from the command line? The Class Kit license, for example, requires a special argument to be passed: -ckl. I don't know why that's necessary, why Comsol's license manager can't figure this out by itself. But if you have to, for example, use that Research Kit license, or if the classkit option doesn't work, then seeing what it takes to start a server session in the console would be the first step to solving this issue.

cescoo1 commented 2 years ago

your're the best! ´´´´ mph.option('classkit',True) ´´´ did the job!

Thank you for your time and support!!!

shehan807 commented 2 years ago

Hi,

I am new to MPh and am also experiencing similar issues but with a Floating Network License (FNL). In principle, it should work just as the CPU-Locked Single User License (CPU). When I run comsolmphserver, I am able to run COMSOL on a Windows machine using Windows Powershell and in the cmd prompt. However, just from some basic commands,

client = mph.start(cores=1)
model = client.load('filename.mph')

I get the following error message:

File "SourceFile", line 168, in com.comsol.model.util.ModelUtil.load
File "SourceFile", line 134, in com.comsol.model.util.ServerModelUtil.load
File "SourceFile", line 930, in com.comsol.model.util.ServerModelUtil.a
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 ".\runAcc.py", line 8, in <module>
model = client.load('PEPPER-Sweep_CMNT_ACC_only.mph')
File
"C:\Users\PSPL_Workstation_1\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\mph\client.py",
line 324, in load
model = Model(self.java.load(tag, str(file)))
java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError:
com.comsol.nativejni.util.FlLicense.initWS0(Lcom/comsol/nativejni/CPointer;)V

Would this still be related to the license and not MPh?

Thanks!

john-hen commented 2 years ago

Well, I don't know what's up with that. As you can see from the traceback, it's just as I described in the earlier comment: Comsol wants to load the file (ModelUtil.load), but then the license manager (FlLicense) fails to start.

This has nothing to do, by the way, with the floating network license. "Fl" stands for Femlab, the original name for Comsol back when it was still a Matlab toolbox.

Also, to be clear, while I haven't tested with that type of license, other people have. And they don't run into this error.

In the end, Java throws an UnsatisfiedLinkError. That means that some dynamically loaded library, a DLL, has not been found. So this isn't a license issue per se. Now, helping Comsol find its own libraries is something MPh does do. For example, it tells Comsol from where to load its Java libraries. These are .jar files though, not DLLs. The DLLs Comsol usually finds automatically, as it should, but MPh could help out when that fails. See issue #49 for an edge case where that was necessary.

But the bottom line is this: There must be something unusual about your system. Maybe in the way the license manager is installed? Pure guess though. There are some ways to get to the bottom of this. Like running the MPh test suite might provide some clues. Though the probably best thing to do is create a small Java program that just loads a model. Because if that fails, with just Java and no Python, you could take that to Comsol Support. I could help with that, but I obviously cannot do it for you as I can't even reproduce the error.

If you want to look into this more, please open a new issue. I would suggest "UnsatisfiedLinkError when loading model" as the title.