I had few questions on hotswapagent. I don't think i really understand what the HotSwapAgent documentation says on the following. It would be good if someone told in detail.
# Watch for changed class files on watchResources path and reload class definition in the running application.
#
# Usually you will launch debugging session from your IDE and use standard hotswap feature.
# This property is useful if you do not want to use debugging session for some reason or
# if you want to enable hotswap at runtime environment.
#
# Internally this uses java Instrumentation API to reload class bytecode. If you need to use JPDA API instead,
# specify autoHotswap.port with JPDA port.
autoHotswap=false
# Create Java Platform Debugger Architecture (JPDA) connection on autoHotswap.port, watch for changed class files
# and do the hotswap (reload) in background.
#
# You need to specify JPDA port at startup
# java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
# autoHotswap.port=8000
I am currently having autoHotswap=true and i have specified a port for debugger (8003). My JVM arguments looks as follows:
JAVA_OPTS=-Xms1024M -Xmx2048M -XX:PermSize=1024M -XX:MaxPermSize=1024M -Xss256k -XX:+UseParallelGC -XX:ParallelGCThreads=4 -XX:-UseGCOverheadLimit -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.lang.ClassLoader.allowArraySyntax=true
-Djobscheduler.disabled=false -Duser.timezone=America/Belize -Dlogin.cache.timeout=120 -XXaltjvm=dcevm -javaagent:"C:\softwares\hotswapagent\hotswap-agent.jar" -DpropertiesFilePath="C:\JBoss\jboss-eap-5.2\jboss-as\bin\hotswap-agent.properties" -Dcom.sungard.gasops.propertyfile="C:\JBoss\jboss-eap-5.2\jboss-as\bin\FactoryOverrides.properties"
My hotswap-agent.properties file is as follows:
# Default agent properties
# You can override them in your application by creating hotswap-agent.properties file in class root
# and specifying new property values.
# Add a directory prior to application classpath (load classes and resources).
#
# This may be useful for example in multi module maven project to load class changes from upstream project
# classes. Set extraClasspath to upstream project compiler output and .class file will have precedence to
# classes from built JAR file.
extraClasspath=C:/Gas_workspaces/GasOps3.0.0.0.0Dev_New/java/rebel/
# Watch for changes in a directory (resources only).
#
# Similar to extraClasspath this property adds classpath when searching for resources (not classes).
# While extra classpath just modifies the classloader, this setting does nothing until the resource
# is really changed.
#
# Sometimes it is not possible to point extraClasspath to your i.e. src/main/resources, because there are multiple
# replacements of resources in a building step (maven filtering resource option).
# This setting will leave i.e. src/target/classes as default source for resources, but after the resource is modified
# in src/main/resources, the new changed resource is served instead.
watchResources=C:/Gas_workspaces/GasOps3.0.0.0.0Dev_New/java/utils/libs/etm_libs/meta/query/
# Load static web resources from different directory.
#
# This setting is dependent on application server plugin(Jetty, Tomcat, JBoss, ...)
webappDir=
# Add a directory prior to webapp path (load webapp resources).
#
# Load web application resources (such as HTML, JSP, CSS, ...) from this directory prior to default processing.
# Use this setting to set to serve resources from source directory directly (e.g. src/main/webapp).
extraWebappContext=
# Comma separated list of disabled plugins
# Use plugin name - e.g. Hibernate, Spring, ZK, Hotswapper, AnonymousClassPatch, Tomcat, Logback ....
disabledPlugins=
# Watch for changed class files on watchResources path and reload class definition in the running application.
#
# Usually you will launch debugging session from your IDE and use standard hotswap feature.
# This property is useful if you do not want to use debugging session for some reason or
# if you want to enable hotswap at runtime environment.
#
# Internally this uses java Instrumentation API to reload class bytecode. If you need to use JPDA API instead,
# specify autoHotswap.port with JPDA port.
autoHotswap=true
# Create Java Platform Debugger Architecture (JPDA) connection on autoHotswap.port, watch for changed class files
# and do the hotswap (reload) in background.
#
# You need to specify JPDA port at startup
#
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8003
# autoHotswap.port=8000
# Enables debugging in OsgiEquinox
# osgiEquinox.debugMode=true
# Logger setup - use entries in the format of
# format: LOGGER.my.package=LEVEL
# e.g. LOGGER.org.hotswap.agent.plugin.myPlugin=trace
# root level
LOGGER=trace
# Print output into logfile
# LOGFILE=agent.logLOGFILE=agent.log
Now, i am having two JDWP debugger ports 9996 and 8003 and i am debugging on 9996. Whenever i debug and make changes in a method, Eclipse tells me that some code changes couldn't be hot swapped and gives me 3 options 'Continue', 'Disconnect' and 'Cancel' (not sure on the 3rd one). I disconnect and i reconnect. Most of the times what i have observed is the code changes aren't reflected / hot swapped. Sometimes when it works i have to do the operation twice to ensure the changes are hot swapped.
Am i doing something wrong ? Can you please help me to correct the configuration if it's wrong ?