MQ

MQ

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Starting mqweb server as a Windows service

  • 1.  Starting mqweb server as a Windows service

    Posted Wed June 01, 2022 04:46 PM
    Hello,

    I have a problem with the mqweb server starting in service mode.

    Environment:
    - Windows Server 2019 Server Standard Edition, Build 17763
    - IBM MQ Version: 9.2.0.4

    I have set up the mqweb server with authentication in LocalOS mode.
    Starting my server from the command line, everything works.
    If I create a Windows service (server registerWinService mqweb), and I start this service (server startWinService mqweb) I get an error :
    Error 500: java.lang.UnsatisfiedLinkError: com/ibm/mq/rest/auth/osauth/v1/MQLocalAuthenticationV1.getRealmMethod()Ljava/lang/String;,
    with in the logs:
    CWWKE0701E: bundle com.ibm.ws.security.registry:1.0.56.cl210920210824-2341 (53)[com.ibm.ws.security.registry.internal.UserRegistryServiceImpl(64)] : The setUserRegistry method has thrown an exception java.lang.UnsatisfiedLinkError: com/ibm/mq/rest/auth/osauth/v1/MQLocalAuthenticationV1.getRealmMethod()Ljava/lang/String;
    at com.ibm.mq.rest.auth.osauth.v1.MQLocalAuthenticationV1.getRealm(MQLocalAuthenticationV1.java:414)

    On the other hand, starting via strmqweb works.

    I found on http://www.mqseries.net/phpBB2/viewtopic.php?t=75795&sid=33a1d4a6004afdff935853aee2410ade
    a post from 2019 with the same problem, but no information about the resolution.

    On my workstation (Win 10 Pro, MQ 9.2.5.0), I do not have this problem.

    Any idea how to solve this?

    Incidentally, is it possible to pass parameters to "server registerWinService mqweb" to have an auto start service (not manual) and a custom label (not IBM WebSphere Liberty Profile)?

    Thank you.

    ------------------------------
    Luc-Michel Demey
    DEMEY CONSULTING
    lmd@demey-consulting.fr
    #IBMChampion
    ------------------------------


  • 2.  RE: Starting mqweb server as a Windows service

    Posted Mon June 06, 2022 06:28 AM

    Hello,

    Does your service not call strmqweb? strmqweb runs setmqenv which allows MQLocalAuthenticationV1 to locate the native libraries it needs.

    Regards, Matt.



    ------------------------------
    MATTHEW LEMING
    ------------------------------



  • 3.  RE: Starting mqweb server as a Windows service

    Posted Tue June 07, 2022 02:19 AM
    Hello Matthew,

    Thank you for this answer.

    My goal is to automatically launch mqweb at Windows VM startup (a bit like Queue Manager autostart).

    I found in the Liberty documentation (https://www.ibm.com/docs/en/was-liberty/base?topic=line-starting-stopping-liberty-server-as-windows-service)
    the command "server registerWinService serverName" which allows to automatically start a Liberty server via a Windows service.
    This command creates a service that starts <mq_bin>\web\tools\win\prunsrv.exe //RS//mqweb, which probably does a "server start mqweb", when indeed the service start should call strmqweb.
    So "server registerWinService mqweb" doesn't seem like the right solution to start this server.

    I will try with sc [<ServerName>] create [<ServiceName>] ..., unless there is something else to create this service with an MQ command?

    Thanks.

    ------------------------------
    Luc-Michel Demey
    DEMEY CONSULTING
    lmd@demey-consulting.fr
    #IBMChampion
    ------------------------------



  • 4.  RE: Starting mqweb server as a Windows service

    Posted Fri June 10, 2022 10:54 AM
    Here is the solution I used :

    • create a Windows service (via sc create)
    • modify this service (via sc description) to have a label
    • edit the registry to change the value of ServicesPipeTimeout (otherwise error 1053 timeout when starting the service)
    • restart the server to take into account the registry changes.
    It's not very practical, but it works.

    I have created an idea about this (https://integration-development.ideas.ibm.com/ideas/MESNS-I-450)

    ------------------------------
    Luc-Michel Demey
    DEMEY CONSULTING
    lmd@demey-consulting.fr
    #IBMChampion
    ------------------------------



  • 5.  RE: Starting mqweb server as a Windows service

    Posted Fri February 10, 2023 08:46 AM

    Hi Luc-Michel

    Wouldn't it just be easier to use nssm for this?

    I have put the strmqweb in nssm and it works for me.

    You can script nssm and set all the params via commandline

    to install, set the startup and set the user you would need to following 3 commands

    nssm install mqweb C:\Windows\System32\cmd.exe /k "\""C:\Program Files\IBM\MQ\bin\strmqweb.bat"\""

    nssm set mqweb AppDirectory "C:\Program Files\IBM\MQ\bin\"

    nssm set mqweb ObjectName <username> <password>

    This would create a server that start mqweb (automatic by default) as a specific user.



    ------------------------------
    Regards
    Matthias Blomme
    ------------------------------



  • 6.  RE: Starting mqweb server as a Windows service

    Posted Fri February 10, 2023 08:56 AM

    Hello Matthias,

    Of course, using a tool like nssm allows to have a cleaner solution, but installing non-Microsoft or non-IBM binaries on a server is not necessarily possible or allowed in all environments.
    That's why I looked for a solution that uses only classical elements for this function.
    It's a pity that IBM doesn't offer it natively.



    ------------------------------
    Luc-Michel Demey
    DEMEY CONSULTING
    lmd@demey-consulting.fr
    #IBMChampion
    ------------------------------



  • 7.  RE: Starting mqweb server as a Windows service

    Posted Fri February 10, 2023 09:09 AM

    Luc-Michel

    In that case, can't you just

    • run crtmqm,
    • copy all env variables related to MQ to the machine level environment (via powershell [System.Environment]::SetEnvironmentVariable('$key', '$value', 'Machine'))
    • install with server registerWinService serverName

    That would work as well, no?



    ------------------------------
    Regards
    Matthias Blomme
    ------------------------------



  • 8.  RE: Starting mqweb server as a Windows service

    Posted Thu January 23, 2025 04:51 AM

    Hi all 

    I'm trying to setup mqweb as a Windows Service, following the suggestions from this thread and some other links, the first problem is this one: 

    Configure a server (Starting and stopping a Liberty server as a Windows service - IBM Documentation

    server.bat registerWinService serverName

    this server.bat returns a file not found for: prunsrv.exe

    "C:\Program Files\IBM\MQ\web\bin>"!WLP_INSTALL_DIR!\bin\tools\win\prunsrv.exe"  //IS//mqweb --Startup=manual --DisplayName="mqweb" --Description="IBM WebSphere Liberty" ++DependsOn=Tcpip --LogPath="!WLP_OUTPUT_DIR!\mqweb\logs" --StdOutput=auto --StdError=auto --StartMode=exe --StartPath="C:\Program Files\IBM\MQ\web" --StartImage="C:\Program Files\IBM\MQ\web\bin\server.bat" ++StartParams=start#mqweb --StopMode=exe --StopPath="C:\Program Files\IBM\MQ\web" --StopImage="C:\Program Files\IBM\MQ\web\bin\server.bat" ++StopParams=stop#mqweb --ServiceUser=LocalSystem
    The system cannot find the path specified."

    so I guess this prunsrv.exe is not shipped with MQ, or is it missing from my installation? I'm using MQ 9.3 

    Is there any detailed documentation about setting the mqweb as a service? 

    Thanks

    joao 



    ------------------------------
    Joao Ramires
    ------------------------------



  • 9.  RE: Starting mqweb server as a Windows service

    Posted Thu January 23, 2025 05:19 AM

    Hello Joao,

    Some months ago I worked on this subject, I have a partial answer.
    The basic idea is to create a Windows service that launches strmqweb.bat.

    When an executable is launched via a service, Windows expects a return code from the executable indicating whether the launch was successful.

    The strmqweb.bat script does not return this return code. The launch of the mqweb server goes well, but the Windows service manager returns an error 1053: "The service did not respond fast enough...", and then marks the service as "stopped".

    I even opened an IBM Ideas about it :
    https://ideas.ibm.com/ideas/MESNS-I-450
    to ask for the addition of a '-sa' parameter (like crtmqm -sa) to automatically create a Windows service running the mqweb server. IBM's response was "not under consideration".

    It is possible to use external utilities to encapsulate strmqweb.bat, or to modify the contents of strmqweb.bat to test the server launch and return the return code expected by Windows.

    Personally, I prefer a simpler solution, based on the creation of a Windows service with "sc". Principle:

    sc create <service_name> start= auto error= ignore binpath= <path>\strmqweb.bat obj= LocalSystem displayname= "name to display"
    sc description <service_name> "service description"

    Example: 

    sc create MQWeb940 start= auto error= ignore binpath= J:\MQ940\bin\strmqweb.bat obj= LocalSystem displayname= "IBM MQ - MQWeb 940"
    sc description MQWeb940 "IBM MQ - MQWeb 940"

    This solution works, but returns error 1053 at startup, as expected.

    HTH, LMD.



    ------------------------------
    Luc-Michel Demey
    DEMEY CONSULTING
    lmd@demey-consulting.fr
    #IBMChampion
    ------------------------------



  • 10.  RE: Starting mqweb server as a Windows service

    Posted Thu January 23, 2025 07:53 AM

    Thanks , fantastic 

    It works and the mqweb starts ok , the but the service status, on the Windows Services (service.msc) doesn't show as "Running". I created as ServicesPipeTimeout with 180000 but I don't see a difference, the 1053 error shows when starting the service  



    ------------------------------
    Joao Ramires
    ------------------------------



  • 11.  RE: Starting mqweb server as a Windows service

    Posted Fri January 24, 2025 08:34 AM

    You probably need to create your own batch file with content of something like the following pseudo code

    cd /d <path to executables>
    call strmqweb
    wait x time
    call dspmqweb | find "Running"
    if errorlevel ....
      exit windows service return code
    else 
      exit other return code
    endif
    
    

    Hope it helps



    ------------------------------
    Francois Brandelik
    ------------------------------



  • 12.  RE: Starting mqweb server as a Windows service

    Posted Fri January 24, 2025 08:46 AM

    Thanks for the suggestion Francois,

    I may try something like you present. The funny thing is the return code 1053, from windows services.msc: when starting the service , RC 1053 is returned , service status is empty, but in fact the Liberty profile mqweb starts and stays running. I played with the regedit option ServicesPipeTimeout but it seems having no effect 

    joao 



    ------------------------------
    Joao Ramires
    ------------------------------



  • 13.  RE: Starting mqweb server as a Windows service

    Posted Mon January 27, 2025 01:11 PM
    Edited by Joao Ramires Mon January 27, 2025 01:20 PM

    Hello all,

    found a solution using prunsrv.exe (prunsrv.exe is available with Liberty profile , or Apache) in my case I found this prunsrv from 2017 in my desktop. 

    What I did:

    1. Create a "win" folder under C:\Program Files\IBM\MQ\web\bin\tools and copy  prunsrv.exe to this folder
    2. run C:\Program Files\IBM\MQ\web\bin>server.bat registerWinService mqweb

    and the service is created and registered, service Name is "mqweb" and Description is "IBM WebShpere Liberty". 

    If we want a different description,  server.bat file can be edited and change the line were the service is created or using windows sc command 


    ------------------------------
    Joao Ramires
    ------------------------------