Load the licensing library to get license information : Java

Having trouble running Advanced Installer? Got a bug to report? Post it all here.

Load the licensing library to get license information : Java

Postby murug86 » Mon May 21, 2012 11:05 am

Hi,

I use the below code to get my custom licencing information as mentioned in your document,

interface TrialLibrary extends Library {
final TrialLibrary INSTANCE = (TrialLibrary) Native.loadLibrary("C:\\Program Files\\yyyt\\aps\\testtrail", TrialLibrary.class); // loads Trial.dll
int ReadSettingsStr(String keyCode, HWND hwnd);
int DisplayRegistrationStr(String keyCode, HWND hwnd);
String GetPropertyValue(String id);
}

private static final String LIBRARY_KEY = "11111";

public static void main(String[] args) {
int i = TrialLibrary.INSTANCE.ReadSettingsStr(LIBRARY_KEY, null); // works fine
System.out.println(TrialLibrary.INSTANCE.GetPropertyValue("Type"));
}

But this throws

#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x046229de, pid=4152, tid=4064
#
# JRE version: 6.0_26-b03
# Java VM: Java HotSpot(TM) Client VM (20.1-b02 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [testtrail.DLL+0x229de]
#
# An error report file with more information is saved as:
# D:\STS\workspace\SmarteServices_Release\hs_err_pid4152.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#


Please help me resolve this issue.
murug86
 
Posts: 52
Joined: Mon May 21, 2012 10:59 am

Re: Load the licensing library to get license information :

Postby murug86 » Tue May 22, 2012 8:00 am

Hi,

Can some please help me with the above issue, I am trying to access the properties of licence using GetPropertyValue as shown above.
murug86
 
Posts: 52
Joined: Mon May 21, 2012 10:59 am

Re: Load the licensing library to get license information :

Postby Bogdan » Tue May 22, 2012 10:32 am

Hi,

After searching more about this on the web it seems the problem usually appears because you are using a beta version of Java.

The solution is to remove the Beta version and install a new and stable release.

Also, I noticed you set the path for the DLL to be loaded from "C:\Program Files", please note that on x64 machines 32 bit applications
are installed in "C:\Program Files (x86)", so you should check this too, if it is the case for you.

Regards,
Bogdan
Bogdan Mitrache
Advanced Installer Team
http://www.advancedinstaller.com/
Bogdan
 
Posts: 2398
Joined: Tue Jul 07, 2009 7:34 am

Re: Load the licensing library to get license information :

Postby murug86 » Tue May 22, 2012 12:25 pm

Hi,

Thanks for the reply. I tried changing the java version to a stable version. But still i get the same error.

I was able to validate the licence using
TrialLibrary.INSTANCE.ReadSettingsStr(LIBRARY_KEY, null);

I get the error only when i add the below line,
TrialLibrary.INSTANCE.GetPropertyValue("ID")

Could you please provide any working examples for retrieving the properties from dll file.
murug86
 
Posts: 52
Joined: Mon May 21, 2012 10:59 am

Re: Load the licensing library to get license information :

Postby murug86 » Thu May 24, 2012 6:55 am

Hi,

What are we trying to do :

provide a licence with "number of users" limitation. and access "the number of users" in the application.

How did we try doing?

We tried adding a custom variable in the licence template. And we tried accessing the variable as shown above, Which resulted in the above issue.

What we need?

Do we have an alternative approach to achieve this? Please help us in achieving the above functionality.
murug86
 
Posts: 52
Joined: Mon May 21, 2012 10:59 am

Re: Load the licensing library to get license information :

Postby murug86 » Thu May 24, 2012 12:38 pm

Hi,

Can some please let me if this is possible atleast. We have been searching for this now for a while.
murug86
 
Posts: 52
Joined: Mon May 21, 2012 10:59 am

Re: Load the licensing library to get license information :

Postby Bogdan » Thu May 24, 2012 12:39 pm

Hi,

The samples we've provided are for integrating the licensing library in a java application that is launched using our java product support. Is your application using this support?

If not, you will have to load the library manually, as we showed in the C++/.NET samples, with additional steps. We will start an investigation for this too and
we'll be back with more details ASAP.

Regards,
Bogdan
Bogdan Mitrache
Advanced Installer Team
http://www.advancedinstaller.com/
Bogdan
 
Posts: 2398
Joined: Tue Jul 07, 2009 7:34 am

Re: Load the licensing library to get license information :

Postby murug86 » Thu May 24, 2012 12:58 pm

Thanks for the reply,

We are not using "java product support", Instead we are loading the .dll file manually in the java program. (as shown above).

I would be of great help if you can provide a Java example to retrieve the properties from DLL.


Thanks,
Murugavel
murug86
 
Posts: 52
Joined: Mon May 21, 2012 10:59 am

Re: Load the licensing library to get license information :

Postby Bogdan » Fri May 25, 2012 1:14 pm

Hi Murugavel,

We managed to reproduce the crash only if we tried to call "GetPropertyValue" when the application that is using the licensing library was not registered, i.e. it was in trial. Once the application was registered the exception disappeared and the value was correctly retrieved. The test was done in a Java application that is not using our java product launcher.

Is your application registered when you make the call to "GetPropertyValue"?

Regards,
Bogdan
Bogdan Mitrache
Advanced Installer Team
http://www.advancedinstaller.com/
Bogdan
 
Posts: 2398
Joined: Tue Jul 07, 2009 7:34 am

Re: Load the licensing library to get license information :

Postby murug86 » Sun May 27, 2012 2:25 am

Hi,

We now tried calling "GetPropertyValue" using the licensing library that was registered. But still the same problem occurs.

Can you please share the source that you used for reproducing the issue, I will check my code against it, to verify if i am missing anything.

Thanks a ton for you support.

Regards,
Murugavel.R
murug86
 
Posts: 52
Joined: Mon May 21, 2012 10:59 am

Re: Load the licensing library to get license information :

Postby murug86 » Mon May 28, 2012 7:28 am

Hi,

It would be of great help if you can share me the source code.

Thanks,
Murugavel
murug86
 
Posts: 52
Joined: Mon May 21, 2012 10:59 am

Re: Load the licensing library to get license information :

Postby Bogdan » Mon May 28, 2012 10:29 am

Hi Murugavel,

Here is the sample code you need, the problem was with the function signature, as you can see in the code its different:
Code: Select all
public interface TrialLibrary extends Library {
   final TrialLibrary INSTANCE = (TrialLibrary) Native.loadLibrary("C:\\Program Files (x86)\\Your Company\\Licensing\\lib",
                                 TrialLibrary.class); // loads Trial.dll
   int ReadSettingsStr(String keyCode, HWND hwnd);
   int DisplayRegistrationStr(String keyCode, HWND hwnd);
   // String GetPropertyValue(String id); here is the problem the GetPropertyValue native method has a different signature
   int GetPropertyValue(WString id, CharBuffer aBuffer, LongByReference len); // this is the solution
 }


private static final String LIBRARY_KEY = "43B10DE39332871B9AD8242FF81A7D44C081F0D7058BDEC4C177EC35194E53DA463777113BD3";

  public static void main(String[] args) {
  // initialize the library
  TrialLibrary.INSTANCE.ReadSettingsStr(LIBRARY_KEY, null);

  WString id = new WString("ID");

  // retrieve the size of the property
  LongByReference len = new LongByReference(0);
  TrialLibrary.INSTANCE.GetPropertyValue(id, null, len);

  // allocate buffer for property value
  CharBuffer buffer = CharBuffer.allocate((int)len.getValue());

  // retrieve property value
  TrialLibrary.INSTANCE.GetPropertyValue(new WString("ID"), buffer, len);
  buffer.limit((int)len.getValue() - 1);

  System.out.println(buffer.toString());
 }


Regards,
Bogdan
Bogdan Mitrache
Advanced Installer Team
http://www.advancedinstaller.com/
Bogdan
 
Posts: 2398
Joined: Tue Jul 07, 2009 7:34 am

Re: Load the licensing library to get license information :

Postby murug86 » Mon May 28, 2012 12:10 pm

Hi,

After changing the methods signature it worked.. Thanks a ton.

Regards,
Murugavel.R
murug86
 
Posts: 52
Joined: Mon May 21, 2012 10:59 am

Re: Load the licensing library to get license information :

Postby Bogdan » Mon May 28, 2012 12:22 pm

Always a pleasure Murugavel.

Best of all,
Bogdan
Bogdan Mitrache
Advanced Installer Team
http://www.advancedinstaller.com/
Bogdan
 
Posts: 2398
Joined: Tue Jul 07, 2009 7:34 am


Return to Common Problems

Who is online

Users browsing this forum: Google [Bot] and 5 guests