Wednesday, May 22, 2013

Useful MySQL commands

This is not MySQL tutorial. It's just list of useful SQL statements that I don't remember and I don't want to google them anymore. SQL commanda are also in basic form. For more detail see original MySQL documentation.

Create new user with login name 'userName' with password 'passwd'. Created use have access to all tables in database 'testDb'.

GRANT ALL PRIVILEGES ON testDb.* TO 'userName'@'host' IDENTIFIED BY 'passwd';

Create new database with default text columns encoding.

CREATE SCHEMA `testDb` DEFAULT CHARACTER SET utf8 ;

Set password for user 'sa' accessing from localhost to 'be'.

SET PASSWORD FOR sa@localhost = PASSWORD('be');

Create SQL file containing all data form database. It's useful for creating backups and for copying data from one db into another one.

mysqldump --add-drop-table -u sa -psa bl > bl.sql

Tuesday, May 21, 2013

jetty-maven-plugin - ERROR: Cannot override read-only parameter: contextPath in goal: jetty:run

Following error started appear in logs:
[artifact:mvn] [INFO] [compiler:testCompile {execution: default-testCompile}]
[artifact:mvn] [INFO] No sources to compile
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [ERROR] BUILD ERROR
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] Error configuring: org.mortbay.jetty:jetty-maven-plugin. Reason: ERROR: Cannot override read-only parameter: contextPath in goal: jetty:run
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] For more information, run Maven with the -e switch
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] Total time: 10 seconds
[artifact:mvn] [INFO] Finished at: Tue May 21 14:00:42 CEST 2013
[artifact:mvn] [INFO] Final Memory: 44M/91M

Problem is in pom.xml in jetty-maven-plugin configuration. If there is:

    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>8.1.5.v20120716</version>
        <configuration>
            <webAppSourceDirectory>${webappDirectory}</webAppSourceDirectory>
            <contextPath>/admin</contextPath>
            ...
        </configuration>
    </plugin>

Than problem is in maven jetty plugin configuration. According to current jetty configuration tag contextPath should be placed inside tag webAppConfig. See following example:

    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>8.1.5.v20120716</version>
        <configuration>
            <webAppSourceDirectory>${webappDirectory}</webAppSourceDirectory>
            <webAppConfig>
                <contextPath>/admin</contextPath>
            </webAppConfig>
            ...
        </configuration>
    </plugin>

Also see original maven jetty plugin configuration documentation at http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin.

Friday, May 17, 2013

BRMS 5.3.1 Exception "Could not find work item handler for"

At the veri beginning of my trying BRMS I met following exception:
org.drools.WorkItemHandlerNotFoundException: Could not find work item handler for 
 at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.throwWorkItemNotFoundException(JPAWorkItemManager.java:62)
 at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.internalExecuteWorkItem(JPAWorkItemManager.java:57)
 at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:107)

This exception is raised when you created Task but you didn't define TaskType. In another words there is created task but is not specified what should be done.

Following image shows JBoss BRMS Process Designer where was process created.

On next image is Task property that have to be set to "Script" value. You can also fill property "Script" in section "Extra" with value "System.out.println("\nHello World!\n");" than Task will write message to JBoss console.