Search code examples
javadebuggingintellij-ideajbosswildfly-8

Why WildFly throws an Exception in Intellij IDEA's debug mode while the run mode works perfectly well?


I decided to learn how to debug Java EE apps. I have a simple JSF/EJB/JPA app which I deploy and run via Intellij IDEA. That means that I have a so called Run/Debug configuration where I had specified an artifact to deploy(a war file) an application server path(wildfly-8.2.0.Final/bin/standalone.bat is used) an a url to be opened in browser after deployment(its a web app). Works awesome - no problems. But when I run debug which as far as I understand uses basically the same configuration but only adds

JAVA_OPTS   -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:52764,suspend=y,server=n

to the enviroment variables I have problems.

D:\Proc\wildfly-8.2.0.Final\bin\standalone.bat D:\Proc\JDK\jdk1.8.0_31\bin\java -classpath "D:\Proc\IntelliJ IDEA 14.1.3\lib\idea_rt.jar;D:\Proc\IntelliJ IDEA 14.1.3\lib\util.jar" -Dfile.encoding=windows-1251 com.intellij.rt.execution.CommandLineWrapper C:\Users\username\AppData\Local\Temp\classpath0.tmp com.intellij.javaee.oss.process.JavaeeProcess 53821 com.intellij.javaee.oss.jboss.agent.JBoss71Agent Detected server admin port: 9990 [2015-05-30 04:35:06,499] Artifact portfolio:war exploded: Server is not connected. Deploy is not available. Detected server http port: 8080 Calling "D:\Proc\wildfly-8.2.0.Final\bin\standalone.conf.bat" "JAVA_OPTS already set in environment; overriding default settings with values: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:52764,suspend=y,server=n

" Setting JAVA property to "D:\Proc\JDK\jdk1.8.0_31\bin\java"

JBoss Bootstrap Environment

JBOSS_HOME: "D:\Proc\wildfly-8.2.0.Final"

JAVA: "D:\Proc\JDK\jdk1.8.0_31\bin\java"

JAVA_OPTS: "-Dprogram.name=standalone.bat -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:52764,suspend=y,server=n "

===============================================================================

Connected to the target VM, address: '127.0.0.1:52764', transport: 'socket'

After that I guess the deployment phase fails with an exception and a debugger as supposed by its default behavior stops on the line that throws an exception in URLClassLoader: enter image description here

enter image description here

What's going on? Why does the same configuration behave differently? I need something to start with...

Thx.


Solution

  • The reason is that Intellij Idea overwrites the JAVA_OPTS enviroment variable when started in debug mode. You can verify this in the Run/Debug Configurations Dialog. Select your configuration and have a look at the Startup/Connection tab. Select Debug and you can see below that the checkmark for Pass environment variables is set.

    There is an entry for JAVA_OPTS. It probably overrides all settings made in standalone.conf (standalone.conf.bat for windows). These settings can be important for operation. Especially if you customize some settings in standalone.conf you can see them in run mode but not in debug mode.