title: How do I debug GlassFish 3 using Eclipse Helios?
body: <p>I am using the GlassFish 3 server adapter with Eclipse Helios 3.6. I can start the server using the <em>Servers</em> view in Eclipse, and things run just fine - but I am not able to debug my code.</p>
  
  <p>After using the GF Admin Console to enable debugging (<em>Configuration → JVM Settings → Debug</em>, then restart the server), clicking <em>Debug</em> (<kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>D</kbd>) gives me an error window:</p>
  
  <p><img src="https://i.stack.imgur.com/YdK1k.png" alt="error window"></p>
  
  <p>I'm guessing this is because Eclipse can't connect to the JVM's debug port (9009 by default).</p>
  
  <p>What is the proper way to set up GlassFish 3 debugging in Helios?</p>
  
  <hr>
  
  <h2>Edit</h2>
  
  <p>Re: @The Elite Gentleman, there aren't any errors that show up in the console. Here's an example:</p>
  
  <pre><code>Nov 29, 2010 11:47:42 AM com.sun.enterprise.admin.launcher.GFLauncherLogger info
  INFO: JVM invocation command line:
  C:\Program Files\Java\jdk1.6.0_22\bin\java.exe
  -cp
  C:/glassfishv3/glassfish/modules/glassfish.jar
  -XX:+UnlockDiagnosticVMOptions
  -XX:MaxPermSize=192m
  -XX:NewRatio=2
  -XX:+LogVMOutput
  -XX:LogFile=C:\glassfishv3\glassfish\domains\myDomain/logs/jvm.log
  -Xmx512m
  -client
  -javaagent:C:/glassfishv3/glassfish/lib/monitor/btrace-agent.jar=unsafe=true,noServer=true
  -Dosgi.shell.telnet.maxconn=1
  -Djdbc.drivers=org.apache.derby.jdbc.ClientDriver
  -Dfelix.fileinstall.dir=C:\glassfishv3\glassfish/modules/autostart/
  -Djavax.net.ssl.keyStore=C:\glassfishv3\glassfish\domains\myDomain/config/keystore.jks
  -Dosgi.shell.telnet.port=6666
  -Djava.security.policy=C:\glassfishv3\glassfish\domains\myDomain/config/server.policy
  -Dfelix.fileinstall.poll=5000
  -Dcom.sun.aas.instanceRoot=C:\glassfishv3\glassfish\domains\myDomain
  -Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
  -Dosgi.shell.telnet.ip=127.0.0.1
  -Djava.endorsed.dirs=C:\glassfishv3\glassfish/modules/endorsed;C:\glassfishv3\glassfish/lib/endorsed
  -Dcom.sun.aas.installRoot=C:\glassfishv3\glassfish
  -Djava.ext.dirs=C:\Program Files\Java\jdk1.6.0_22/lib/ext;C:\Program Files\Java\jdk1.6.0_22/jre/lib/ext;C:\glassfishv3\glassfish\domains\myDomain/lib/ext
  -Dfelix.fileinstall.bundles.new.start=true
  -Djavax.net.ssl.trustStore=C:\glassfishv3\glassfish\domains\myDomain/config/cacerts.jks
  -Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as
  -Djava.security.auth.login.config=C:\glassfishv3\glassfish\domains\myDomain/config/login.conf
  -DANTLR_USE_DIRECT_CLASS_LOADING=true
  -Dfelix.fileinstall.debug=1
  -Dorg.glassfish.web.rfc2109_cookie_names_enforced=false
  -Djava.library.path=C:/glassfishv3/glassfish/lib;C:/Program Files/Java/jdk1.6.0_22/bin;C:/glassfishv3/glassfish;C:/Windows/Sun/Java/bin;C:/Windows/System32;C:/Windows;C:/Program Files/Java/jdk1.6.0_22/jre/bin/server;C:/Program Files/Java/jdk1.6.0_22/jre/bin;C:/Program Files/Java/jdk1.6.0_22/jre/lib/amd64;C:/Python26/Scripts;C:/Python26;C:/Windows/System32/wbem;C:/Program Files (x86)/ATI Technologies/ATI.ACE/Core-Static;C:/Program Files (x86)/Common Files/Roxio Shared/DLLShared;C:/Program Files (x86)/Common Files/Roxio Shared/10.0/DLLShared;C:/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn;C:/Program Files/Microsoft SQL Server/100/Tools/Binn;C:/Program Files/Microsoft SQL Server/100/DTS/Binn;C:/Windows/System32/WindowsPowerShell/v1.0;C:/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn/VSShell/Common7/IDE;C:/Program Files (x86)/Microsoft SQL Server/100/DTS/Binn;C:/Program Files (x86)/PuTTY;C:/Program Files (x86)/jboss-4.2.2.GA/bin;C:/Program Files/MySQL/MySQL Server 5.0/bin;C:/Program Files/IBM/SQLLIB/BIN;C:/Program Files/IBM/SQLLIB/FUNCTION;C:/Program Files/IBM/SQLLIB/samples/repl;C:/Program Files/TortoiseSVN/bin;C:/jboss-5.1.0.GA/bin;C:/Program Files (x86)/QuickTime/QTSystem;C:/Program Files (x86)/Git/cmd;C:/Program Files/SlikSvn/bin;C:/glassfishv3/glassfish/%APPDATA%/Python/Scripts;C:/Program Files (x86)/Apache/apache-ant-1.7.0/bin;C:/Program Files (x86)/CVSNT/C:/jboss-5.1.0.GA/bin;C:/Program Files (x86)/Java/jdk1.6.0_14;C:/Program Files (x86)/Apache/apache-maven-2.1.0/bin;C:/glassfishv3/glassfish/bin
  com.sun.enterprise.glassfish.bootstrap.ASMain
  -domainname
  myDomain
  -asadmin-args
  start-domain,,,--domaindir,,,C:\glassfishv3\glassfish\domains,,,--debug,,,--verbose=true,,,myDomain
  -instancename
  server
  -verbose
  true
  -debug
  true
  -asadmin-classpath
  C:/glassfishv3/glassfish/modules/admin-cli.jar
  -asadmin-classname
  com.sun.enterprise.admin.cli.AsadminMain
  -upgrade
  false
  -domaindir
  C:/glassfishv3/glassfish/domains/myDomain
  -read-stdin
  true
  Nov 29, 2010 11:47:43 AM com.sun.enterprise.admin.launcher.GFLauncherLogger info
  INFO: Successfully launched in 4 msec.
  
  INFO: Running GlassFish Version: GlassFish Server Open Source Edition 3.0.1 (build 22)
  
  INFO: Perform lazy SSL initialization for the listener 'http-listener-2'
  INFO: Starting Grizzly Framework 1.9.18-o - Mon Nov 29 11:47:46 EST 2010
  INFO: Starting Grizzly Framework 1.9.18-o - Mon Nov 29 11:47:46 EST 2010
  INFO: Grizzly Framework 1.9.18-o started in: 40ms listening on port 7676
  INFO: Grizzly Framework 1.9.18-o started in: 50ms listening on port 3700
  INFO: Grizzly Framework 1.9.18-o started in: 90ms listening on port 80
  INFO: Grizzly Framework 1.9.18-o started in: 60ms listening on port 4848
  INFO: Grizzly Framework 1.9.18-o started in: 67ms listening on port 8181
  INFO: The Admin Console is already installed, but not yet loaded.
  
  INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
  
  INFO: SEC1002: Security Manager is OFF.
  INFO: Security startup service called
  INFO: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
  INFO: Realm admin-realm of classtype com.sun.enterprise.security.auth.realm.file.FileRealm successfully created.
  INFO: Realm file of classtype com.sun.enterprise.security.auth.realm.file.FileRealm successfully created.
  INFO: Realm certificate of classtype com.sun.enterprise.security.auth.realm.certificate.CertificateRealm successfully created.
  INFO: Realm jdbc of classtype com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm successfully created.
  INFO: Security service(s) started successfully....
  INFO: Created HTTP listener http-listener-1 on port 80
  INFO: Created HTTP listener http-listener-2 on port 8181
  INFO: Created HTTP listener admin-listener on port 4848
  INFO: Created virtual server server
  INFO: Created virtual server server
  INFO: Created virtual server __asadmin
  INFO: Created virtual server __asadmin
  INFO: Created virtual server __asadmin
  
  INFO: Virtual server server loaded system default web module
  |#]
  INFO: Virtual server server loaded system default web module
  
  INFO: Initializing Mojarra 2.0.2 (FCS b10) for context '/richfaces-showcase'
  
  INFO: Selected fallback cache factory
  INFO: Creating LRUMap cache instance using parameters: {org.richfaces.enableControlSkinningClasses=false, javax.faces.PROJECT_STAGE=Development, com.sun.faces.validateXml=true, com.sun.faces.forceLoadConfiguration=true, javax.faces.STATE_SAVING_METHOD=server, org.richfaces.enableControlSkinning=true, javax.faces.FACELETS_LIBRARIES=/WEB-INF/app-tags.taglib.xml, org.richfaces.skin=#{skinBean.skin}}
  INFO: Creating LRUMap cache instance of 512 items capacity
  INFO: RichFaces Core Implementation by JBoss, a division of Red Hat, Inc., version v.4.0.0-SNAPSHOT SVN r.20127
  INFO: Monitoring jndi:/server/richfaces-showcase/WEB-INF/faces-config.xml for modifications
  INFO: Loading application richfaces-showcase at /richfaces-showcase
  INFO: Loading application richfaces-showcase at /richfaces-showcase
  INFO: Loading richfaces-showcase Application done is 7895 ms
  
  INFO: Hibernate Validator bean-validator-3.0-JBoss-4.0.2
  INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
  
  INFO: Portable JNDI names for EJB UserBean : [java:global/RetailerPortalDemo/RetailerPortalDemo_Bean/UserBean, java:global/RetailerPortalDemo/RetailerPortalDemo_Bean/UserBean!com.lapis.retailerportal.demo.ejb.UserBean]
  INFO: Portable JNDI names for EJB DbTestBean : [java:global/RetailerPortalDemo/RetailerPortalDemo_Bean/DbTestBean!com.lapis.retailerportal.demo.ejb.DbTestBean, java:global/RetailerPortalDemo/RetailerPortalDemo_Bean/DbTestBean]
  INFO: Portable JNDI names for EJB NewsBean : [java:global/RetailerPortalDemo/RetailerPortalDemo_Bean/NewsBean!com.lapis.retailerportal.demo.ejb.NewsBean, java:global/RetailerPortalDemo/RetailerPortalDemo_Bean/NewsBean]
  INFO: Portable JNDI names for EJB GameConfigBean : [java:global/RetailerPortalDemo/RetailerPortalDemo_Bean/GameConfigBean!com.lapis.retailerportal.demo.ejb.GameConfigBean, java:global/RetailerPortalDemo/RetailerPortalDemo_Bean/GameConfigBean]
  
  INFO: Initializing Mojarra 2.0.2 (FCS b10) for context '/RetailerPortalDemo'
  
  INFO: com.lapis.retailerportal.demo.entity.Retailer actually got transformed
  
  INFO: Selected fallback cache factory
  INFO: Creating LRUMap cache instance using parameters: {javax.faces.PROJECT_STAGE=Development, com.sun.faces.validateXml=true, com.sun.faces.forceLoadConfiguration=true, org.richfaces.skin=tweaked}
  INFO: Creating LRUMap cache instance of 512 items capacity
  INFO: RichFaces Core Implementation by JBoss, a division of Red Hat, Inc., version v.4.0.0.20101110-M4 SVN r.20021
  INFO: com.lapis.retailerportal.demo.entity.GameConfig actually got transformed
  INFO: com.lapis.retailerportal.demo.entity.NewsItem actually got transformed
  INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
  INFO: EclipseLink, version: Eclipse Persistence Services - 2.0.1.v20100213-r6600
  
  INFO: file:/C:/glassfishv3/glassfish/domains/myDomain/eclipseApps/RetailerPortalDemo/RetailerPortalDemo_Bean_jar/_RPD_Persistence_CTX login successful
  INFO: Loading application RetailerPortalDemo#RetailerPortalDemo_Web.war at RetailerPortalDemo
  INFO: Loading application RetailerPortalDemo#RetailerPortalDemo_Web.war at RetailerPortalDemo
  INFO: Loading RetailerPortalDemo Application done is 5656 ms
  INFO: GlassFish Server Open Source Edition 3.0.1 (22) startup time : Felix(2386ms) startup services(14265ms) total(16651ms)
  INFO: Binding RMI port to *:8686
  
  INFO: JMXStartupService: Started JMXConnector, JMXService URL = service:jmx:rmi://192.168.5.10:8686/jndi/rmi://192.168.5.10:8686/jmxrmi
  
  INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started
  INFO: {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = C:\glassfishv3\glassfish\modules\autostart, felix.fileinstall.debug = 1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = C:\Users\mjball\AppData\Local\Temp\fileinstall-2104459395405070416, felix.fileinstall.filter = null}
  INFO: {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = C:\glassfishv3\glassfish\domains\myDomain\autodeploy\bundles, felix.fileinstall.debug = 1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = C:\Users\mjball\AppData\Local\Temp\fileinstall-286375592969619901, felix.fileinstall.filter = null}
  INFO: Started bundle: file:/C:/glassfishv3/glassfish/modules/autostart/osgi-web-container.jar
  
  INFO: Updating configuration from org.apache.felix.fileinstall-autodeploy-bundles.cfg
  INFO: Installed C:\glassfishv3\glassfish\modules\autostart\org.apache.felix.fileinstall-autodeploy-bundles.cfg
  INFO: {felix.fileinstall.poll (ms) = 5000, felix.fileinstall.dir = C:\glassfishv3\glassfish\domains\myDomain\autodeploy\bundles, felix.fileinstall.debug = 1, felix.fileinstall.bundles.new.start = true, felix.fileinstall.tmpdir = C:\Users\mjball\AppData\Local\Temp\fileinstall--3209587030652226629, felix.fileinstall.filter = null}
  </code></pre>
  
  <h2>Edit 2</h2>
  
  <p>I was able to successfully debug in Eclipse by starting GlassFish externally, e.g.</p>
  
  <pre><code>&gt; asadmin start-domain myDomain
  </code></pre>
  
  <p>and then creating a custom Debug Configuration:</p>
  
  <p><img src="https://imgur.com/jJlg7.png" alt="bloody hell &gt;:("></p>
  
  <p><em>So why can't the GlassFish server adapter do this?</em></p>
  
  <h2>Edit 3 - Problem solved</h2>
  
  <p>Originally, I had added GlassFish support through the <a href="http://download.java.net/glassfish/eclipse/helios" rel="noreferrer">GlassFish Tools plugin</a>. I uninstalled the plugin, and added GlassFish support using <em>Servers → New → Server → Download additional server adapters</em>. Now I can debug. <strong>Woohoo!</strong></p>