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
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:
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:
(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 runsAdminConfig.save()
after the command.Then build a new image and that image should start up in debug mode by default.
Solution extracting properties-file based configuration from admin console updates
docker run --name mywas -p 9043:9043 -p 9443:9443 ibmcom/websphere-traditional:8.5.5.22
docker exec -it mywas bash -c "cat /tmp/PASSWORD";
Open admin console (point browser to: https://localhost:9043/ibm/console/ )
Click to enable server for debug (use Debugging Service or Application servers > server1 > Process definition > Java Virtual Machine
Click Apply to save
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)
print AdminTask.extractConfigProperties('-configData Node=DefaultNode01 -propertiesFileName /home/was/jvm.props -filterMechanism SELECTED_SUBTYPES -selectedSubTypes JavaVirtualMachine')
docker cp mywas:/home/was/jvm.props jvm.props
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.