GVKun编程网logo

Java FTPSClient-SSL对等错误关闭-间歇性错误(java ftp server)

1

在本文中,我们将详细介绍JavaFTPSClient-SSL对等错误关闭-间歇性错误的各个方面,并为您提供关于javaftpserver的相关解答,同时,我们也将为您带来关于'java.lang.No

在本文中,我们将详细介绍Java FTPSClient-SSL对等错误关闭-间歇性错误的各个方面,并为您提供关于java ftp server的相关解答,同时,我们也将为您带来关于'java.lang.NoClassDefFoundError 由 java.lang.ClassNotFoundException 引起的 Ljava/util/Base64 解析失败 未找到类“java.util.Base64”、(Java 学习笔记) Java Threading (Java 线程)、Android 应用程序开发支持哪些 Java 版本我可以使用 1.8 以上的 java 版本还是 java 8、Android:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法“ java.lang.String java.lang.Object.toString()”的有用知识。

本文目录一览:

Java FTPSClient-SSL对等错误关闭-间歇性错误(java ftp server)

Java FTPSClient-SSL对等错误关闭-间歇性错误(java ftp server)

如何解决Java FTPSClient-SSL对等错误关闭-间歇性错误?

我正在尝试使用Apache FTPSClient库传输文件。这是2个单独的程序,用于连接和发送文件。有时从两个客户端成功进行文件传输,有时1个程序失败,有时都失败。 我已经用相同的错误遍历了线程。我无法确定发生这种情况的确切原因。 对使用相同端口号连接到同一FTP站点的2个客户端有什么限制?如果是,有时它是如何工作的。请提示。调用connect()时引发错误。

堆栈跟踪:

javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:944)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1323)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1350)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1334)
    at org.apache.commons.net.ftp.FTPSClient.sslNegotiation(FTPSClient.java:269)
    at org.apache.commons.net.ftp.FTPSClient._connectAction_(FTPSClient.java:205)
    at org.apache.commons.net.socketClient.connect(SocketClient.java:176)
    at org.apache.commons.net.socketClient.connect(SocketClient.java:196)
Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:462)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:925)
    ... 11 more
public void publish(FtpConnection conn,File[] files) throws FTPException
{
    FTPSClient ftp = null;
    String protocol = "TLS"; // TLS / null (SSL)
    int port = 990;
    int timeoutInMillis = 10000;
    boolean isImpicit = true;
    try {
        ftp = new FTPSClient(protocol,isImpicit);
        ftp.setDataTimeout(timeoutInMillis);
        LOG.info("Before calling connect");
        ftp.connect(conn.getHost(),port);
        LOG.info("FTP connect successful");
        ftp.enterLocalPassiveMode();
        ftp.login(conn.getUsername(),conn.getpassword());
        LOG.info("FTP login successful");
        ftp.execPBSZ(0);
        ftp.execPROT("P");
        ftp.setFileType(FTP.BINARY_FILE_TYPE);
        for (File file : files) {
            publish(ftp,conn.getDirectory(),file);
        }
    }
    catch (Exception e)
    {   
        LOG.error("Failed to FTP.",e);
        throw new FTPException("Failed to FTP message.",e);
    }
    finally
    {
        close(ftp);
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

'java.lang.NoClassDefFoundError 由 java.lang.ClassNotFoundException 引起的 Ljava/util/Base64 解析失败 未找到类“java.util.Base64”

'java.lang.NoClassDefFoundError 由 java.lang.ClassNotFoundException 引起的 Ljava/util/Base64 解析失败 未找到类“java.util.Base64”

如何解决''java.lang.NoClassDefFoundError 由 java.lang.ClassNotFoundException 引起的 Ljava/util/Base64 解析失败 未找到类“java.util.Base64”?

我收到此错误,我已阅读该错误以解决它我必须将 import java.util.Base64 替换为 import android.util.Base64 但在我的整个项目中我只发现 Base68 result = Base64.getEncoder().encodetoString(macData); 的唯一用法 我该如何解决?而且我不能用 android.util.Base.64 替换 java.util.Base64 因为这行代码在后端

解决方法

这很不幸 - 这意味着您正在使用某个库,而那个库正在尝试使用 /i。 Android 选择了 Java 库,就像 android 发布时一样,现在已经是很久以前的事了。从那以后它们就没有真正更新过。 (那个 oracle v google 法庭案件可能没有帮助……)

java.util.Base64 已添加到 https://forge.autodesk.com/en/docs/design-automation/v3/reference/cmdLine/cmdLine-inventor/(有关此信息,请参阅 javadoc 中的“since”行;任何“1.6”或以下,或者如果没有“since”行,肯定可用在 android 上。其他东西通常不是)。 java 8 现在已经 7 岁了,因此不是专门为 android 设计的库越来越有可能开始使用这些非 android 库调用。

检查堆栈跟踪,您会找到正在执行此操作的库。恐怕除了停止使用这个库之外别无他法。您可以尝试在您的应用程序中粘贴 juBase64 impl,但这会相对棘手,因为这可能涉及一些法律问题,因此,要么没有人这样做,要么如果他们这样做,他们可能不会宣传如何。

您可以要求这个库使用第三方库来做 base64 工作,但他们可能不想这样做,这可能不是库无法在 android 上运行的唯一问题。

如果 android 变体是一个替代品,你可以重写这个库的类文件,但这也是一个有点笨拙、笨拙的概念,并不完全困难,但因为这不是一件正常的事情,而且通常积极不喜欢,我认为您无法轻松找到有关如何操作的文档。

因此,建议:尝试寻找另一个图书馆。

(Java 学习笔记) Java Threading (Java 线程)

(Java 学习笔记) Java Threading (Java 线程)

Java Threading (Java 线程)

● Process & Thread

Processes are the abstraction of running programs: A binary image, virtualized memory, various kernel resources, an associated security context, and so on.

Threads are the unit of execution in a process: A virtualized processor, a stack, and program state.

 

Threads are sometimes called lightweight processes. Both processes and threads provide an execution environment, but creating a new thread requires fewer resources than creating a new process.

Threads exist within a process — every process has at least one. Threads share the process''s resources, including memory and open files. This makes for efficient, but potentially problematic, communication.

 

Multithreaded execution is an essential feature of the Java platform. Every application has at least one thread — or several, if you count "system" threads that do things like memory management and signal handling. But from the application programmer''s point of view, you start with just one thread, called the main thread. This thread has the ability to create additional threads, as we''ll demonstrate in the next section.

 

● Processes

--Will by default not share memory

--Most file descriptors not shared

--Don''t share filesystem context

--Don''t share signal handling

 

● Threads

--Will by default share memory

--Will share file descriptors

--Will share filesystem context

--Will share signal handling

 

● Thread pool

Thread pool represents a group of worker threads that are waiting for the job and reuse many times,

 

● Thread life cycle & states

 

 

Android 应用程序开发支持哪些 Java 版本我可以使用 1.8 以上的 java 版本还是 java 8

Android 应用程序开发支持哪些 Java 版本我可以使用 1.8 以上的 java 版本还是 java 8

如何解决Android 应用程序开发支持哪些 Java 版本我可以使用 1.8 以上的 java 版本还是 java 8?

我在这里可以用于 Android 应用程序开发的最大版本是多少。 我正在开发一个 Android 库,我想知道我是否设置了我的库 build.gradle

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

它将与 Android 应用程序中定义的所有先前和更高版本的 Java 版本兼容吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

Android:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法“ java.lang.String java.lang.Object.toString()”

Android:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法“ java.lang.String java.lang.Object.toString()”

面对我正在使用的练习应用程序的问题。我面临与toString方法有关的NullPointerException问题。作为android应用程序开发的新手,即使经过研究,我也不确定确切的原因。因此,我要求一个更熟悉堆栈跟踪的人来帮助我。

注意:当我单击列表视图条目以访问日记条目的编辑页面时,将发生错误。但是,它似乎根本没有进入编辑页面。

在下面,您将找到我的活动代码及其堆栈跟踪。

活动代码:

import android.app.AlertDialog;import android.content.DialogInterface;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.content.Intent;import android.widget.AdapterView;import android.widget.ArrayAdapter;import android.widget.EditText;import android.widget.ListView;import android.widget.TextView;import android.widget.Toast;import java.util.ArrayList;public class ViewDiaryEntries extends AppCompatActivity {// Database HelperMyDBHandler db;// ListviewListView data_list;// Test varpublic final static String KEY_EXTRA_DATA_ID = "KEY_EXTRA_DATA_ID";@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_view_diary_entries);    db = new MyDBHandler(this);    // Displays the database items.    displayItems();}// To display items in the listview.public void displayItems(){    // To display items in a listview.    ArrayList db_data_list = db.getDiaryDBDataList();    ArrayAdapter listAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, db_data_list);    // Set the adapter for the listview    data_list = (ListView) findViewById(R.id.dataListView);    data_list.setAdapter(listAdapter);    /* Experiment -------------------------------------------------------------*/    data_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {        @Override        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {            // Selected item store            String selectedEntry = ((TextView) view).getText().toString();            // Test for regular expression            String[] listViewItemSplit = selectedEntry.split(" - ");            String listViewItempt1 = listViewItemSplit[0]; // For date and time            //String listViewItempt2 = listViewItemSplit[1]; // For save file name            //Toast.makeText(ViewDiaryEntries.this, listViewItempt1, Toast.LENGTH_LONG).show();            if(listViewItempt1.equals("")){                Toast.makeText(ViewDiaryEntries.this, "Error. Unable to detect entry ID.", Toast.LENGTH_LONG).show();            }            else{                // Pass on the data:                Intent editEntry = new Intent(ViewDiaryEntries.this, editdiaryentry.class);                editEntry.putExtra(KEY_EXTRA_DATA_ID, listViewItempt1);                startActivity(editEntry);            }        }    });}// For the go back button.public void viewdiarytoinitialdiary_backbutt(View v){    // Create and start new intent going back ot main page.    Intent main_page = new Intent(ViewDiaryEntries.this, User_Main_Menu_Options.class);    main_page.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);    startActivity(main_page);}// For the about button.public void viewdiarypage_directionabout_butt(View v){    // Create an alert dialog    final AlertDialog.Builder about_page_dialog = new AlertDialog.Builder(ViewDiaryEntries.this);    about_page_dialog.setTitle("About This Page:");    // Inputs values for the dialog message.    final String dialog_message = "This page will show you any saved diary entries you''ve.\n\n To edit an entry, do the following: \n\n- Take note of the Entry ID# (first value on entry display) \n- Type it in the number box at the bottom. \n- Press Edit Record icon next to number box, and wait for it to load.";    about_page_dialog.setMessage(dialog_message);    about_page_dialog.setPositiveButton("Got it!", new DialogInterface.OnClickListener() {        @Override        public void onClick(DialogInterface dialog, int which) {            // Closes the dialog.            dialog.cancel();        }    });    // Shows the dialog.    about_page_dialog.show();}// Main menu button.public void viewDiaryEntriesMainMenushortcut_butt(View v){    // Creates main menu alert dialog.    AlertDialog.Builder mainMenu_Dialog = new AlertDialog.Builder(this);    mainMenu_Dialog.setIcon(R.drawable.main_menu_symbol);    mainMenu_Dialog.setTitle("Main Menu");    // Creates array adapter with items to fill the menu with.    final ArrayAdapter<String> menuItemsAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);    menuItemsAdapter.add("Home Screen");    menuItemsAdapter.add("Diary");    menuItemsAdapter.add("Tests");    menuItemsAdapter.add("Activity");    menuItemsAdapter.add("Media");    menuItemsAdapter.add("Thought of the Day");    menuItemsAdapter.add("Inspirational Quotes");    menuItemsAdapter.add("Resources");    menuItemsAdapter.add("Settings");    // To close menu.    mainMenu_Dialog.setPositiveButton("Cancel", new DialogInterface.OnClickListener() {        @Override        public void onClick(DialogInterface dialog, int which) {            dialog.cancel();        }    });    // To go to appropriate page upon selection.    mainMenu_Dialog.setAdapter(menuItemsAdapter, new DialogInterface.OnClickListener() {        @Override        public void onClick(DialogInterface dialog, int which) {            String selectedItem = menuItemsAdapter.getItem(which);            if(selectedItem.equals("Home Screen")){                // Goes to main menu.                Intent mainMenu = new Intent(ViewDiaryEntries.this, User_Main_Menu_Options.class);                mainMenu.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);                startActivity(mainMenu);            }            else if(selectedItem.equals("Diary")){                // Goes to diary page.                Intent diaryPage = new Intent(ViewDiaryEntries.this, ViewDiaryEntries.class);                diaryPage.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);                startActivity(diaryPage);            }            else if(selectedItem.equals("Tests")){                // Goes to tests page.                Intent testsPage = new Intent(ViewDiaryEntries.this, TestChoices.class);                testsPage.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);                startActivity(testsPage);            }            else if(selectedItem.equals("Media")){                // Goes to media page.                Intent mediaPage = new Intent(ViewDiaryEntries.this, initialMediaPage.class);                mediaPage.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);                startActivity(mediaPage);            }            else if(selectedItem.equals("Thought of the Day")){                // Goes to thought of the day page.                Intent thoughtofthedayPage = new Intent(ViewDiaryEntries.this, thoughtQuotes.class);                thoughtofthedayPage.putExtra("quote_or_thought", 2);                thoughtofthedayPage.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);                startActivity(thoughtofthedayPage);            }            else if(selectedItem.equals("Inspirational Quotes")){                // Goes to inspirational quotes page.                Intent inspirationalquotesPage = new Intent(ViewDiaryEntries.this, thoughtQuotes.class);                inspirationalquotesPage.putExtra("quote_or_thought", 1);                inspirationalquotesPage.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);                startActivity(inspirationalquotesPage);            }            else if(selectedItem.equals("Settings")){                // Goes to settings page.                Intent settingsPage = new Intent(ViewDiaryEntries.this, settings.class);                settingsPage.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);                startActivity(settingsPage);            }        }    });    mainMenu_Dialog.show();}// For the settings button.public void viewdiarypagelisttoSettings_butt(View v){    // Goes to settings page.    Intent settingsPage = new Intent(ViewDiaryEntries.this, settings.class);    settingsPage.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);    startActivity(settingsPage);}// For new entry.public void viewdiarypageaddEntry_butt(View v){    // Opening up the diary add intent.    Intent newdiaryEntry = new Intent(ViewDiaryEntries.this, newdiaryentry.class);    startActivity(newdiaryEntry);}}

这是我看到的堆栈跟踪:

java.lang.NullPointerException: Attempt to invoke virtual method ''java.lang.String java.lang.Object.toString()'' on a null object reference        at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:401)        at android.widget.ArrayAdapter.getView(ArrayAdapter.java:369)        at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:194)        at android.widget.Spinner.onMeasure(Spinner.java:580)        at android.support.v7.widget.AppCompatSpinner.onMeasure(AppCompatSpinner.java:407)        at android.view.View.measure(View.java:18794)        at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)        at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)        at android.view.View.measure(View.java:18794)        at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1283)        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)        at android.widget.ScrollView.onMeasure(ScrollView.java:340)        at android.view.View.measure(View.java:18794)        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)        at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)        at android.view.View.measure(View.java:18794)        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)        at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)        at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)        at android.view.View.measure(View.java:18794)        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)        at android.view.View.measure(View.java:18794)        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)        at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)        at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)        at android.view.View.measure(View.java:18794)        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)        at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)        at android.view.View.measure(View.java:18794)        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)        at android.view.Choreographer.doCallbacks(Choreographer.java:670)        at android.view.Choreographer.doFrame(Choreographer.java:606)        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)        at android.os.Handler.handleCallback(Handler.java:739)        at android.os.Handler.dispatchMessage(Handler.java:95)        at android.os.Looper.loop(Looper.java:148)        at android.app.ActivityThread.main(ActivityThread.java:5417)        at java.lang.reflect.Method.invoke(Native Method)        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

任何对解决方案的帮助将不胜感激。

编辑:

因此,在从数据库和与之交互的活动之间的代码来回浏览之后,我设法使其重新工作。以下是我按确切顺序执行的操作:

  1. 我意识到我有一个日期字段没有接收任何数据,对此进行了纠正。
  2. 清理了项目。
  3. 重新启动Android Studio(基本上停止开发环境的所有操作)。
  4. 从我的开发手机上卸载了该应用。
  5. 重新启动android studio并重新安装该应用程序。
  6. 我以某种方式工作= _ =,是的,这很神奇。

老实说,我不知道哪一步真正解决了它。我猜这是数据库中的日期字段在我没有收到任何数据的同时给我带来了麻烦。

答案1

小编典典

您的阵列中ArrayAdapter至少包含一个条目null。那里不能有空值。

数组被填充,getDiaryDBDataList()所以问题也在那里。

我们今天的关于Java FTPSClient-SSL对等错误关闭-间歇性错误java ftp server的分享就到这里,谢谢您的阅读,如果想了解更多关于'java.lang.NoClassDefFoundError 由 java.lang.ClassNotFoundException 引起的 Ljava/util/Base64 解析失败 未找到类“java.util.Base64”、(Java 学习笔记) Java Threading (Java 线程)、Android 应用程序开发支持哪些 Java 版本我可以使用 1.8 以上的 java 版本还是 java 8、Android:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法“ java.lang.String java.lang.Object.toString()”的相关信息,可以在本站进行搜索。

本文标签: