【问题标题】:connection failed while connecting to OpenOffice .org连接到 OpenOffice .org 时连接失败
【发布时间】:2013-10-27 18:07:01
【问题描述】:
File file = new File((new StringBuilder()).append(s2).append(File.separator).append(s1).toString());
        file.renameTo(new File((new StringBuilder()).append(s2).append(File.separator).append("$$tsjoof$$.xls").toString()));
      // SocketOpenOfficeConnection socketopenofficeconnection = new SocketOpenOfficeConnection();
         OpenOfficeConnection socketopenofficeconnection = new SocketOpenOfficeConnection(8100);

        try
        {
            String s3 = (new StringBuilder()).append(s2).append(File.separator).append("$$tsjoof$$.xls").append(".ods").toString();
            DefaultDocumentFormatRegistry defaultdocumentformatregistry = new DefaultDocumentFormatRegistry();
            File file4 = new File((new StringBuilder()).append(s2).append(File.separator).append("$$tsjoof$$.xls").toString());
            File file6 = new File(s3);
            socketopenofficeconnection.connect();
            if(socketopenofficeconnection.isConnected())
            {
                OpenOfficeDocumentConverter openofficedocumentconverter = new OpenOfficeDocumentConverter(socketopenofficeconnection);
                openofficedocumentconverter.convert(file4, defaultdocumentformatregistry.getFormatByFileExtension("xls"), file6, defaultdocumentformatregistry.getFormatByFileExtension("ods"));
            } else
            {
                File file7 = new File((new StringBuilder()).append(s2).append(File.separator).append("$$tsjoof$$.xls").toString());
                file7.renameTo(new File((new StringBuilder()).append(s2).append(File.separator).append(s1).toString()));
                throw new OpenOfficeConnectException("Unable to connect to OpenOffice.org to convert Excel Document.");
            }
        }

它给出了一个例外

connection failed: socket,host=localhost,port=1234,tcpNoDelay=1: java.net.ConnectException: Connection refused: connect
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at com.artofsolving.jodconverter.openoffice.connection.AbstractOpenOfficeConnection.disconnect(AbstractOpenOfficeConnection.java:88)
    at fileToXliff.ExcelImporter.convert(ExcelImporter.java:90)
    at fileToXliff.MainGui.jbtnConvertActionPerformed(MainGui.java:667)
    at fileToXliff.MainGui.access$800(MainGui.java:55)
    at fileToXliff.MainGui$9.actionPerformed(MainGui.java:179)

我需要做什么。

【问题讨论】:

    标签: java openoffice.org


    【解决方案1】:

    您应该检查哪个地址正在监听 OpenOffice 并使用该地址。因为它可能不会监听localhost (127.0.0.1)

    SocketOpenOfficeConnection connection = new SocketOpenOfficeConnection("192.168.0.1", 8100);
    

    【讨论】:

    • 还是同样的问题
    • 我不知道你代码的哪一部分是连接到localhost:1234。检查你的代码可能是你手动输入的端口参数1234。
    • 是OpenOfficeConnection socketopenofficeconnection = new SocketOpenOfficeConnection(1234);
    • 是的,但我已经添加了您的代码 SocketOpenOfficeConnection connection = new SocketOpenOfficeConnection("192.168.0.1", 8100);但它仍然在连接失败时给出异常:socket,host=192.168.0.1,port=8100,tcpNoDelay=1: java.net.ConnectException: Connection timed out: connect
    • 地址不是你的具体机器,你应该检查你的openoffice运行的接口并替换那个地址。
    【解决方案2】:

    连接被拒绝。没有阅读文档,我猜 OpenOffice 没有监听 1234 端口?

    【讨论】:

    • 有什么解决办法吗?
    • 文档说你应该做什么才能使用这个 API?您是否按照文档中的说明进行操作?
    猜你喜欢
    • 2018-07-07
    • 2015-04-03
    • 1970-01-01
    • 2014-02-26
    • 2012-11-21
    • 2020-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多