Category Archives: maven

Maven Surefire PermGen error

In case you are getting PermGen error while running tests using the Maven Surefire plugin, here is the solution:

    <argLine>-Xmx512m -XX:MaxPermSize=256m</argLine>

Setting the JVM args as part of the plugin did the trick!

Setting MAVEN_OPTS would not help because Maven Surefire plugin forks the JVM process while running the tests, and so the MAVEN_OPTS settings do not take effect.


If you work in a corporate behind a firewall, most likely you would need to configure proxy for any of the dev tools that talk to the internet. The write-up below talks about configuring proxy for:

  • Maven – Build and management tool for any Java-based project
  • Git – Distributed version control system
  • npm – Node Packaged Modules (Package manager for Node.js)
  • Bower – Front-end package manager

In order to work with any of the above tools, you would need to have access to the internet. And if your company/client uses a proxy server, you would need to configure these tools to use that proxy in order to talk to the internet.

  • Maven

Add the following section in your maven settings.xml (typically located at ${user.home}/.m2/settings.xml).


For a detailed description on the different settings, please refer to this link.

  • Git

For using git over HTTP, execute the following command.

git config --global http.proxy http://<proxy_server>:<proxy_server_port>
  • npm

Execute the following command. You might want to put it as part of your .bash_profile (for bash) or the profile file of your favorite shell so that you do not need to set it up whenever you open up a new command shell.

npm config set proxy http://<proxy_server>:<proxy_server_port>
  • Bower

Set the following environment variable:  HTTP_PROXY or HTTPS_PROXY (as per your needs).

export HTTPS_PROXY=http://<proxy_server>

Again, you might would want to put it as part of your .bash_profile (for bash). In case of windows, add a new User environment variable.

Maven Exec Plugin vs Maven AntRun Plugin for running command-line tool

Maven Exec Plugin supports the following two goals:

  1. exec: to execute external programs (including Java) in a separate process
  2. java: to execute Java programs in the same JVM

Maven AntRun Plugin supports only one goal:

  1. run: to execute the Ant target specified

If you have a requirement to run a command-line tool, e.g. cURL, in an synchronous (blocking) way, you can use the Maven Exec Plugin (exec goal). However, in case you need to run it in an asynchronous (non-blocking) fashion, you can use the Ant exec task (with ‘spawn’ option set as true) with Maven AntRun Plugin. You might want to consider something like this before executing the integration tests which could be dependent on the database being in a clean state. Here is an example:

  • Using Maven Exec Plugin
      <id>drop DB => db_name</id>
  • Using Maven AntRun Plugin
      <id>drop DB => db_name</id>
          <exec executable="curl">
            <arg value="-s" />
            <arg value="-S" />
            <arg value="-X" />
            <arg value="DELETE" />
            <arg value="http://${db.server}:${db.port}/db_name" />
            <spawn value="true">