Linux特定错误IOException

时间:2017-03-20 20:47:31

标签: java linux spotify

所以我正在制作一个java应用程序,它可以从特定的Spotify用户获取所有公共播放列表,这一切都很棒,直到我托盘并在基于linux的机器上运行我的项目(raspbian java version 1.8)它在Windows上我获得了预期的输出但是当在linux上运行时我得到了

来自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)

这是包含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;
    }

}
&#13;
&#13;
&#13;

spotify.spotifyhttpManger.execute类看起来像这样

&#13;
&#13;
  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();
    }
  }
&#13;
&#13;
&#13;

我没有想法为什么我有这个错误,如何解决它的任何想法?

1 个答案:

答案 0 :(得分:0)

所以我没有弄清楚问题是什么,但后来我重新安装操作系统又恢复了工作