I wanted to start the AP server and debug with just the Maven command

Introduction

As the title says, I wanted to build an environment where I could execute steps with just the Maven command **.

I didn't have enough resources to launch Docker or VM, so I couldn't wait to clone & checkout and build, but I still wanted to do runtime variable check and version difference verification.

So, I thought that I should try using the ancient ** Codehaus Cargo (hereinafter Cargo) **, so this article was written. I will.

It's a tool that has been around for a long time, and the content is now renewed as "Is it Maven nowadays?"

Requirements

--It is troublesome to keep the source at hand ** and build it ** -** The source on the application side cannot be tampered with ** (including pom.xml), change management is strict --I want to switch between different versions or start them at the same time ** -** Because there is no memory or room **, VMs and containers are a little ... --Even if you launch the IDE separately, you want to launch the app with one command. --The AP server is Jetty 9.4 series, which is light.

Things necessary

Prepare the following in advance.

And here is what I made

cargo-jetty-launcher - GitHub

It's sloppy, but it consists only of pom.xml and Jetty config file. Basically, the argument (-D option) at the time of executing the mvn command is used to do anything.

For the time being, the following command will run a sample application that just opens the data source ** org.codehaus.cargo: datasource-war **.

git clone https://github.com/Piecemeal-Technology-Inc/cargo-jetty-launcher.git
cd cargo-jetty-launcher
mvn initialize compile cargo:run

If you access http: // localhost: 8081 / change-context-root / test with your browser, you will see "Got connection!". The context root is controlled by context.path in pom.xml.

Let's debug

Launch VSCode and generate Java launch.json by "Run"-"Add Configuration". Therefore, add the following configuration to configurations.

launch.json


    {
       "type": "java",
       "name": "Debug (Remote 9990)",
       "request": "attach" , //Remote debug specification
       "projectName" : "cargo-jetty-launcher",
       "hostName": "localhost",
       "port": 9990, // pom.xml debug.Match with port property
       //Add a reference path to the source created under target
       "sourcePaths": [
           "${workspaceFolder}/target/sources-datasource-war.1.7.11/main",
           "${workspaceFolder}/target/sources-datasource-war.1.7.11/dependency"
       ]
    }

Now that the preparation is complete, you can execute steps by setting a breakpoint and starting the debugger.

ezgif-4-be77008fa52c.gif

  1. Start the server with mvn cargo: run
  2. target / sources-datasource-war.1.7.11 / main contains the source of war, so put a breakpoint where you want to stop.
  3. Debug the configuration created in launch.json
  4. Go to http: // localhost: 8081 / change-context-root / test
  5. Stop at the breakpoint! You can step in not only to the application side but also to the Jetty side source

in conclusion

※Caution ** This is a result of trial and error, so I don't think it's basically the theory street. ** ** If you use an embedded data source or don't include Jetty's own extension, it's okay if you do it normally as officially.

Since it is generalized to some extent with run-time arguments, it can be easily raised by preparing a command for each application you want to raise. In addition, since it does not have the substance such as source code, the execution environment can be expanded in PJ in a lightweight form.

I thought I'd write this story because I was really into Cargo, but I don't think there is any demand, so I'll omit it for the time being.

Prerequisites for use

In the first place, the war and source-jar to be run must be in the local repository or remote repository. If you don't debug, you don't need source-jar, just war.

Recommended Posts

I wanted to start the AP server and debug with just the Maven command
I want to bring Tomcat to the server and start the application
How to download and run a Jar package directly from the Maven repository with just the command line
I want to control the start / stop of servers and databases with Alexa
I want to pass the startup command to postgres with docker-compose.
The story I wanted to unzip
I want to return to the previous screen with kotlin and java!
I tried to build the environment of PlantUML Server with Docker
I tried to check the operation of gRPC server with grpcurl
I wanted to make JavaFX programming easier with the Spring Framework
I wanted to add @VisibleForTesting to the method
I tried to measure and compare the speed of GraalVM with JMH
After all I wanted to preview the contents of mysql with Docker ...
IDE and Maven compile with all debug information
When the server fails to start in Eclipse
I wanted to gradle spring boot with multi-project
I updated Node.js with nodebrew and scripted the routine to re-install npm install -g
Just plug in the storage and power to run the Raspberry Pi (Ubuntu Server Edition)
I tried what I wanted to try with Stream softly.
[wip] Server-side development comfortably and freely with the server
What to do if the Rails server can't start
I tried to read and output CSV with Outsystems
I started MySQL 5.7 with docker-compose and tried to connect
`Failed to create the host-only adapter` with docker-machine start`
I want to dark mode with the SWT app
HTTPS connection with Java to the self-signed certificate server
I want to transition screens with kotlin and java!
What I did to get out of the first wall I was assigned to the SRE team and bumped into, "What should I start with?"
I wanted to develop PHP with vscode remote container
When the server does not start with rails s
Until you build a project described in scala with Maven and execute it with the scala command.
Why can I use the rails command installed with gem? ??
I tried to increase the processing speed with spiritual engineering
I tried to summarize the basics of kotlin and java
Wait for the container service to start with docker healthcheck
Command to check the number and status of Java threads
I want to make a list with kotlin and java!
I want to call a method and count the number
I just wanted to make a Reactive Property in Java
I want to make a function with kotlin and java!
I tried to link chat with Minecraft server with Discord API
I want to distinct the duplicated data with has_many through
How to run React and Rails on the same server
I want to implement various functions with kotlin and java!
I tried upgrading from CentOS 6.5 to CentOS 7 with the upgrade tool
Technical causes and countermeasures for the points I was addicted to with the first Android app & Kotlin
I tried to express the result of before and after of Date class with a number line
[Spring Boot] I want to add my own property file and get the value with env.getProperty ().
Since the Rspec command is troublesome, I tried to make it possible to execute Rspec with one Rake command