/optaplanner-wb

OptaPlanner workbench 7.x: OptaPlanner extensions to the KIE Workbench

Primary LanguageJava

Quick development start

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.

Running SuperDevMode from command line

1. Build the whole project

$ 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.

2. Launch CodeServer

$ mvn gwt:codeserver -pl optaplanner-wb-ui -am

The process will keep running in the foreground and thus will occupy the terminal window.

3. Launch backend

It’s recommended to do this in a different terminal window.

$ cd optaplanner-wb-webapp
$ mvn wildfly:start wildfly:deploy-only

4. Open the WebApp

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.

5. Shut down

Shut down CodeServer with SIGTERM (Ctrl+Z).

Shut down WildFly by running

$ mvn wildfly:shutdown

Running SuperDevMode from IntelliJ IDEA

You need to create two separate Run configurations for CodeServer and webapp deployment.

Add CodeServer Run configuration

  1. Open the Run/Debug Configurations window by choosing Run > Edit Configurations…​

  2. Click Add New Configuration (green plus button), select Maven.

  3. Fill the following fields in Parameters tab:

    • Working directory: /absolute/path/to/optaplanner-wb

    • Command line: gwt:codeserver -pl optaplanner-wb-ui -am

Add AppServer Run configuration

  1. Open the Run/Debug Configurations window by choosing Run > Edit Configurations…​

  2. Click Add New Configuration (green plus button), select JBoss Server > Local.

  3. Choose a name, e.g. OptaPlanner WB WildFly.

  4. Click Configure…​ to create a new Application server.

  5. Click + and set JBoss Home to point to /absolute/path/optaplanner-wb/optaplanner-wb-webapp/target/wildfly-14.0.1.Final

  6. Click the Fix…​ button next to the "No artifacts marked for deployment" warning and select optaplanner-wb-webapp exploded.

    Important
    After 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.
  7. 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.

  8. Enable client code debugging:

Run SuperDevMode

  1. Run the CodeServer configuration.

  2. 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.

Advanced development instructions

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 (besides optaplanner-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

Developing Drools, OptaPlanner and jBPM

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 master, please respect those guidelines.