|
Attention! Read the forum rules carefully before posting a topic.
Try to find an answer in Wiki before asking a question. Submit programming questions in this forum only. Off topics are strictly forbidden.
Any topics which do not satisfy these rules will be deleted.
Access native libraries (via JNA) |
[bigdir]
|
Post subject: Error: Unable to compile. Please restart platform. |
Post rating: 0
|
Posted: Thu 22 Oct, 2009, 14:13
|
|
User rating: 0
Joined: Wed 21 Oct, 2009, 04:47 Posts: 22
|
Can someone please help me with this error:
Unable to compile. Please restart platform.
I have restarted the platform several times and attempted to compile a blank indicator but I keep getting the message. On one occasion when I got this message, a restart fixed the issue but now it wont go away!
Thanks.
|
|
|
|
 |
[bigdir]
|
Post subject: Re: Error: Unable to compile. Please restart platform. |
Post rating: 0
|
Posted: Thu 22 Oct, 2009, 22:50
|
|
User rating: 0
Joined: Wed 21 Oct, 2009, 04:47 Posts: 22
|
I have fiddled around for quite some time and managed to fix this. I basically had to go to the Sun java cache directories (\Documents and Settings\<Username>\Application Data\Sun\Java\Deployment\cache\6.0\) and find out where the jforex jars were being cached. I got rid of them and then re-launched the platform from the main Dukascopy website. After it downloaded the jars again and retrying the compile, everything worked.
Could I just ask Support one question - it appears that when the Jforex platform crashes (I'm not sure if the crash is directly related to the platform or just java in general but my machine locked up twice now), it seems that the source file I am editing gets completely corrupted. All that is left is a bunch of control characters in the file. Is there some feature you can add to make a backup of the file being edited? The only thing that saved me is having an older copy of my source in Eclipse.
Thanks!
|
|
|
|
 |
API Support
|
Post subject: Re: Error: Unable to compile. Please restart platform. |
Post rating: 0
|
Posted: Fri 23 Oct, 2009, 09:27
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Hi, we will investigate this problem. It would be very helpful if you could provide us with some information: - please describe in detail, how JForex crashed. What was your actions?
- which Java version are you using?
- which OS are you using?
|
|
|
|
 |
[bigdir]
|
Post subject: Re: Error: Unable to compile. Please restart platform. |
Post rating: 0
|
Posted: Sat 24 Oct, 2009, 02:14
|
|
User rating: 0
Joined: Wed 21 Oct, 2009, 04:47 Posts: 22
|
Hi there,
I will see if there is a pattern next time it happens, although the last crash happened at the moment I was compiling. Basically the Dukascopy platform failed to respond after that. Then, although I could ALT-Tab through various applications (on Windows XP), no application would respond. I attempted to get to the TaskManager to see what was responsible, but no luck - I had to hard reset the machine. Given the symptoms, I wasn't inclined to think it wasn't the Dukascopy platform at fault, but rather the Java VM (no other notable applications were running). I am using Java 1.6 (v6).
Just a further note that could assist others - after this crash, some weird things were happening including the left-hand side panel (which has workspace, conditional orders, etc) went missing. The only way I could restore it was by selecting Tools->Preferences->Advanced and checking the 'delete saved settings' checkbox (I tried restarting the platform several times before that but it didn't work).
I figure that if automatic backups are made of all the settings & source, this would hopefully alleviate some of the impact of a crash & improve the "resiliency" of the platform.
Appreciate your assistance.
|
|
|
|
 |
[bigdir]
|
Post subject: Re: Error: Unable to compile. Please restart platform. |
Post rating: 0
|
Posted: Mon 26 Oct, 2009, 03:32
|
|
User rating: 0
Joined: Wed 21 Oct, 2009, 04:47 Posts: 22
|
I'm inclined to now believe the crash is something that the Dukascopy platform is instigating. It again happened during a right-click 'Compile' from the strategy menu. After that, everything locked up on my PC - the mouse was still working, but I couldn't access any other application so unfortunately couldn't gather any further info. The only thing notable I was doing is tweaking code & recompiling quite often.
As before, the source that I was editing got corrupted - basically it is filled with a repeating control character. Just extrapolating - if the source code is corrupted, perhaps something in between saving and compiling the source is causing the issue? I think there are several checks that are done to the Indicator source, so maybe this is causing a problem?
|
|
|
|
 |
[bigdir]
|
Post subject: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Mon 26 Oct, 2009, 14:11
|
|
User rating: 0
Joined: Wed 21 Oct, 2009, 04:47 Posts: 22
|
Hi support, I have been trying to use the Java Native Access (JNA) libraries in the platform but coming across difficulties. In particular, I seem to be getting a null pointer exception when trying to use the 'CLibrary' interface as shown in the code below. I can run this code through Eclipse without any issues, which suggests to me that perhaps my library search path was incorrect or that I didn't have access to the DLL - both issues I have tried to address in the code with a manual setting of the library search path and using the annotation @RequiresFullAccess. The example below has a dummy library name as the DLL I am using is a proprietary one. I imagine that any DLL would yield the same null pointer exception as it seems to fail whenever Clibrary.INSTANCE is called. Please note also that some of the code is not entirely complete - the main point of interest is to get the native call to work. JNA can be downloaded from here: https://jna.dev.java.net/servlets/Proje ... folderID=0Appreciate any help on trouble-shooting the issue. import com.dukascopy.api.IConsole; import com.dukascopy.api.indicators.*; import com.dukascopy.api.Library; import com.dukascopy.api.RequiresFullAccess; import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna.Pointer; import com.sun.jna.TypeMapper; import com.sun.jna.ptr.PointerByReference;
@Library("jna.jar") @RequiresFullAccess()
public class JnaIndicator implements IIndicator { private IIndicator sma1; private IIndicator sma2; private int timePeriod = 15; private IIndicatorContext context; private IConsole console;
private IndicatorInfo indicatorInfo; private InputParameterInfo[] inputParameterInfos; private OutputParameterInfo[] outputParameterInfos; private OptInputParameterInfo[] optInputParameterInfos; private double[][] inputs = new double[1][]; private double[][] outputs = new double[2][];
// This is the standard, stable way of mapping, which supports extensive // customization and mapping of Java to native types. public interface CLibrary extends com.sun.jna.Library { static CLibrary INSTANCE = (CLibrary) Native.loadLibrary("dlllib", CLibrary.class);
int Cfunction(int size, double[] daInData, double[] daOutData); }
public void onStart(IIndicatorContext context) {
this.context = context; this.console = context.getConsole();
indicatorInfo = new IndicatorInfo("JnaIndicator", "JnaIndicator", "Custom", true, false, false, 1, 1, 1);
inputParameterInfos = new InputParameterInfo[]{new InputParameterInfo("Price", InputParameterInfo.Type.DOUBLE)};
optInputParameterInfos = new OptInputParameterInfo[]{new OptInputParameterInfo("Period", OptInputParameterInfo.Type.OTHER, new IntegerRangeDescription(timePeriod, 1, 100, 1)), };
outputParameterInfos = new OutputParameterInfo[]{ new OutputParameterInfo("output", OutputParameterInfo.Type.DOUBLE, OutputParameterInfo.DrawingStyle.LINE) }; }
public IndicatorResult calculate(int startIndex, int endIndex) {
int i = 0, k = 0; try { //calculating startIndex taking into account lookback value if (startIndex - getLookback() < 0) { startIndex -= startIndex - getLookback(); } if (startIndex > endIndex) { return new IndicatorResult(0, 0); }
double[] dinput; double[] dresult; int totalSize = endIndex - startIndex + 2 + iLookback; dresult = new double[totalSize]; dinput = new double[totalSize];
// This method fails with a null pointer exception. CLibrary.INSTANCE;
// Never gets here, although this would also fail due to a null pointer exception int result = CLibrary.INSTANCE.Cfunction(totalSize, dinput, dresult);
} catch ( Exception ex ) { this.console.getOut().println("calculate error: " + ex.getMessage() + "\r\n" + ex.getStackTrace().toString()); } return new IndicatorResult(startIndex, i - 1); }
public IndicatorInfo getIndicatorInfo() { return indicatorInfo; }
public InputParameterInfo getInputParameterInfo(int index) { if (index <= inputParameterInfos.length) { return inputParameterInfos[index]; } return null; }
public int getLookback() { return timePeriod; }
public int getLookforward() { return 0; }
public OutputParameterInfo getOutputParameterInfo(int index) { if (index <= outputParameterInfos.length) { return outputParameterInfos[index]; } return null; }
public void setInputParameter(int index, Object array) { inputs[index] = (double[]) array; }
public void setOutputParameter(int index, Object array) { switch (index) { case 0: outputs[index] = (double[]) array; break; case 1: outputs[index] = (double[]) array; break; default: throw new ArrayIndexOutOfBoundsException(index); } }
public OptInputParameterInfo getOptInputParameterInfo(int index) { if (index <= optInputParameterInfos.length) { return optInputParameterInfos[index]; } return null; }
public void setOptInputParameter(int index, Object value) { switch (index) { case 0: timePeriod = (Integer) value; break; default: throw new ArrayIndexOutOfBoundsException(index); } }
}
|
|
|
|
 |
[bigdir]
|
Post subject: Re: Error: Unable to compile. Please restart platform. |
Post rating: 0
|
Posted: Mon 26 Oct, 2009, 14:14
|
|
User rating: 0
Joined: Wed 21 Oct, 2009, 04:47 Posts: 22
|
Hi there, I posted an example of my code here: viewtopic.php?f=1&t=1400I created a new topic as the code relates to using Java Native Access libraries. I am not entirely sure whether this is the cause of the problem I mention here. However if there is a solution to this, then I'm sure it would assist others with questions about native access. I will continue to see if I can see a pattern to what I am doing and what could be causing the lock-ups. Thanks.
|
|
|
|
 |
[bigdir]
|
Post subject: Re: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Tue 27 Oct, 2009, 09:13
|
|
User rating: 0
Joined: Wed 21 Oct, 2009, 04:47 Posts: 22
|
Still trying to solve this Java Native issue - I cannot figure the origins of the NullPointer exception. I have tried to catch the exception and print out a full stack trace to file however I cannot seem to capture it. Is this usual or does this mean there is an internal error somewhere? You should be able to reproduce the problem simply by trying to .loadLibrary("kernel32") under Windows and then calling CLibrary.INSTANCE.
If I can't use JNA, then the next option is JNI but if I spend the time to develop lots of C++ stubs, there's no guarantee this will work either...
Appreciate your help.
|
|
|
|
 |
[bigdir]
|
Post subject: Compile crash |
Post rating: 0
|
Posted: Thu 19 Nov, 2009, 02:23
|
|
User rating: 0
Joined: Wed 21 Oct, 2009, 04:47 Posts: 22
|
Hi guys - any joy with reproducing this problem?
I wanted to change this to a separate thread as the problem doesn't relate to JNA. It seems that this happens mainly when I am compiling an indicator (I don't recall it happening at all (or as much) when I've compiled a strategy). There is nothing special about the indicator - quite vanilla. Perhaps during the course of developing I've had a few exceptions raised while referring to arrays out-of-bounds, but that in theory shouldn't cause any problem.
Same symptoms as before - after around 30 compiles, my machine completely freezes but doesn't reset - the screen still has the last impression of what was there. It's not hardware related. The mouse cursor responds, but nothing else within the operating system (no icons are blinking, no screens are being updated, no servers/services are responsive).
If I manage to, I will see if I can see whether the 'Messages' tab is saying anything before the crash - usually there are only two messages - 'Compiling...' and 'OK'. Perhaps if it stops between the two you can isolate the code in question.
I am also happy to run a debug version of it for you that prints out messages to hone in on the problem. I think I can reproduce the problem pretty easily simply by repeatedly compiling.
I'm keen to solve the problem as I work remotely and a crash means that I cannot do anything until I physically go back to the box and do a hard reset. Obviously the implications of crashing a trading machine is quite high as well.
Let me help get this one solved!
Thanks!
|
|
|
|
 |
API Support
|
Post subject: Re: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Tue 24 Nov, 2009, 16:23
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
The next JForex platform build will support lite DLL support instead of JNI. package jforex.converted;
import java.awt.Color; import com.dukascopy.api.*; import com.dukascopy.api.connector.*;
public class mlotstest extends ConnectorStrategy { // -------------------------------------------------------------- // start import declaration // -------------------------------------------------------------- @DllClass public interface User32 { @DllMethod int MessageBox(int hwnd, String text, String caption, int flags ); }
// -------------------------------------------------------------- // end import declaration // --------------------------------------------------------------
// +------------------------------------------------------------------+ // | expert initialization function | // +------------------------------------------------------------------+ protected int init() { // ------------ // NLink usage // ------------ User32 user32 = NLink.create(User32.class); user32.MessageBox(0,"Hello JForex Strategy","Test string from JForex Strategy",4|0x20);
// ---- return (0); }
// +------------------------------------------------------------------+ // | expert deinitialization function | // +------------------------------------------------------------------+ protected int deinit() { // ----
// ---- return (0); }
// +------------------------------------------------------------------+ // | expert start function | // +------------------------------------------------------------------+ protected int start() {
return (0); }
// +------------------------------------------------------------------+
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { }/**/ }
|
|
|
|
 |
[brisully]
|
Post subject: Re: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Fri 01 Apr, 2011, 07:26
|
|
User rating: 0
Joined: Fri 04 Mar, 2011, 02:36 Posts: 1
|
I want to call functions from DLLs within a JForex strategy, and if you've created a special method to do this instead of JNI, I want to use it. I pasted the above code into a new strategy, and it compiles and runs, but nothing seems to happen except the below messages: 05:22:31 Strategy "mlotstest" is stopped at 2011-04-01 05:22:31.839 GMT on the local computer with parameters "Chart"=[EUR/USD, 1 Min], "Instrument"=[EUR/USD], "Period"=[1 Min] 05:22:31 Stopping "mlotstest" strategy at 2011-04-01 05:22:31.838 GMT on the local computer 05:22:31 Strategy "mlotstest" is started at 2011-04-01 05:22:31.727 GMT on the local computer with parameters "Chart"=[EUR/USD, 1 Min], "Instrument"=[EUR/USD], "Period"=[1 Min] 05:22:31 Starting "mlotstest" strategy at 2011-04-01 05:22:31.722 GMT on the local computer I tried to use a new DLL, in this case, one called exchng.dll (from https://www.mql5.com/en/articles/19), and altered the above code as follows: package jforex.converted;
import java.awt.Color; import com.dukascopy.api.*; import com.dukascopy.api.connector.*;
public class X1 extends ConnectorStrategy { // -------------------------------------------------------------- // start import declaration // -------------------------------------------------------------- @DllClass public interface Exchng { @DllMethod double GetValue(int pointer,int i); //void SetValue(int pointer,int i,double value); }
// -------------------------------------------------------------- // end import declaration // --------------------------------------------------------------
// +------------------------------------------------------------------+ // | expert initialization function | // +------------------------------------------------------------------+ protected int init() { // ------------ // NLink usage // ------------ Exchng exchng = NLink.create(exchng.class); exchng.GetValue(119825896, 5); //119825896 is a pointer value for an array from a running MT4 EA, and 5 is the array index. //I want to display this value and use it in other ways, but first I wanted to see if the program would compile and run // ---- return (0); }
// +------------------------------------------------------------------+ // | expert deinitialization function | // +------------------------------------------------------------------+ protected int deinit() { // ----
// ---- return (0); }
// +------------------------------------------------------------------+ // | expert start function | // +------------------------------------------------------------------+ protected int start() {
return (0); }
// +------------------------------------------------------------------+
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { }/**/ } The code doesn't compile, instead giving me the following errors: 05:29:23 ---------- 05:29:23 exchng cannot be resolved to a type 05:29:23 ^^^^^^ 05:29:23 Exchng exchng = NLink.create(exchng.class); 05:29:23 2. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\X1.java (at line 29) 05:29:23 ---------- 05:29:23 The method create(Class<exchng>) from the type NLink refers to the missing type exchng 05:29:23 ^^^^^^ 05:29:23 Exchng exchng = NLink.create(exchng.class); 05:29:23 1. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\X1.java (at line 29) 05:29:23 ---------- 05:29:22 Compiling X1.java Where do I put the file exchng.dll in the file system? "/JForex/Strategies/"? "/JForex/Strategies/files"? Neither of these seem to work. Thank you for your help, Brian
|
|
|
|
 |
[sparkz]
|
Post subject: Re: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Fri 13 May, 2011, 01:57
|
|
User rating: 0
Joined: Thu 27 Aug, 2009, 12:09 Posts: 23
|
Does JForex have this "lite DLL" support yet? Also, as brisully says, I tried the example which compiles ok but does nothing. Just starts and stops. No other messages. Is the code incorrect? Has anyone got any examples on how to call DLLs successfully from jforex? Thanks Support wrote: The next JForex platform build will support lite DLL support instead of JNI.
|
|
|
|
 |
API Support
|
Post subject: Re: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Tue 21 Jun, 2011, 12:42
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
[sparkz] wrote: Does JForex have this "lite DLL" support yet? It is supported with the latest release, try the mlotstest example from the previous Support's post.
|
|
|
|
 |
API Support
|
Post subject: Re: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Tue 21 Jun, 2011, 12:45
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
[brisully] wrote: 05:29:23 ---------- 05:29:23 exchng cannot be resolved to a type 05:29:23 ^^^^^^ 05:29:23 Exchng exchng = NLink.create(exchng.class); 05:29:23 2. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\X1.java (at line 29) 05:29:23 ---------- 05:29:23 The method create(Class<exchng>) from the type NLink refers to the missing type exchng 05:29:23 ^^^^^^ 05:29:23 Exchng exchng = NLink.create(exchng.class); 05:29:23 1. ERROR in C:\Users\ADMINI~1\AppData\Local\Temp\2\jfxide\tmp\X1.java (at line 29) 05:29:23 ---------- 05:29:22 Compiling X1.java
replace Exchng exchng = NLink.create(Exchng.class); with Exchng exchng = NLink.create(Exchng.class);
|
|
|
|
 |
sparkz2
|
Post subject: Re: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Tue 28 Jun, 2011, 05:21
|
|
User rating: 0
Joined: Tue 28 Jun, 2011, 04:15 Posts: 2 Location: GB
|
I tried that and it doesn't do anything? It runs but no popup messages. This is on a demo account with API 2.6.38 (according to the help/about). Does this not work on a demo account? Thanks Support wrote: It is supported with the latest release, try the mlotstest example from the previous Support's post.
|
|
|
|
 |
API Support
|
Post subject: Re: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Tue 28 Jun, 2011, 08:38
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Please be advised that the latest release has been rollbacked, follow the release information here: viewforum.php?f=71
|
|
|
|
 |
sparkz2
|
Post subject: Re: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Wed 29 Jun, 2011, 13:06
|
|
User rating: 0
Joined: Tue 28 Jun, 2011, 04:15 Posts: 2 Location: GB
|
Ok thanks. Will it work on a live account then?
Mark
|
|
|
|
 |
API Support
|
Post subject: Re: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Wed 29 Jun, 2011, 14:32
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
sparkz2 wrote: Will it work on a live account then? LIVE release will follow after the stabilization of DEMO release.
|
|
|
|
 |
syedrizwanm
|
Post subject: Re: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Fri 16 Sep, 2011, 09:41
|
|
User rating: 0
Joined: Wed 13 Jul, 2011, 09:06 Posts: 8 Location: Australia, Quakers Hill
|
Hi Support,
I am also getting this error:
16.09.2011 17:54:27.360 SEVERE a.c ] Uncaught exception in [common-1-thread-3] thread: null java.lang.ExceptionInInitializerError at com.dukascopy.api.nlink.Wrapper.<init>(Wrapper.java:33) at com.dukascopy.api.NLink.create(NLink.java:66) at com.dukascopy.api.NLink.create(NLink.java:27) at jforex.converted.YDAM1Strategy_dukas.<init>(YDAM1Strategy_dukas.java:7) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at com.dukascopy.dds2.greed.agent.a.f.getTarget(Unknown Source) at com.dukascopy.api.impl.ag.e(Unknown Source) at com.dukascopy.dds2.greed.actions.StrategyTesterAction.uH(Unknown Source) at com.dukascopy.dds2.greed.actions.StrategyTesterAction.uh(Unknown Source) at com.dukascopy.dds2.greed.actions.c.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission java.io.tmpdir read) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPropertyAccess(Unknown Source) at java.lang.System.getProperty(Unknown Source) at com.dukascopy.api.nlink.Native.extract(Native.java:84) at com.dukascopy.api.nlink.Native.loadNativeLibrary(Native.java:74) at com.dukascopy.api.nlink.Native.<clinit>(Native.java:33) ... 18 more
Can you please advise what do I need to do to fix this? I am using this on the live account. Moreoever, if it's not supported then is there an alternate available to the use of external DLLs?
Regards, Riz
|
|
|
|
 |
API Support
|
Post subject: Re: Access native libraries (via JNA) |
Post rating: 0
|
Posted: Mon 19 Sep, 2011, 07:35
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
syedrizwanm wrote: Can you please advise what do I need to do to fix this? I am using this on the live account. The functionality will be supported with the next release of JForex DEMO client. And as mentioned before - LIVE release will follow after the stabilization of DEMO release. syedrizwanm wrote: Moreoever, if it's not supported then is there an alternate available to the use of external DLLs? JForex API supports jar include libraries: https://www.dukascopy.com/wiki/index.php ... _librariesSo what you might consider, is wrapping the dll within a jar file and then forward the function calls to the dll.
|
|
|
|
 |
|
Pages: [
1, 2
»
]
|
|
|
|
|