skip to Main Content

we have an application WAR that runs on traditional websphere. For local testing we create a docker image for our app based on the "ibmcom/websphere-traditional:8.5.5.22" docker image.

This works fine as such, but when I want to debug my app within the docker container via remote debugging I have to enable DEBUG mode for the server manually through the admin console first. And then I need to restart the server/container.

I am wondering is there a different way of doing this? Like applying some props to the new image that will start my application server in DEBUG mode by default?

Thanks

UPDATE

I’ve been playing with wsadmin scripts. When making the change through web adminconsole and scripting the change out as suggested by lwestby I came up with the following python func which I included in our install.py.

But its not doing the job. Where would I actually see the logger or stdout output from such python scripts?

Thanks

def enableDebug():
    try:
        server1 = AdminConfig.getid('/Cell:DefaultCell01/Node:DefaultNode01/Server:server1/')
        AdminConfig.create('DebugService', server1, '[[BSFDebugPort "4444"] [enable "true"] [jvmDebugPort "7777"] [jvmDebugArgs "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7777"] [debugClassFilters ""] [BSFLoggingLevel "0"]]')
        jvm = AdminConfig.list('JavaVirtualMachine', server1)
        AdminConfig.modify(jvm[0], '[[debugMode "true"]]')
    except:
        logger("EXCEPTION ENABLING DEBUG FOR server1")

2

Answers


  1. You’re right that you’ll need to configure a new image from your base image that starts in debug mode. Since it sounds like you’ve already tried toggling it in the admin console, you can actually get the wsadmin command to change the JVM settings by doing exactly what you did, and looking for the Command Assistance header in the right column:

    Command Assistance in the Admin Console

    As soon as you check the box to enable Debug mode and click OK, click that "View administrative scripting command for last action" link to get the command, something like:

    AdminTask.setJVMProperties('[-nodeName DefaultNode01 -serverName server1 -verboseModeClass false -verboseModeGarbageCollection true -verboseModeJNI false -runHProf false -hprofArguments -debugMode true -debugArgs "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7777" -executableJarFileName -genericJvmArguments "-Xnoloa" -disableJIT false]')
    

    (Don’t just copy paste what I have here in case your image has other settings changed.)

    Then you can add this link to an existing or new wsadmin .py file that you apply as part of the image build process. Make sure the file runs AdminConfig.save() after the command.

    Then build a new image and that image should start up in debug mode by default.

    Login or Signup to reply.
  2. Solution extracting properties-file based configuration from admin console updates

    1. Start initial container

    docker run --name mywas -p 9043:9043 -p 9443:9443 ibmcom/websphere-traditional:8.5.5.22

    1. Grab generated wsadmin password

    docker exec -it mywas bash -c "cat /tmp/PASSWORD";

    1. Open admin console (point browser to: https://localhost:9043/ibm/console/ )

    2. Click to enable server for debug (use Debugging Service or Application servers > server1 > Process definition > Java Virtual Machine

    3. Click Apply to save

    4. Launch wsadmin

    docker exec -it mywas bash -c "/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -lang jython -user wsadmin -password <password>"
    (Accept self-signed cert. if prompted)

    1. (Within wsadmin session), extract properties

    print AdminTask.extractConfigProperties('-configData Node=DefaultNode01 -propertiesFileName /home/was/jvm.props -filterMechanism SELECTED_SUBTYPES -selectedSubTypes JavaVirtualMachine')

    1. Back in host, copy properties out of container

    docker cp mywas:/home/was/jvm.props jvm.props

    1. Copy jvm.props properties file to location of your Dockerfile and add COPY to /work/config
    FROM ibmcom/websphere-traditional:8.5.5.22
    COPY --chown=was:root jvm.props /work/config/
    RUN /work/configure.sh
    
    1. docker build (notice the build will take a bit of time, as your props are "applied" via wsadmin via the websphere docker tooling utils)

    Your new image will be enabled for debug.

    COMMENTS

    This is clearly more work than adding a single wsadmin script (as in @lwestby’s answer). One nice aspect of the properties file approach is you only have to learn a single wsadmin command AdminTask.extractConfigProperties, instead of learning different commands for each admin/config object type. Learning the different commands isn’t as much of a challenge as it might seem given the assistance mentioned in lwestby’s answer but there might be times when it’s easier to just work with the properties more directly, possibly filtering them, like in the example in this answer.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search