Skip to content
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

JRuby > 1.7.0 doesn't work with Oanda FXClient #1553

Closed
josacar opened this issue Mar 8, 2014 · 2 comments
Closed

JRuby > 1.7.0 doesn't work with Oanda FXClient #1553

josacar opened this issue Mar 8, 2014 · 2 comments
Milestone

Comments

@josacar
Copy link

josacar commented Mar 8, 2014

When using oanda fxclient Java libraries, an exception is thrown when getting EventManager from RateTable.

Using provided jar and this code:

require 'java'
require 'oanda_fxtrade_implementation.jar'

fxclient = com.oanda.fxtrade.api.API.createFXGame
fxclient.with_keep_alive_thread = true
fxclient.with_rate_thread = true
fxclient.login 'xxxxx', 'xxxx'
fxclient.rate_table.event_manager

The following exception is thrown:

Class.java:-2:in `getDeclaringClass': java.lang.IncompatibleClassChangeError: com.oanda.fxtrade.api.implementation.RateTable and com.oanda.fxtrade.api.implementation.RateTable$c disagree on InnerClasses attribute
    from Class.java:1123:in `getEnclosingClass'
    from Class.java:1267:in `getSimpleBinaryName'
    from Class.java:1159:in `getSimpleName'
    from JavaClass.java:743:in `setupProxy'
    from Java.java:574:in `createProxyClass'
    from Java.java:502:in `createProxyClassForClass'
    from JavaSupport.java:154:in `computeValue'
    from JavaSupport.java:151:in `computeValue'
    from MapBasedClassValue.java:18:in `get'
    from JavaSupport.java:207:in `getProxyClassFromCache'
    from Java.java:450:in `getProxyClass'
    from Java.java:389:in `getInstance'
    from Java.java:371:in `getInstance'
    from JavaUtil.java:167:in `convertJavaToUsableRubyObject'
    from JavaMethod.java:517:in `convertReturn'
    from JavaMethod.java:441:in `invokeDirectWithExceptionHandling'
    from JavaMethod.java:304:in `invokeDirect'
    from InstanceMethodInvoker.java:52:in `call'
    from AliasMethod.java:56:in `call'
    from CachingCallSite.java:306:in `cacheAndCall'
    from CachingCallSite.java:136:in `call'
    from a.rb:8:in `__file__'
    from a.rb:-1:in `load'
    from Ruby.java:811:in `runScript'
    from Ruby.java:804:in `runScript'
    from Ruby.java:673:in `runNormally'
    from Ruby.java:522:in `runFromMain'
    from Main.java:395:in `doRunFromMain'
    from Main.java:290:in `internalRun'
    from Main.java:217:in `run'
    from Main.java:197:in `main'

The equivalent Java code works as expected:

import com.oanda.fxtrade.api.API;
import com.oanda.fxtrade.api.FXClient;
import com.oanda.fxtrade.api.SessionDisconnectedException;
import com.oanda.fxtrade.api.InvalidUserException;
import com.oanda.fxtrade.api.InvalidPasswordException;
import com.oanda.fxtrade.api.SessionException;
import com.oanda.fxtrade.api.MultiFactorAuthenticationException;

class OandaRunner {
  public static void main (String args[]){
    try {
      FXClient fxclient = com.oanda.fxtrade.api.API.createFXGame();
      fxclient.setWithKeepAliveThread(true);
      fxclient.setWithRateThread(true);
      fxclient.login("xxx", "xxx");
      fxclient.getRateTable().getEventManager();
    } catch ( InvalidUserException iue ) {
    } catch ( SessionDisconnectedException sde ) {
    } catch ( InvalidPasswordException ipe ) {
    } catch ( SessionException se ) {
    } catch ( MultiFactorAuthenticationException mfae ) {
    }
  }
}

The client is working with Jruby 1.6.x series and 1.7.0. With >= 1.7.1 it breaks when calling event_manager.

Tested with OpenJDK 6 and Oracle JDK 7.

@BanzaiMan
Copy link
Member

I just tested it with 1.7.13 (the oldest release I have), 1.7.21, and master (@4fa224f), and they all work.

$ jruby -v -I. jruby-1553.rb
jruby 1.7.21 (1.9.3p551) 2015-07-07 a741a82 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_40-b25 +jit [darwin-x86_64]
API proxy version          : 2.6.2
API implementation jar     : http://dynamic-api.oanda.com/oanda_fxtrade_implementation.jar
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2015-07-26 01:09:41.556 -0400 I [main] Connection manager: using proxy=none for connection to fxserver02-cr.oanda.com on port=9700
2015-07-26 01:09:41.557 -0400 I [main] - connecting to fxserver02-cr.oanda.com/204.93.159.166: 9700
2015-07-26 01:09:42.102 -0400 I [main] sent seqid=0 /fxtrade/cr/LoginRequest at 1437887381 in 245 ms
2015-07-26 01:09:42.169 -0400 I [DispatcherThread] received seqid=0 /fxtrade/cr/LoginReply sendtime=1437887382 uniqueMsgId=CRgamecs01_175565382126388
2015-07-26 01:09:42.169 -0400 W [DispatcherThread] OFacade.read HEADER ERROR: errorId=CRgamecs01.chi.oanda.com1437887382138 on request=/fxtrade/cr/LoginRequest seqId=0 response=/fxtrade/cr/LoginReply
2015-07-26 01:09:42.177 -0400 I [DispatcherThread] OFacade.DispatcherThread.run: Stopping normally Socket closed
java/lang/reflect/Method.java:497:in `invoke': com.oanda.fxtrade.api.SessionDisconnectedException: Authentication failed: due to exception
        from jruby-1553.rb:7:in `(root)'
        from jruby-1553.rb:7:in `(root)'
Caused by:
null:-1:in `a': com.oanda.fxtrade.api.InvalidUserException: Authentication failed: Invalid username or password
        from null:-1:in `a'
        from null:-1:in `login'
        from null:-1:in `login'
        from null:-1:in `login'
        from null:-1:in `login'
        from NativeMethodAccessorImpl.java:-2:in `invoke0'
        from NativeMethodAccessorImpl.java:62:in `invoke'
        from DelegatingMethodAccessorImpl.java:43:in `invoke'
        from Method.java:497:in `invoke'
        from JavaMethod.java:471:in `invokeDirectWithExceptionHandling'
        from JavaMethod.java:329:in `invokeDirect'
        from InstanceMethodInvoker.java:56:in `call'
        from CachingCallSite.java:346:in `cacheAndCall'
        from CachingCallSite.java:204:in `call'
        from jruby-1553.rb:7:in `__file__'
        from jruby-1553.rb:-1:in `load'
        from Ruby.java:867:in `runScript'
        from Ruby.java:860:in `runScript'
        from Ruby.java:729:in `runNormally'
        from Ruby.java:578:in `runFromMain'
        from Main.java:395:in `doRunFromMain'
        from Main.java:290:in `internalRun'
        from Main.java:217:in `run'
        from Main.java:197:in `main'

IncompatibleClassChangeError usually means something broke binary compatibility on your machine. When I get it, I usually have had to recompile JRuby, but that may not be the issue for you (as I doubt you would be compiling JRuby from source).

@josacar
Copy link
Author

josacar commented Jul 26, 2015

With last jar works fine, closing this for now. Thanks!

@josacar josacar closed this as completed Jul 26, 2015
@enebo enebo added this to the JRuby 1.7.22 milestone Aug 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants