0. OpenTCS Local Debugging and Development Environment Setup
OpenTCS Local Debugging and Development
This article briefly introduces local development debugging for OpenTCS.
Environment Preparation
- We're using OpenTCS 5.x, due to legacy project constraints, higher versions are not considered for now.
- OpenJDK must be 13.x, please pay special attention
- If you want to develop GUI interfaces, you must use Netbeans IDE for development, because OpenTCS uses visual components where many are Netbeans-specific Swing components that cannot be opened in other IDEs like IntelliJ IDEA.
Known Resource Links
Quickly Establish Debuggable Environment
- Download the compiled binary package of the same version and the corresponding source code. We can quickly establish debugging without compilation.
- If on Windows platform, regardless of which component you're debugging, it's recommended to modify
start.cmd
[if the default Java is already 13.x, no modification needed], but for safety, it's recommended to modify the Java command in start.cmd to use the absolute path to Java to avoid mysterious issues.
# Modify
set JAVA=javaw
# To absolute path Java
set JAVA="xxxx/javaw.exe"
- Add breakpoints to the program for remote debugging [configuration method is basically the same for each component type, make sure exposed ports don't conflict]
# Modify startup parameters:
start /b %JAVA%
# Modify to:
start /b %JAVA% -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:2333
At this point, connect remotely to port 2333 in your IDE to establish debugging.
If the code you need to debug automatically initializes at startup, change suspend=n to suspend=y
Startup Exception Troubleshooting
Sometimes, you'll encounter tricky problems that manifest as: controllers, operation panels, etc. completely unable to start. After executing start.cmd to launch, the interface flashes by and cannot start normally. There are two ways to troubleshoot (generally these 2 methods can troubleshoot all serious problems).
ctbots.com plans to release some toolkits specifically for OpenTCS later.
General Problem Log Observation
If the problem is not very serious, meaning the Java program starts but exits due to code logic reasons, there are usually log files to check. Generally in the log directory of the same directory as the start.cmd startup script.
Log files may roll by date, just check the latest log.
Serious Problems - Modify javaw
There may be very serious problems, such as: missing jar packages, class or method not found, serialization failures, incorrect Java startup parameters, etc. These manifest as: the program crashes immediately upon startup due to program integrity issues, before printing any log files. At this point, there are no logs to query. The handling steps are as follows:
- Use cmd command to start in the black and white console, at this point if there are errors, they won't flash by. Don't double-click cmd to start.
- Or modify the start.cmd script, change javaw.exe to java.exe. The difference between java and javaw is: java outputs standard stream information to the console, javaw disables standard stream input/output. Then manually start in cmd to observe specific error information.
I Want to Compile It Myself
If you want to compile it yourself, the first obstacle is gradle. People switching from Maven will find it strange why gradle compatibility is so poor. Without proper network access and without any configuration, compilation is almost impossible.
Modify Gradle Binary Package Download Address
Find the gradle-wrapper.properties file in the project and modify the configuration as follows:
distributionUrl=https://mirrors.cloud.tencent.com/gradle//gradle-8.7-bin.zip
Note: it doesn't have to be gradle-8.7-bin.zip, it needs to be dynamically replaced according to the original gradle version.
Configure Gradle Download Acceleration
Then, find gradle.properties in the project to configure acceleration mirrors
# Alibaba Cloud Maven Mirror
repositories.grails.default = https://maven.aliyun.com/repository/public
# Optional, you can add other sources
repositories.grails.default.1 = https://mirrors.tuna.tsinghua.edu.cn/maven/repos/public