connection failed while connecting to OpenOffice .org

独自空忆成欢 提交于 2019-12-11 21:45:29

问题


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.");
            }
        }

It is giving an exception as

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)

What should I need to do .


回答1:


You should check on which address is listening OpenOffice and use that address. because it might not listening on localhost (127.0.0.1).

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



回答2:


The connection was refused. Without reading the documentation, I'm guessing OpenOffice is not listening on port 1234?



来源:https://stackoverflow.com/questions/19616742/connection-failed-while-connecting-to-openoffice-org

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!