Having Issues with the E*Trade OAuth API (Java)


I'm trying to code a program that will trade stocks in a sandbox environment with the E*Trade API. I am using their sample code as a guideline and currently am getting an issue with the .getAuthorizeURL() method. It says that it is undefined for type String however, after decompiling the OAuth jar I am stuck in a rut about how to solve this issue.

import com.etrade.etws.account.Account; import com.etrade.etws.account.AccountListResponse; import com.etrade.etws.oauth.sdk.client.IOAuthClient; import com.etrade.etws.oauth.sdk.client.OAuthClientImpl; import com.etrade.etws.oauth.sdk.common.Token; import com.etrade.etws.sdk.client.ClientRequest; import com.etrade.etws.sdk.client.Environment; import com.etrade.etws.sdk.common.ETWSException; import com.etrade.*; import java.awt.Desktop; import java.net.URI; import java.*; import java.io.IOException; public class OAuth { public static void main(String[] args) throws IOException, ETWSException { //Variables IOAuthClient client = null; ClientRequest request = null; Token token = null; String oauth_consumer_key = null; // Your consumer key String oauth_consumer_secret = null; // Your consumer secret String oauth_request_token = null; // Request token String oauth_request_token_secret = null; // Request token secret client = OAuthClientImpl.getInstance(); // Instantiate IOAUthClient request = new ClientRequest(); // Instantiate ClientRequest request.setEnv(Environment.SANDBOX); // Use sandbox environment request.setConsumerKey(oauth_consumer_key); //Set consumer key request.setConsumerSecret(oauth_consumer_secret); token = client.getRequestToken(request); // Get request-token object oauth_request_token = token.getToken(); // Get token string oauth_request_token_secret = token.getSecret(); // Get token secret } public String Verification(String client, ClientRequest request) { String authorizeURL = null; authorizeURL = client.getAuthorizeUrl(request); // E*TRADE authorization URL URI uri = new java.net.URI(authorizeURL); Desktop desktop = Desktop.getDesktop(); desktop.browse(uri); return authorizeURL; } }

Stack Trace

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger at com.etrade.etws.oauth.sdk.client.OAuthClientImpl.<init>(OAuthClientImpl.java:22) at com.etrade.etws.oauth.sdk.client.OAuthClientImpl.<clinit>(OAuthClientImpl.java:24) at OAuth.main(OAuth.java:29) Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 3 more


You need to configure your build path to include the Apache log4j logger (org/apache/log4j/Logger) in your external JARs. It's use is buried down in the ETRADE code.

What are you editing your code in? It should be easy to find instructions for your development environment. APACHE is free and you can download the JAR here: <a href="http://logging.apache.org/log4j/2.x/" rel="nofollow">http://logging.apache.org/log4j/2.x/</a>

Note the requirement from ETRADE (<a href="https://us.etrade.com/ctnt/dev-portal/getContent?contentUri=V0_Code-Tutorialhttps://us.etrade.com/ctnt/dev-portal/getContent?contentUri=V0_Code-Tutorial" rel="nofollow">https://us.etrade.com/ctnt/dev-portal/getContent?contentUri=V0_Code-Tutorialhttps://us.etrade.com/ctnt/dev-portal/getContent?contentUri=V0_Code-Tutorial</a>): Java SDK To proceed with this tutorial, you must first have completed the installation of the E*TRADE Java SDK, including:

•Java 1.6 or later installed

<strong>•3rd-party jars installed</strong>

•E*TRADE Java SDK libraries in your CLASSPATH

You can get instructions for all of the jars here <a href="https://us.etrade.com/ctnt/dev-portal/getContent?contentUri=V0_Code-SDKGuides-Java" rel="nofollow">https://us.etrade.com/ctnt/dev-portal/getContent?contentUri=V0_Code-SDKGuides-Java</a>

If you were using Eclipse IDE, for example, you can follow these instructions <a href="https://stackoverflow.com/questions/3280353/how-to-import-a-jar-in-eclipse/3280384#3280384" rel="nofollow">How to import a jar in Eclipse</a>


  • Quickbook Intergration Using PHP
  • Using Twitter login API
  • Convert curl command to pycurl
  • Generating Authentication Header
  • Getting Request Token From Dropbox OAuth “Invalid OAuth Request”
  • How to disable printing request information while using twitter4j
  • REST Web Service - Dynamic Query Parameters
  • how to set environment variables on google appengine?
  • WooCommerce REST Client API - Programmatically get consumer key and secret
  • Task processing status with a message queue
  • My Produce Consumer Hangs
  • ILMerge: Rename internalized assemblies' namespaces?
  • Success handler not working after Symfony2 login
  • Migration tool for ANTLR grammar
  • IDX10503: Signature validation failed
  • oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Invalid JWT
  • Syntax error near unexpected token 'elif'
  • PHP get selected value of select form
  • Mvc 3 posting content type application/json, action method arguments loose mapping?
  • retrieving data from url in iphone
  • How to apply a custom handlers to only specific folder
  • read values from form post in jquery or javascript
  • Google Maps api v3 get start and end coordinates of a street
  • HttpClient: disabling chunked encoding
  • How to get latest version of a artifact on Bintray using JSONP
  • IE11 throwing “SCRIPT1014: invalid character” where all other browsers work
  • How can I speed up CURL tasks?
  • Why querying a date BC is changed to AD in Java?
  • Bad request using file_get_contents for PUT request in PHP
  • Seeking advice on Jetty HttpClient Hang
  • ilmerge with a PFX file
  • Why value captured by reference in lambda is broken? [duplicate]
  • How would I use PHP exceptions to define a redirect?
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Symfony2: How to get request parameter
  • log4net write single file for each call to log.info
  • Getting error when using KSoap library to consume .NET web services
  • Why joiner is not used after Sequence generator or Update statergy
  • Recursive/Hierarchical Query Using Postgres
  • UserPrincipal.Current returns apppool on IIS