Install4j web应用程序作为服务自动更新,无需启动程序

Install4j web应用程序作为服务自动更新,无需启动程序,install4j,Install4j,如果应用程序是没有启动器的web应用程序作为服务,install4j中的自动更新功能是否有效?我尝试了很多在网络资源中提到的方法,但没有成功。请帮忙。我使用的是install4j Windows Edition 6.1.6 编辑1: @英戈·凯格尔, 根据您的建议,我添加了-Dinstall4j.keepLog=true-Dinstall4j.alternativeLogfile=E:/install4j log/log.txt,并获得了以下日志。请帮忙 [INFO] com.install4j

如果应用程序是没有启动器的web应用程序作为服务,install4j中的自动更新功能是否有效?我尝试了很多在网络资源中提到的方法,但没有成功。请帮忙。我使用的是install4j Windows Edition 6.1.6

编辑1: @英戈·凯格尔, 根据您的建议,我添加了
-Dinstall4j.keepLog=true-Dinstall4j.alternativeLogfile=E:/install4j log/log.txt
,并获得了以下日志。请帮忙

[INFO] com.install4j.runtime.beans.actions.control.SetVariableAction [ID 630]: Execute action
       Property script: com.install4j.script.I4jScript_Internal_38
       Property variableName: updateDescriptorEntry
       Property failIfNull: true
       Property onlyIfUndefined: false
       Property responseFileVariable: false
       Property rollbackSupported: false
[ERROR] com.install4j.runtime.beans.actions.control.SetVariableAction [ID 630]: Execute action not successful after 4 ms
编辑2: 下面是执行代码后的日志(下载exe文件后)
UpdateChecker.executeScheduledUpdate(Arrays.asList(“-q”),false,null)

日志:

 [INFO] com.install4j.runtime.beans.actions.update.CheckForUpdateAction [ID 629]: Execute action
   Property connectTimeout: 10000
   Property connectionFailureScript: null
   Property readTimeout: 20000
   Property requestHeaders: []
   Property url: http://localhost:8181/astra-downloads/updates.xml
   Property variable: updateDescriptor
   Property acceptAllCertificates: false
   Property askForProxy: true
   Property rollbackSupported: false
   Property showError: true
   Download: http://localhost:8181/astra-downloads/updates.xml to C:\WINDOWS\TEMP\i4jupd4650856858406689282.xml; size: 366 bytes
   Variable changed: updateDescriptor=com.install4j.runtime.installer.config.update.UpdateDescriptorImpl@82c94f[class com.install4j.runtime.installer.config.update.UpdateDescriptorImpl]
   Execute action successful after 44 ms
[INFO] com.install4j.runtime.beans.actions.control.SetVariableAction [ID 630]: Execute action
   Property script: com.install4j.script.I4jScript_Internal_63
   Property variableName: updateDescriptorEntry
   Property failIfNull: true
   Property onlyIfUndefined: false
   Property responseFileVariable: false
   Property rollbackSupported: false
   Branch 1
   3.0.1
   Variable changed: updateDescriptorEntry=UpdateDescriptorEntry [target: 22, file: GreytipAstra_windows_3_0_1.exe][class com.install4j.runtime.installer.config.update.UpdateDescriptorEntryImpl]
   Execute action successful after 4 ms
[INFO] com.install4j.runtime.beans.actions.control.SetVariableAction [ID 632]: Execute action
   Property script: com.install4j.script.I4jScript_Internal_65
   Property variableName: updaterNewVersion
   Property failIfNull: false
   Property onlyIfUndefined: false
   Property responseFileVariable: false
   Property rollbackSupported: false
   Variable changed: updaterNewVersion=3.0.1[class java.lang.String]
   Execute action successful after 0 ms
[INFO] com.install4j.runtime.beans.actions.control.SetVariableAction [ID 633]: Execute action
   Property script: com.install4j.script.I4jScript_Internal_66
   Property variableName: updaterDownloadUrl
   Property failIfNull: false
   Property onlyIfUndefined: false
   Property responseFileVariable: false
   Property rollbackSupported: false
   Variable changed: updaterDownloadUrl=http://localhost:8181/astra-downloads/GreytipAstra_windows_3_0_1.exe[class java.lang.String]
   Execute action successful after 0 ms
[INFO] com.install4j.runtime.beans.actions.control.SetVariableAction [ID 634]: Execute action
   Property script: com.install4j.script.I4jScript_Internal_67
   Property variableName: updaterDownloadFile
   Property failIfNull: false
   Property onlyIfUndefined: false
   Property responseFileVariable: false
   Property rollbackSupported: false
   Variable changed: updaterDownloadFile=C:/Users/Abhishek/Downloads\GreytipAstra_windows_3_0_1.exe[class java.lang.String]
   Execute action successful after 0 ms
[INFO] com.install4j.runtime.beans.actions.net.DownloadFileAction [ID 635]: Execute action
   Property connectTimeout: 10000
   Property connectionFailureScript: null
   Property md5Url: 
   Property readTimeout: 20000
   Property requestHeaders: []
   Property targetFile: C:\Users\Abhishek\Downloads\GreytipAstra_windows_3_0_1.exe
   Property url: http://localhost:8181/astra-downloads/GreytipAstra_windows_3_0_1.exe
   Property acceptAllCertificates: false
   Property askForProxy: true
   Property checkForMd5Sums: false
   Property deleteOnExit: false
   Property dontAskForRetry: false
   Property retryIfInterrupted: true
   Property rollbackSupported: false
   Property showError: true
   Property showFileName: true
   Property showProgress: true
   Download: http://localhost:8181/astra-downloads/GreytipAstra_windows_3_0_1.exe to C:\Users\Abhishek\Downloads\GreytipAstra_windows_3_0_1.exe; size: 43569152 bytes
   Execute action successful after 2640 ms
[INFO] com.install4j.runtime.beans.actions.files.SetModeAction [ID 637]: Execute action
   Property directoryFilter: null
   Property fileFilter: null
   Property fileTarget: everything
   Property files: [C:\Users\Abhishek\Downloads\GreytipAstra_windows_3_0_1.exe]
   Property filesRoot: null
   Property mode: 755
   Property recursive: false
   Property rollbackSupported: true
   Property showFileNames: true
   Property showProgress: false
   Execute action successful after 0 ms
[INFO] com.install4j.runtime.beans.actions.update.ScheduleUpdateAction [ID 638]: Execute action
   Property arguments: []
   Property installerFile: C:\Users\Abhishek\Downloads\GreytipAstra_windows_3_0_1.exe
   Property maxCancelCount: 10
   Property maxTries: 3
   Property version: 3.0.1
   Property rollbackSupported: false
   Execute action successful after 3 ms
[INFO] com.install4j.runtime.beans.screens.StartupScreen [ID 627]: command: move 1 screens, executing actions, checking condition
[INFO] cleaning up
[INFO] Finished
编辑3: 下面是UpdateChecker.executeScheduledUpdate的日志(Arrays.asList(“-q”、“-Dinstall4j.keepLog=true”、“-Dinstall4j.alternativeLogfile=E:/install4j log/log2.txt”)、false、null)

编辑4: 我的应用程序代码:

try {
        ApplicationLauncher.launchApplication("626", null, false, new ApplicationLauncher.Callback() {
                public void exited(int exitValue) {
                    //TODO add your code here (not invoked on event dispatch thread)
                    log.debug("******Exited "+exitValue+"********");
                    log.debug("****Inside block UpdateChecker.isUpdateScheduled() "+String.valueOf(UpdateChecker.isUpdateScheduled()));

                    boolean updateScheduled=UpdateChecker.isUpdateScheduled();


                    if(updateScheduled){
                        log.debug("***************Running UpdateChecker.executeScheduledUpdate*******************");
                        UpdateChecker.executeScheduledUpdate(Arrays.asList("-q","-Dinstall4j.keepLog=true","-Dinstall4j.alternativeLogfile=E:/install4j-log/log2.txt"), false, null);
                        log.debug("***************Completed UpdateChecker.executeScheduledUpdate*******************");
                    }
                }

                public void prepareShutdown() {
                    //TODO add your code here (not invoked on event dispatch thread)
                    log.debug("******prepare shut down********");
                }
            }
        );

    } catch (IOException e) {
        e.printStackTrace();
        //TODO handle invocation failure
    }
jstack错误如下所示:

编辑5: 以下是jstack日志:

    2017-09-18 17:31:12
Full thread dump Java HotSpot(TM) Client VM (24.80-b11 mixed mode):

"TimerQueue" daemon prio=6 tid=0x17ecec00 nid=0x3708 waiting on condition [0x1861f000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x03850980> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(Unknown Source)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
    at java.util.concurrent.DelayQueue.take(Unknown Source)
    at javax.swing.TimerQueue.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
    - <0x03884b18> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)

"AWT-EventQueue-0" prio=6 tid=0x17d3f000 nid=0x2670 waiting on condition [0x1841e000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x08ca4218> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(Unknown Source)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
    at java.awt.EventQueue.getNextEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

   Locked ownable synchronizers:
    - None

"AWT-Windows" daemon prio=6 tid=0x17d2fc00 nid=0x40c runnable [0x1838f000]
   java.lang.Thread.State: RUNNABLE
    at sun.awt.windows.WToolkit.eventLoop(Native Method)
    at sun.awt.windows.WToolkit.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
    - None

"AWT-Shutdown" prio=6 tid=0x17d2f400 nid=0xe68 in Object.wait() [0x182ff000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x08c79758> (a java.lang.Object)
    at java.lang.Object.wait(Object.java:503)
    at sun.awt.AWTAutoShutdown.run(Unknown Source)
    - locked <0x08c79758> (a java.lang.Object)
    at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
    - None

"Java2D Disposer" daemon prio=10 tid=0x17d2ec00 nid=0x3d64 in Object.wait() [0x1826f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x08c797e8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(Unknown Source)
    - locked <0x08c797e8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(Unknown Source)
    at sun.java2d.Disposer.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

   Locked ownable synchronizers:
    - None

"Service Thread" daemon prio=6 tid=0x1783bc00 nid=0x468 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"C1 CompilerThread0" daemon prio=10 tid=0x1783a000 nid=0x1768 waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"Attach Listener" daemon prio=10 tid=0x17837800 nid=0x389c waiting on condition [0x00000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"Signal Dispatcher" daemon prio=10 tid=0x17835400 nid=0x3258 runnable [0x00000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
    - None

"Finalizer" daemon prio=8 tid=0x0101a800 nid=0x4394 in Object.wait() [0x033bf000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x08ab74f8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(Unknown Source)
    - locked <0x08ab74f8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(Unknown Source)
    at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

   Locked ownable synchronizers:
    - None

"Reference Handler" daemon prio=10 tid=0x01015800 nid=0x3d50 in Object.wait() [0x0127f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x08ab7588> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
    - locked <0x08ab7588> (a java.lang.ref.Reference$Lock)

   Locked ownable synchronizers:
    - None

"main" prio=6 tid=0x010ac400 nid=0x3138 in Object.wait() [0x00798000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x038517d0> (a com.install4j.runtime.installer.controller.CommandSink)
    at java.lang.Object.wait(Object.java:503)
    at com.install4j.runtime.installer.controller.Controller.start(Controller.java:87)
    - locked <0x038517d0> (a com.install4j.runtime.installer.controller.CommandSink)
    at com.install4j.runtime.installer.Installer.runInProcess(Installer.java:59)
    at com.install4j.runtime.installer.Installer.main(Installer.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:65)
    at com.exe4j.runtime.WinLauncher.main(WinLauncher.java:101)
    at com.install4j.runtime.launcher.WinLauncher.main(WinLauncher.java:26)

   Locked ownable synchronizers:
    - None

"VM Thread" prio=10 tid=0x01012400 nid=0x1bf0 runnable 

"VM Periodic Task Thread" prio=10 tid=0x17856000 nid=0x2fdc waiting on condition 

JNI global references: 449

我建议升级到install4j 7,它有很多新的自动更新功能,可以很好地用于服务

使用install4j 7,您可以在安装程序->屏幕和操作步骤中添加“后台更新下载程序”应用程序。该应用程序模板中的关键操作是“计划更新安装”操作

在您的服务中,您可以按如下方式启动更新下载程序:

ApplicationLauncher.launchApplication("<ID>", null, true, null);
现在,您只需要触发已下载安装程序的执行。您可以立即这样做,如果不想终止服务,也可以在启动时这样做。您需要的代码段如下:

UpdateChecker.executeScheduledUpdate(Arrays.asList("-q"), false, null);
作为更新安装的一部分,服务将关闭。服务无法自动重启(如果您将
true
作为上述方法调用的第二个参数传递给GUI启动器,则GUI启动器可以自动重启),但必须使用“启动服务”操作启动服务,您可能已经在安装程序中执行了该操作

有关更多信息和屏幕截图,请参阅


然后搜索“后台自动更新”。

如果选择“显示ID”工具栏按钮,下载程序的ID就是安装程序->屏幕和操作步骤中更新下载程序名称旁边的ID。您提到的另一个ID(9244-5699-2766-7401)是项目的ID。您不必担心下载位置。请查看更新下载程序的日志文件以检查发生了什么。将VM参数
-Dinstall4j.keepLog=true-Dinstall4j.alternativeLogfile=/path/to/writable/log.txt
传递给更新下载程序(launchApplication
的第二个参数采用带参数的字符串数组),以便在特定路径中获取日志文件。然后,您必须编辑“设置变量”的脚本操作并添加如下调试代码
Util.logInfo(null,“分支1”)
以查看操作不返回更新描述符项的原因。要记录可用条目的版本,请执行
UpdateDescriptorEntry[]条目=((UpdateDescriptor)context.getVariable(“UpdateDescriptor”)).getEntries();对于(UpdateDescriptorEntry:entries){Util.logInfo(null,entry.getNewVersion());}
安装程序似乎正在使用32位JRE运行。您必须使用来自32位JDK的jstack,而不是来自64位JDK的jstack。安装程序具有必须选择的“允许无人参与模式”属性(默认情况下已选择),请检查该属性。如果使用相同的参数从命令行手动执行安装程序会怎么样?这样行吗?
ApplicationLauncher.launchApplication("<ID>", null, true, null);
UpdateChecker.isUpdateScheduled()
UpdateChecker.executeScheduledUpdate(Arrays.asList("-q"), false, null);