I'm fighting with Eclipse version 2024-09 right now when running junit tests. When I go to run our Junit 4 (yes old) tests, it complains with very opaque error message:
Reference to undefined variable argLine
After poking around for a while I find that under the Run Configurations for the Junit test in question, in the VM arguments window there is not only -ea
but also a whole bunch of additional arguments include ${argLine}
. Ok, good. But I have no idea where that is coming from. When I delete that configuration and re-run, the extra arguments come back.
The full argument list follows. You can see that there are some obvious debug flags in there that I might set if doing some profiling or remove debugging. But again, where are they coming from?
-ea
${argLine} -javaagent:${com.github.jbellis:jamm:jar}
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n
-Djava.net.preferIPv4Stack=true -Xms512m -Xmx1g -DMHUB_DEV=true
I did some searches and found people talking about the Installed JREs -> Edit -> Default VM arguments but none of my JREs have any arguments.
I've done a grep -r
of "argLine" and "agentlib" down in my workspace configurations and maven pom.xml file to see if it was in some sort of plugin configurations or something. I see it show up in the test run configurations but nowhere else. I don't see it in the environment nor in any maven pom plugin configurations that I can find. I've tried restarting Eclipse.
Any other ideas? Thanks in advance.
Eclipse 2024-09 includes m2e 2.6.2 which added a new feature where arguments from the Maven surefire plugin would be propagated to run configurations.
So if your pom.xml contains CLI arguments for tests in the surefire or failsafe plugin similar to the following, these arguments would be copied:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
your arguments here
</argLine>
</configuration>
</plugin>
If these arguments are defined in a parent POM (a <parent>
element referencing another artifact in the pom.xml), these are propagated as well. To check for that, you can open the pom.xml
in Eclipse and open the Effective POM
tab:
This should show you the full effective pom.xml that also includes content from parent POMs.
If you remove the arguments the error at startup from the pom.xml and update the Maven project by right-clicking on the project and selecting Maven > Update Project, it should stop trying to use these arguments.
If this is a bug where Eclipse fails to interpolate some properties, please create an issue in m2e including a minimal pom.xml
reproducing it.