Hi All,
I've been putting together a simple sketch to filter tweets by location and return the user profile images. These forums have been very helpful. No problems with the sketch in processing, however, I am getting an error message when I try to run the exported applet.
I have signed the .jar files per instructions at this link:
When running the applet index.html I receive this error in the java console:
- Exception in thread "Animation Thread" java.lang.AssertionError: java.lang.reflect.InvocationTargetException
- at twitter4j.TwitterFactory.<clinit>(TwitterFactory.java:76)
- at test4.setup(test4.java:78)
- at processing.core.PApplet.handleDraw(Unknown Source)
- at processing.core.PApplet.run(Unknown Source)
- at java.lang.Thread.run(Unknown Source)
- Caused by: java.lang.reflect.InvocationTargetException
- 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 twitter4j.TwitterFactory.<clinit>(TwitterFactory.java:70)
- ... 4 more
- Caused by: java.lang.ExceptionInInitializerError
- at twitter4j.internal.http.HttpClientWrapper.<init>(HttpClientWrapper.java:48)
- at twitter4j.TwitterBaseImpl.init(TwitterBaseImpl.java:86)
- at twitter4j.TwitterBaseImpl.<init>(TwitterBaseImpl.java:65)
- at twitter4j.TwitterImpl.<init>(TwitterImpl.java:50)
- ... 9 more
- Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission twitter4j.http.httpClient 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 twitter4j.internal.http.HttpClientFactory.<clinit>(HttpClientFactory.java:33)
- ... 13 more
And lastly, here's my code out of processing. Many thanks for any help.
- import twitter4j.conf.*;
- import twitter4j.internal.async.*;
- import twitter4j.internal.org.json.*;
- import twitter4j.internal.logging.*;
- import twitter4j.json.*;
- import twitter4j.internal.util.*;
- import twitter4j.management.*;
- import twitter4j.auth.*;
- import twitter4j.api.*;
- import twitter4j.util.*;
- import twitter4j.internal.http.*;
- import twitter4j.*;
- import twitter4j.internal.json.*;
- ArrayList<String> username = new ArrayList();
- ArrayList<String> imgs = new ArrayList();
- double lat;
- double lon;
- double res;
- String resUnit;
- PImage twitimg;
- void setup() {
- size(990, 480);
- background(255);
- smooth();
- noStroke();
- ConfigurationBuilder cb = new ConfigurationBuilder();
- cb.setOAuthConsumerKey("XXXXX");
- cb.setOAuthConsumerSecret("XXXXXXX");
- cb.setOAuthAccessToken("XXXXXXX ");
- cb.setOAuthAccessTokenSecret(" XXXXXXX ");
- lat = 40.7404;
- lon =74.0070;
- res = 1;
- resUnit="mi";
- try {
- Twitter twitter = new TwitterFactory(cb.build()).getInstance();
- Query query = new Query();
- GeoLocation nyc = new GeoLocation(lat, lon);
- query.setGeoCode(nyc, res, resUnit);
- query.setRpp(200);
- QueryResult result = twitter.search(query);
- ArrayList tweets = (ArrayList) result.getTweets();
- for (int i = 0; i < tweets.size(); i++) {
- Tweet t = (Tweet) tweets.get(i);
- String user = t.getFromUser();
- Long id = t.getFromUserId();
- String url = t.getProfileImageUrl();
- String msg = t.getText();
- Date d = t.getCreatedAt();
- username.add(user);
- imgs.add(url);
- };
- }
- catch (TwitterException te) {
- println("Couldn't connect: " + te);
- };
- }
- void draw() {
- int k = (frameCount % imgs.size());
- String pix = imgs.get(k);
- String users = username.get(k);
- PFont font;
- font = loadFont("FuturaLT-ExtraBoldOblique-18.vlw");
- fill(0);
- textFont(font);
- text(k + " " + users, 0, 35);
- fill(255, 200);
- rect(0, 0, 220, 45);
- twitimg = loadImage(pix, "png");
- image(twitimg, random(width), random(height));
- //text(users, twitimg.x, twitimg.y);
- fill(255, 1);
- rect(0, 0, width, height);
- fill(222, random(50, 150));
- textSize(random(10, 30));
- }
1