install4j service start exception

744 views Asked by At

I created an new application iteration using install4j v5.1.15. The application starts a windows service after installation which has couple of steps to try and hit few URLs to get the updates or make sure some other configuration is available.

All I am getting is this below exception after installation is complete(used debugger mode). Is there any way I can configure the installer to give out more information(either point out which URL it is accessing), I have made sure that the all URLs added as present in the .install4j file are available.

What else can I try?

[INFO] com.install4j.runtime.beans.screens.BannerFormScreen [ID 1202]: Show screen
[INFO] com.install4j.runtime.beans.actions.control.RunScriptAction [ID 1203]: Execute action
Property script: I4jScript_Internal_97
Property rollbackSupported: false
Property rollbackScript: null
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at I4jScript_Internal_97$1.execute(I4jScript_Internal_97.java:68)
at com.install4j.runtime.installer.ContextImpl.runElevatedInt(Unknown Source)
at com.install4j.runtime.installer.ContextImpl.runElevated(Unknown Source)
at I4jScript_Internal_97.eval(I4jScript_Internal_97.java:34)
at I4jScript_Internal_97.evaluate(I4jScript_Internal_97.java:99)
at com.install4j.runtime.installer.helper.Script.evaluate(Unknown Source)
at com.install4j.runtime.installer.ContextImpl.runScript(Unknown Source)
at com.install4j.runtime.installer.ContextImpl.runScript(Unknown Source)
at com.install4j.runtime.beans.actions.control.RunScriptAction.execute(Unknown Source)
at com.install4j.runtime.beans.actions.SystemInstallOrUninstallAction.install(Unknown Source)
at com.install4j.runtime.installer.InstallerContextImpl$2.fetchValue(Unknown Source)
at com.install4j.runtime.installer.helper.comm.actions.FetchObjectAction.execute(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.executeActionDirect(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.executeActionInt(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.executeActionChecked(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.fetchObjectChecked(Unknown Source)
at com.install4j.runtime.installer.InstallerContextImpl.performActionIntStatic(Unknown Source)
at com.install4j.runtime.installer.InstallerContextImpl.performActionInt(Unknown Source)
at com.install4j.runtime.installer.ContextImpl.performAction(Unknown Source)
at com.install4j.runtime.installer.controller.Controller.executeActions(Unknown Source)
at com.install4j.runtime.installer.controller.Controller.handleCommand(Unknown Source)
at com.install4j.runtime.installer.controller.Controller.start(Unknown Source)
at com.install4j.runtime.installer.Installer.runInProcess(Unknown Source)
at com.install4j.runtime.installer.Installer.main(Unknown Source)

Edit-1: @Ingo Kegel Adding the script that I believe is failing:

//Get the "Click Finish to start..." label and update the text once the application is starting.
Screen otherScreen = context.getScreenById("1202");

FormEnvironment otherFormEnvironment = ((FormPanelContainer)otherScreen).getFormEnvironment();
FormComponent finishLabel = otherFormEnvironment.getFormComponentById("1207");

((JLabel)finishLabel.getConfigurationObject()).setText(context.getMessage("Please.Be.Patient.While.Application.Name.Is.Starting"));

//Start spinning the progress bar
context.getProgressInterface().setIndeterminateProgress(true);

//Get a handle on the port the user chose
final Long port = (Long)context.getVariable("user.specified.port");

//It's necessary to run this task elevated, otherwise install4j can have permissions issues and throw exceptions.
//See: http://blog.ej-technologies.com/2012/06/migrating-to-install4j-51.html
Boolean result = (Boolean)context.runElevated(new RemoteCallable() 
{
    public Serializable execute() 
    {
        int numRetries = 50;
        int retries = 0;

        java.net.URL url = null;

        try
        {
            url = new java.net.URL("http", "localhost", port.intValue(), "");
        }
        catch (java.net.MalformedURLException mue)
        {
            //If something goes wrong, return false.
            return false;
        } 

        while(retries < numRetries)
        {
            try
            {
                Thread.sleep(5000);
            }
            catch(InterruptedException ie)
            {
                return false;
            }

            try 
            {
                java.net.HttpURLConnection connection = (java.net.HttpURLConnection)url.openConnection();

                int responseCode = connection.getResponseCode(); 

                if (responseCode == java.net.HttpURLConnection.HTTP_OK) 
                {
                    return true;
                }
                else
                {     
                    retries++;
                }
            } 
            catch (Throwable t) 
            {
                t.printStackTrace();

                retries++;
            }
        }

        //We did not successfully find an application running on the port.
        return false;
    }
}, true);

context.getProgressInterface().setIndeterminateProgress(false);

return result;
1

There are 1 answers

0
Singhs On

Providing an update as the root cause was found to be unrelated to the install4j tool.

The jar I was using for packaging the installable was invalid. We had recently updated the maven plugin versions. The newer version changed the way our jar was packaged, which did not allow the service to start post the installation.

I am still receiving the same error as listed in the initial post, not sure of the source (I am ignoring that one for now).