How to test EJB apps with Glassfish embedded container

There are many articles about EJB deploying and testing. But after one of my colleagues spent a week trying to make it work, I decided to write my own. I’ll describe the wrong path first and then correct it.

Continue reading How to test EJB apps with Glassfish embedded container


How to use TestNG in Gradle project

A statement: IntelliJ IDEA likes JUnit. Thing is, it’s gonna try to use JUnit even if you create a test with TestNG selected in settings. When you are ready to run your tests, you are probably about to encounter the following error: Test filtering is not supported for given version of JUnit. Please upgrade JUnit version to at least 4.6. Here is what needs to be done in this case:

  1. (optional) Add TestNG as Gradle dependency. At this moment you probably have it added by pressing ‘Fix’ button in ‘Create test’ dialog window. This is not a required step, I just prefer to have all the dependencies in one place.
  2. Explicitly tell Gradle to use TestNG as a testing framework.

Here’s how the modified build.gradle will look like:

apply plugin: 'java'
repositories {
dependencies {
testCompile 'org.testng:testng:6.9.4'
test {

How to fix “Unable to start the daemon process” error in IntelliJ IDEA

There is another strange error that encounters from time to time at the start of IntelliJ IDEA. Gradle refuses to sync project with a following text:


I’ve found a good solution for it here, but it is for Eclipse. Some further analysis indicated that problem is actually in the insufficient amount of available RAM. After closing web browser (500 mb RAM to free) and pressing “Try Again” link in IDEA project has synced without any issues.

How to fix “Multiple dex files define” error in IntelliJ IDEA

There is one strange error I have encountered while trying to build an Android application with IntelliJ IDEA. Gradle crashed with a mysterious message: UNEXPECTED TOP-LEVEL EXCEPTION: Multiple dex files define. There are several solutions available for Eclipse and several solutions available for IDEA (this one is my favorite), but none of them worked in my case.

This error started to come up after updating IDEA Gradle plugin from 0.6.+ to 0.7.+ (and corresponding Gradle distribution from 1.8 to 1.9). To verify which plugin version you are using, look at the following line in the build.gradle:

dependencies {
classpath ''

Next thing I found during my investigation to solve this error was the folder named “.gradle” in the project dir. Its content actually clarified much. In this folder Gradle kept task artifacts for building process, both 1.8 and 1.9. Somehow it was causing build conflict. Deleting this folder did the trick, Gradle has recreated it with newer artifacts only and that solved the entire problem.

UPD: Today IDEA suggested to migrate my projects to plugin version 0.9.+ and Gradle version 1.11 due to some breaking changes. No errors this time.