The project is ready to start the application in GWT SuperDevMode. In SuperDevMode, the client side of the application is served by GWT’s CodeServer, which can quickly recompile changes made in the source files in your IDE and serve the updated client upon browser refresh. On the other hand, the webapp is deployed to an AppServer running in a separate process and only provides the server side of the application. This way it is possible to reduce the refresh time during development either by just refreshing browser window to get client code changes or by just redeploying the webapp (without recompiling the client) to see backend changes.
Additionally, the GWT Maven plugin is configured to produce source maps which allow to browse the Java source files, set breakpoints and inspect variables using the Developer tools in Chrome.
$ mvn clean install -Dgwt.skipCompilation
We can skip GWT compilation because it will be done anyway by the CodeServer when accessing the application from browser for the first time.
$ mvn gwt:codeserver -pl optaplanner-wb-ui -am
The process will keep running in the foreground and thus will occupy the terminal window.
It’s recommended to do this in a different terminal window.
$ cd optaplanner-wb-webapp
$ mvn wildfly:start wildfly:deploy-only
Open http://localhost:8080/optaplanner-wb/ in your web browser.
Enter admin:admin
credentials.
Users, their passwords and roles are configured by the PicketLinkDefaultUsers
server bean.
You need to create two separate Run configurations for CodeServer and webapp deployment.
-
Open the Run/Debug Configurations window by choosing Run > Edit Configurations…
-
Click Add New Configuration (green plus button), select Maven.
-
Fill the following fields in Parameters tab:
-
Working directory:
/absolute/path/to/optaplanner-wb
-
Command line:
gwt:codeserver -pl optaplanner-wb-ui -am
-
-
Open the Run/Debug Configurations window by choosing Run > Edit Configurations…
-
Click Add New Configuration (green plus button), select JBoss Server > Local.
-
Choose a name, e.g. OptaPlanner WB WildFly.
-
Click Configure… to create a new Application server.
-
Click
+
and set JBoss Home to point to/absolute/path/optaplanner-wb/optaplanner-wb-webapp/target/wildfly-14.0.1.Final
-
Click the Fix… button next to the "No artifacts marked for deployment" warning and select
optaplanner-wb-webapp exploded
.ImportantAfter adding the deployment, remove all build steps that were added to the Before launch phase. It is necessary to skip the build to avoid overwriting the index page "injected" by CodeServer. -
On the Server tab, select Update classes and resources for both On 'Update' action and On frame deactivation.
Update action is triggered by clicking a blue arrow button next to the server output window.
Frame deactivation happens when you switch from IDEA window to the web browser.
-
Enable client code debugging:
-
Check After launch and select Chrome.
-
Check with JavaScript debugger. This will allow you to debug client code from IDEA.
-
Enter
http://localhost:8080/optaplanner-wb-webapp
as the start URL.
-
-
Run the CodeServer configuration.
-
Run or Debug the AppServer configuration.
Running the AppServer configuration in Debug mode will allow you to set breakpoints and step through both backend and client code.
If for some reason you can’t run SuperDevMode in IDEA,
it is possible to debug client code using Chrome’s Developer tools (Ctrl + Shift + I
).
You can undock the Developer tools window, which is useful if you have two monitors.
Now you can open any client-side Java source file with Ctrl + P
and debug with breakpoints.
Add the upstream workbench projects too, because you might want to make changes on those too:
-
Git clone:
guvnor
,kie-wb-common
,drools-wb
too (besidesoptaplanner-wb
). -
Import them all in the same IntelliJ project.
-
Make sure to use Maven Projects > Reimport All Maven Projects and Maven Projects > Generate Sources and Update Folders for All Projects to update module dependencies.
-
Configure a GWT configuration as mentioned above.
-
It is likely going to crash with
Too many open files
in IntelliJ on linux.-
Use this to fix that:
$ sudo echo "fs.inotify.max_user_watches = 8388608" >> /etc/sysctl.conf $ sudo echo "fs.inotify.max_user_instances = 8388608" >> /etc/sysctl.conf $ sudo sysctl -p ... (no errors) $ ulimit -n 1024 $ sudo echo "* soft nofile 102400" >> /etc/security/limits.conf $ sudo echo "* hard nofile 102400" >> /etc/security/limits.conf $ sudo reboot $ ulimit -n 102400
-
-
If you want to build or contribute to a kiegroup project, read this document.
It will save you and us a lot of time by setting up your development environment correctly. It solves all known pitfalls that can disrupt your development. It also describes all guidelines, tips and tricks. If you want your pull requests (or patches) to be merged into main, please respect those guidelines.