cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
peijunyan
Level 4

Can't use absolute path of a license file to createLicenseSource

In the Java API document, License should support the relative or absolute path of a license file, for example "/a/b/c/license.lic". But it failed with Invalid Server Port Number (-500,4018) returned. Any suggestion?

FLEXnet Licensing version: v11.4.0.0.
under winXP Professional version2002 SP2
Labels (1)
0 Kudos
(7) Replies
RobertDickau
Flexera Alumni

Could you post a fragment of the code that fails?

For example, this seems to work:
LicenseSource f1LicSrc =
LicenseSource.createLicenseSource("C:\\jflexapp.lic", viTestInfo, null);

f1license = new License(f1spec, f1LicSrc);

f1license.checkout(1);

// etc.
0 Kudos
peijunyan
Level 4

Hi, Thanks! But same error returned when we used your sample code!
The following are the fragment of my code
String licSource = System.getenv("VENDOR_LICENSE_FILE");
lic = new License(fs, licSource, vInfo, new ConnectionDataAdapter(){…});
0 Kudos
RobertDickau
Flexera Alumni

As a sanity check, what is the value of VENDOR_LICENSE_FILE on your system?

(And it seems you're not using createLicenseSource, but if you do, be aware that it takes only a single source and not a list of sources.)
0 Kudos
peijunyan
Level 4

We have changed our code like yours. Still don’t work.

//--changed code--//
fs = new FeatureSpecifier(featureName, version);
LicenseSource f1LicSrc = LicenseSource.createLicenseSource("C:\\20070731-wesley.lic", vInfo, null);
lic = new License(fs, f1LicSrc);

//--our original code--//
String licSource = System.getenv("VENDOR_LICENSE_FILE");
// value of "VENDOR_LICENSE_FILE" is "C:\20070731.lic".
lic = new License(fs, licSource, vInfo, new ConnectionDataAdapter(){…});
0 Kudos
RobertDickau
Flexera Alumni

To try to isolate the issue, here's a complete simple app that uses a hard-coded absolute path (using the demo toolkit, adapted from 11.4 toolkit sample BasicExample.java):
[code]import com.macrovision.flexlm.*;

public class SimpleExample implements FlexlmConstants
{
public static final void main(String args[])
{
// get a VendorInfo instance (below)
VendorInfo vInfo = getVendorInfo( );

FeatureSpecifier fs = null;
License lic = null;

try
{
fs = new FeatureSpecifier("F1", "1.0");
lic = new License(fs, "C:\\jflexapp.lic", vInfo, null);

// check out a license
lic.checkout(1);

// get VENDOR_STRING...
Feature feat = lic.getFeature( );
String vendorString = feat.getVendorString( );
System.out.println(
"\nF1 checked out (VENDOR_STRING: " + vendorString + ")\n");
System.out.print("Press Enter to check back in... ");

// wait for user...
try { int i = System.in.read( ); } catch (java.io.IOException e) { }

// check the license back in
lic.checkin( );
System.out.println("Done!");

} catch (FlexlmException drat)
{
System.out.println(drat.getMessage( ));
System.exit(1);
}
}

private static VendorInfo getVendorInfo( )
{
VendorInfo vInfo = null;
try {
vInfo = new demoInfo( );
} catch (FlexlmException e) {
throw new RuntimeException(e.getMessage( ));
}
return vInfo;
}
}[/code]
Contents of C:\jflexapp.lic are something like this:
INCREMENT F1 demo 1.0 1-jan-2010 uncounted \
VENDOR_STRING="Hello from JFlexapp.lic!" HOSTID=DEMO SIGN="..."
0 Kudos
peijunyan
Level 4

Thx again. But we have tried this example. Failed with same error.
0 Kudos
peijunyan
Level 4

This is resolved! It is caused by incorrect port in SERVER line of license file.

=original license file
SERVER hostname hostid ANY
....
=updated license file
SERVER hostname hostid 27000
....

After updating port in the license file, it works for Java now. But notice that with original license file, license server has been started without any warning or error and C++ application could check out license successfully.
0 Kudos