Friday, August 30, 2013

svn: E160005: Invalid control character '0x08' in path 'dist.xml'

When following errors appears during SVN committing:
svn: E160005: Invalid control character '0x08' in path 'dist.xml'
than problem is 'dist.xml' file name. File name contains some invisible character that cause this problem. Solution is to rename file.

Saturday, June 1, 2013

BLOB/TEXT column 'description' used in key specification without a key length

This post is not about solving some problem. Sadly I don't know hot to solve following problem. There are just work arounds. I have following configuration:
MySQL: 5.5.27
hibernate dialect: org.hibernate.dialect.MySQLInnoDBDialect
hibernate: 3.6.9
In my model I have entity with following attribute:
@Entity
@Table(name = "site")
public class Site extends AbstractEntity {
    
    ...
     
    @Column(unique = true, nullable = true, length = 1024 * 100)
    private String description;
    
    ...
     
}
When I run program follow error appears in logs and table site is not created.
2013-06-01 12:15:24 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - 
Unsuccessful: create table site (id_site integer not null auto_increment, description longtext unique, name varchar(250) unique, url_pattern longtext not null unique, id_image integer, primary key (id_site)) ENGINE=InnoDB
2013-06-01 12:15:24 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate - 
BLOB/TEXT column 'description' used in key specification without a key length
Problem is that column 'description' is marked as unique. In InnoDB maximum length of key could be just 767 characters for a single-byte charset like LATIN1 and only 255 characters for UTF8. Look at possible workarounds:
  1. avoid indexes, don't use unique = true
  2. make column length smaller (255) characters for UTF8
  3. compute hash from long column store in in another column and create index on hash column


If you'll have some other possible solution than please let me know.

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.

Wednesday, April 24, 2013

Post data with curl when you are behind proxy

I found that SoapUI 4.5.1 have so problems to access some web service endpoint when you are behind proxy. It seems that your authentications is not processed correctly, my proxy server always return HTTP error 407. So I started to play with 'curl' command. Let me show ho to do that:
curl -v --proxy proxy.something.com:8080 --proxy-user myname:password \
 --request POST \
 --header "Content-Type: text/xml;charset=UTF-8" \
 --header "SOAPAction: http://somesite.com:80/adistc/axis2/services/interaface/getAvailableNames" \
 --data @request.txt \
 http://somesite.com:80/adistc/axis2/services/interaface/
Most of parameters are self explaining. Note that @ in parameter --data means that posted data should be find in file 'request.txt'. Headers are not necessary. Obviously in request.xml is your soap XML request. Switch -v shows you request and response data.

Saturday, April 6, 2013

MySQL and Hibernate exception

Following exception made me some problem.
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
        at java.lang.Thread.run(Thread.java:662)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/err


** BEGIN NESTED EXCEPTION **

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
MESSAGE: Communications link failure

Last packet sent to the server was 18788 ms ago.

STACKTRACE:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 18788 ms ago.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
        at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
        at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2985)
        at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2871)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3414)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
        at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
        at org.hibernate.loader.Loader.doQuery(Loader.java:802)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
My environment was MySQL 5.0.77, Java 1.6.0_24-b07, Apache Tomcat 6.0.32, Hibernate 3.6.0.Final.
This exception never occurs at development or continues integration environment. This problem appears just in production after one day of running without application restart. After some time of testing JDBC connection handling, TCP/IP connection to MySQL database I found that problem is caused by incorrect hibernate dialect configuration
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
After correcting to:
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
everything works fine.