Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jetty-maven-plugin does not correctly pass JVM arguments for external deployMode #6153

Closed
kazkansouh opened this issue Apr 11, 2021 · 2 comments · Fixed by #6155
Closed

jetty-maven-plugin does not correctly pass JVM arguments for external deployMode #6153

kazkansouh opened this issue Apr 11, 2021 · 2 comments · Fixed by #6155
Assignees

Comments

@kazkansouh
Copy link

Jetty version

jetty-maven-plugin: 10.0.2

Java version

$ java -version
openjdk version "11.0.11-ea" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11-ea+4-post-Debian-1)
OpenJDK 64-Bit Server VM (build 11.0.11-ea+4-post-Debian-1, mixed mode, sharing)

OS type/version

debian/rolling

Description

I have been attempting use jetty-maven-plugin during development phase of a webapp but have come across an issue with the jvmArgs configuration parameter when running with deployMode=EXTERNAL.

From inspecting the code that generates the command which launches the java it treats the jvmArgs as arguments to the jetty jar, which means its not possible to enable the java debug server. That is, I want to set jvmArgs to -agentlib:jdwp=transport=dt_socket,address=8000,server=y so I can actually debug the code but this is instead passed to jetty and not jvm and then ignored. See excerpt of the code used to build the command line below:

https://github.com/eclipse/jetty.project/blob/e163b001c34704154edb45c7aa37908e0d9aafd7/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyHomeForker.java#L168-L187

I think it would be useful to have both a jettyArgs and jvmArgs configuration parameter as there are cases where it is useful to pass options directly to jetty as well.

In case its of use, here is the plugin configuration (it tries to make use of both jetty and jvm arguments and fails):

          <configuration>
            <webApp>
              <contextPath>/${project.build.finalName}</contextPath>
            </webApp>
            <contextXml>${project.basedir}/jetty-context.xml</contextXml>
            <scanIntervalSeconds>10</scanIntervalSeconds>
            <scanTargets>
              <scanTarget>src/main/webapp/WEB-INF/web.xml</scanTarget>
            </scanTargets>
            <deployMode>EXTERNAL</deployMode>
            <jvmArgs>--lib=${project.basedir}/../jetty-auth/target/jetty-auth-1.0-SNAPSHOT.jar -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmArgs>
            <modules>jaas,jsp</modules>
            <jettyProperties>
              <jetty.jaas.login.conf>${project.basedir}/jaas.conf</jetty.jaas.login.conf>
            </jettyProperties>
          </configuration>
@janbartel janbartel self-assigned this Apr 11, 2021
@janbartel
Copy link
Contributor

@kazkansouh using the EXTERNAL mode of running jetty will fork a new process and execute the equivalent of java -jar $jetty.home/start.jar. When using the jetty start.jar mechanism with a remote debugger (and many other types of jvm args), you need to use the --exec parameter in order to fork yet another process to which the jvm args are applied. So, put this line into your pom.xml:

<jvmArgs>--lib=${project.basedir}/../jetty-auth/target/jetty-auth-1.0-SNAPSHOT.jar --exec -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmArgs>

@janbartel
Copy link
Contributor

@kazkansouh it appears that if I swap the ordering of the jvmArgs passed into the forked process they are correctly interpreted by the jvm. I've opened a PR for that here: #6155. If you want to build the branch https://github.com/eclipse/jetty.project/tree/jetty-10.0.x-6153-swap-jvmArgs-order and give it a try, that would be helpful.

janbartel added a commit that referenced this issue Apr 13, 2021
Signed-off-by: Jan Bartel <janb@webtide.com>
janbartel added a commit that referenced this issue Apr 15, 2021
Signed-off-by: Jan Bartel <janb@webtide.com>
janbartel added a commit that referenced this issue Apr 29, 2021
)

* Issue #6153 Swap order of jetty maven plugin jvmArgs for EXTERNAL

Signed-off-by: Jan Bartel <janb@webtide.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants