2017-03-20 3 views
0

so mache ich eine Java-Anwendung, die alle öffentlichen Wiedergabelisten von einem bestimmten Spotify-Benutzer erhalten kann, ist alles großartig und funktioniert, bis ich tray und mein Projekt auf einem Linux-basierten Rechner (Raspbian Java Version 1.8) ausführen ich laufe es auf windows i die erwartete Ausgabe erhalten, aber wenn auf linux lief ich erhalteLinux spezifische Fehler IOException

Fehlerprotokoll von linux

java.io.IOException 
at com.wrapper.spotify.SpotifyHttpManager.execute(SpotifyHttpManager.java:164) 
at com.wrapper.spotify.SpotifyHttpManager.post(SpotifyHttpManager.java:81) 
at com.wrapper.spotify.methods.AbstractRequest.postJson(AbstractRequest.java:38) 
at com.wrapper.spotify.methods.authentication.ClientCredentialsGrantRequest.getAsync(ClientCredentialsGrantRequest.java:30) 
at com.simon.spotify.Spotify.GetPublicPlayLists(Spotify.java:47) 
at com.simon.Main$10.start(Main.java:375) 
at com.simon.Main.getSpotifyPlayLists(Main.java:379) 
at com.simon.keyevent.selectionHandler(keyevent.java:77) 
at com.simon.keyevent.keyPressed(keyevent.java:52) 
at java.awt.AWTEventMulticaster.keyPressed(AWTEventMulticaster.java:250) 
at java.awt.Component.processKeyEvent(Component.java:6493) 
at javax.swing.JComponent.processKeyEvent(JComponent.java:2832) 
at java.awt.Component.processEvent(Component.java:6312) 
at java.awt.Container.processEvent(Container.java:2236) 
at java.awt.Component.dispatchEventImpl(Component.java:4891) 
at java.awt.Container.dispatchEventImpl(Container.java:2294) 
at java.awt.Component.dispatchEvent(Component.java:4713) 
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954) 
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806) 
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074) 
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945) 
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771) 
at java.awt.Component.dispatchEventImpl(Component.java:4762) 
at java.awt.Container.dispatchEventImpl(Container.java:2294) 
at java.awt.Window.dispatchEventImpl(Window.java:2750) 
at java.awt.Component.dispatchEvent(Component.java:4713) 
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) 
at java.awt.EventQueue.access$500(EventQueue.java:97) 
at java.awt.EventQueue$3.run(EventQueue.java:709) 
at java.awt.EventQueue$3.run(EventQueue.java:703) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) 
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) 
at java.awt.EventQueue$4.run(EventQueue.java:731) 
at java.awt.EventQueue$4.run(EventQueue.java:729) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) 
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) 
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) 
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) 
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) 
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) 
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) 
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) 

ist dies die Klassen Hexe enthält die getSpotifyPlayLists

public class Spotify { 
 
    public static String clientId = ""; // inser client public key 
 
    public static String clientSecret = ""; // insert client sercet key 
 
    public static String userid = "";// inser user name 
 
    public Spotify(String clientId,String clientSecret,String userid) { 
 
     this.clientId = clientId; 
 
     this.clientSecret = clientSecret; 
 
     this.userid = userid; 
 
    } 
 

 
    public static Api api; 
 

 
    public static void GetPublicPlayLists() { 
 
     
 
     System.out.println 
 
       (new Exception().getStackTrace()[0].getMethodName()); 
 
     ArrayList<String> data = new ArrayList<>(); 
 

 

 
     api = Api.builder() 
 
       .clientId(clientId) 
 
       .clientSecret(clientSecret) 
 
       .build(); 
 

 
/* Create a request object. */ 
 
     final ClientCredentialsGrantRequest request = api.clientCredentialsGrant().build(); 
 

 
/* Use the request object to make the request, either asynchronously (getAsync) or synchronously (get) */ 
 
     final SettableFuture<ClientCredentials> responseFuture = request.getAsync(); 
 

 
/* Add callbacks to handle success and failure */ 
 
     Futures.addCallback(responseFuture, new FutureCallback<ClientCredentials>() { 
 
      @Override 
 
      public void onSuccess(ClientCredentials clientCredentials) { 
 
    /* The tokens were retrieved successfully! */ 
 
       System.out.println("Successfully retrieved an access token! " + clientCredentials.getAccessToken()); 
 
       System.out.println("The access token expires in " + clientCredentials.getExpiresIn() + " seconds"); 
 

 
    /* Set access token on the Api object so that it's used going forward */ 
 
       api.setAccessToken(clientCredentials.getAccessToken()); 
 

 
    /* Please note that this flow does not return a refresh token. 
 
    * That's only for the Authorization code flow */ 
 

 
       final UserPlaylistsRequest request = api.getPlaylistsForUser(userid).build(); 
 

 
       try { 
 
        final Page<SimplePlaylist> playlistsPage = request.get(); 
 

 
        for (SimplePlaylist playlist : playlistsPage.getItems()) { 
 
         System.out.println(playlist.getName() + " : "+ playlist.getId() + " : "+ playlist.getUri() + " : track count ="+ playlist.getTracks().getTotal()); 
 

 
         /* item i = new item(); 
 
         i.title = playlist.getName(); 
 
         i.creator = playlist.getOwner().getId(); 
 
         i.uri = playlist.getId(); 
 
         data.add(i); 
 
         */ 
 
        } 
 
       } catch (Exception e) { 
 
        System.out.println("Something went wrong!" + e.getMessage()); 
 
       } 
 
      } 
 

 
      @Override 
 
      public void onFailure(Throwable throwable) { 
 
    /* An error occurred while getting the access token. This is probably caused by the client id or 
 
    * client secret is invalid. */ 
 
       System.out.println("Something went wrong! 2"); 
 
      throwable.printStackTrace(); 
 
      throwable.printStackTrace(System.out); 
 
      } 
 
     }); 
 
    return; 
 
    } 
 

 
}

die spotify.spotifyhttpManger.execute Klasse lookes wie diese

private String execute(HttpMethod method) throws WebApiException, IOException { 
 
    final HttpClient httpClient = new HttpClient(connectionManager); 
 
    try { 
 
     httpClient.executeMethod(method); 
 

 
     handleErrorStatusCode(method); 
 
     String responseBody = method.getResponseBodyAsString(); 
 

 
     handleErrorResponseBody(responseBody); 
 
     return responseBody; 
 

 
    } catch (IOException e) { 
 
     throw new IOException(); 
 
    } finally { 
 
     method.releaseConnection(); 
 
    } 
 
    }

ich keine idear haben, warum ich diesen Fehler Erz haben, wie es zu beheben atm keine idears?

Antwort

0

so konnte ich nicht herausfinden, was das Problem war, aber dann installiere ich das OS neu und es funktionierte wieder

Verwandte Themen