java 8 using jboss5

If you need to run your app on jboss5 and using jdk8  you will get error

3:53:10,693 ERROR [AbstractKernelController] Error installing to Instantiated: name=AttachmentStore state=Described
java.lang.IllegalArgumentException: Wrong arguments. new for target java.lang.reflect.Constructor expected=[] actual=[]
    at org.jboss.reflect.plugins.introspection.ReflectionUtils.handleErrors(
    at org.jboss.reflect.plugins.introspection.ReflectionUtils.newInstance(
    at org.jboss.reflect.plugins.introspection.ReflectConstructorInfoImpl.newInstance(


You need to modify “profile.xml” and add class=”” into paramater element

<bean name="AttachmentStore" class="org.jboss.system.server.profileservice.repository.AbstractAttachmentStore">
<parameter class="">
<inject bean="BootstrapProfileFactory" property="attachmentStoreRoot" />




unable to find valid certification path to requested target

It is always preferred to use https instead of http (specially when using passwords and so on…)

We have switched our SonarQube (tool for Continuous Inspection of code quality) to use https for security reasons. Anyway I have noticed that Jenkins stop sending new quality codes to our sonar. When I have checked the logs I have seen this stacktrace:

Exception in thread "main" java.lang.IllegalStateException: Fail to request server version
	at org.sonar.runner.Bootstrapper.getServerVersion(
	at org.sonar.runner.Runner.checkSonarVersion(
	at org.sonar.runner.Runner.execute(
	at org.sonar.runner.Main.execute(
	at org.sonar.runner.Main.main(
Caused by: PKIX path building failed: unable to find valid certification path to requested target
	at org.sonar.runner.Bootstrapper.remoteContent(
	at org.sonar.runner.Bootstrapper.getServerVersion(
	... 4 more

So here you can see that Jenkins has problem to “handshake” ssl certificate.

follow these steps:


Search google – it originally was done in Sun, but you can find this program on google codes or somewhere else. You can even download binaries of this file.

Add Trusted Keystore

Run “” on server (where you run your https service). something like java InstallCert localhost:443 -> press “1”  when asked. It will add your “localhost” as a trusted keystore, and generate a file named “jssecacerts“.

[user@sonar ~]$ java InstallCert localhost:443
Loading KeyStore /usr/java/jdk1.6.0_37/jre/lib/security/cacerts...
Opening connection to localhost:443...
Starting SSL handshake..
Server sent 1 certificate(s):
1 Subject CN=Unknown, OU=Unknown, O=Vendavo, L=Unknown, ST=Czech republic, C=CZ
Enter certificate to add to trusted keystore or 'q' to quit: [1]
Added certificate to keystore 'jssecacerts' using alias 'localhost-1'

I have removed most of the parts but the main parts are here:

a) press 1 when assked – you agree to add certificate for this domain into keystore

b) it created jssecacerts file

Verify Trusted Keystore

Run same command again 🙂  (this is full export – removed hashed data)

[mchowaniok@sonar ~]$ java InstallCert
Loading KeyStore jssecacerts...
Opening connection to
Starting SSL handshake...
No errors, certificate is already trusted
Server sent 1 certificate(s):
1 Subject CN=Unknown, OU=Unknown, O=Vendavo, L=Unknown, ST=Czech republic, C=CZ
 Issuer CN=Unknown, OU=Unknown, O=Vendavo, L=Unknown, ST=Czech republic, C=CZ
Enter certificate to add to trusted keystore or 'q' to quit: [1]
KeyStore not changed

Copy jssecacerts

copy jssecacerts file into java/jre/lib/security folder (I had to done it under sudo )

[user@sonar ~]$ sudo cp jssecacerts /usr/java/default/jre/lib/security/


verify it 🙂   in my case, run Jenkins job and verify data are uploaded to Sonar.

HSQLDB – some tips

I have been working these days with Spring3 and as DB I have used HSQLDB.

Types of catalog data

  • mem: stored entirely in RAM – without any persistence beyond the JVM process’s life
  • file: stored in filesystem files
  • res: stored in a Java resource, such as a Jar and always read-only

so the URL in java or spring context would looks like this:


Turning on HSQLDB GUI in eclipse

in eclipse find the hsqldb.jar (usually lib folder) -> do right click and select “run as java” -> from the list select “DatabaseManagerSwing”

Get rid of “The database is already in use by another process”

For this error I have heard that you should use “shutdown=true” syntax in URL. So this would look like :

"jdbc:hsqldb:file:testdb;shutdown=true"  everything put in one single line (doc)


That’s it. more can be found in google or HSQLDB doc.

google code with git

google code allows to use SVN to access the code and I was wondering whether there is way to access code with git.

  • Import
$ git svn clone --username your-name -s
few other commands
git log
git diff HEAD^^
  • Developing
git add filename
git rm  filename
git commit -a     => commits to local repository
git push          => sends to server repository
  • Update – get online and check latest changes from google code
git svn rebase
  • Export – sends commits to google code
git svn dcommit       => sends commit
  • Other useful commads:
git branch -a         => shows all branches

You have noticed that svn command connected with git “git svn”. This is as already written google supports SVN, but git can comunicate “SVN” way 🙂

You can read more here. For GIT tutorial check git pages or this tutorial.

You can use “egit” plugin to connect your eclipse to git repository.

So summary time - equivalent svn/git commands - Git for SVN User

svn checkout $SVNREP/trunk -> git svn clone $SVNREP -T trunk -b branches -t tags svn checkout $SVNREP/branches/release-0.3 -> git checkout -b local/release-0.3 release-0.3 svn commit -> git commit -a, or git add then git commit followed by git-svn dcommit svn diff|less, svn commit -> git commit -v svn merge -> git cherry-pick or use "gitk --all" svn status -> git status svn revert, --recursive -> git checkout , git checkout -f or git reset --hard svn diff -> git diff svn update -> git svn rebase --all (see also git stash)

authentication against google in java

Google, Yahoo and others allows to authenticate users using OpenID protocol. Some pages are here and openid4j .

In my last post I have mentioned about google data libraries which is actually APIs for most of the google services, including to authenticate users and much more. GData libraries are let’s say higher level layer which handles all the openid pain for you. 2 simple lines of code and you are authenticate 🙂

Here is simple example


<project xmlns="" xmlns:xsi=""xsi:schemaLocation="">



Simple java project:

package com.majecek.gdata;

public class App
 public static void main( String[] args )
 GoogleService myService = new CalendarService("some_apps");
 try {
 myService.setUserCredentials("userLogin".concat(""), "password");
 //if success then succes authentication occures
 System.out.println("success authentication");
 } catch (AuthenticationException e) {
 //if not then invalid credentials has been set
 //invalid username or password
 System.out.println("invalid authentication");

Example can be downloaded from google code repository. It is maven project.

I have updated and uploaded this example to github. Read README.

The bigest advantage is that we don’t need to handle any “openid” tricks, just creates service against google service (in my example Calendar) and call “setUserCredentials” which already authenticate user.

Credits go also @Petr Olivka

google data libraries in maven

I wanted to create new project and used google data libraries (…) and connect with maven2.

Even though Google has these libraries as opensource, it is not in maven repository. Anyway there is project which added these google libraries into maven into google code.

Here is example of pom.xml (repository & libary dependency)

<project> ..


As you can see you can add google libraries according your needs. If you don’t know the full name and version of the library you want to use – check it here .

App Engine supports JAVA, thank you Google !

Big day was yesterday 7th April in AppEngine world.

Their most requested feature has been delivered by google folks. They support not only Python but now also Java.

Read more here.

GWT using maven2

I was trying to set up gwt with maven2. And here is tutorials how to do it.

We will use little help. There is already gwt archetype for maven2. (you don’t have to use it. You are fine with maven default war project archetype but set up your project correctly)

  1. Download this file (it is for version 1.4.59, but by changing the pom you can get the newest version (which is at the time of writing 1.4.61)
  2. unzip file
  3. install it to your repository “mvn install”

Use the archetype to create maven gwt skelet.

mvn archetype:create -DarchetypeGroupId=com.totsp.gwt -DarchetypeArtifactId=gwt-archetype -DarchetypeVersion=1.0-SNAPSHOT -DartifactId=gwt-using-archetype

Next we will modify pom.xml

  • change version for gwt-user and gwt-servlet (at the time of writing it is 1.4.61)
  • change element <compileTarget> to <compileTargets> also for closing element </compileTargets>
  • last thing is to tell where is your gwt installation. So add <gwtHome> element (here is example:

This is very “hardcoded” and it is suggest to define it in ~/.m2/settings.xml (use either way) and here is example of settings.xml

<?xml version=”1.0″ encoding=”UTF-8″?>
     <!–- XstartOnFirstThread needed only on the mac -–>

OK and now we are ready to try our example. Run ‘mvn gwt:gwt’ and it will launch browser with your application. By using archetype you are up and running in few minutes.

If you want to integrate it with jetty just run ‘mvn jetty:run-exploded’ and open localhost:8080.

Few tips:

  • polish tutorial with little bit different approach
  • tutorial I studied from
  • Multi project in maven with GWT – use svn to check out code on your local computer and run it

Source code can be downloaded from here.