Cannot start hsqldb server via maven exec plugin

I am trying to start the hsqldb server for use for development purposes. I had a hsqldb dependency:

<dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>2.2.4</version> </dependency> 

I had a built-in exec-maven-build:

 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <mainClass>org.hsqldb.server.Server</mainClass> <arguments> <argument>--database.0 file:target/monitoring</argument> </arguments> </configuration> </plugin> 

And I run mvn exec: java, the server starts, and I have this error:

 [ Server@6e9770a3 ]: [Thread[org.hsqldb.server.Server.main(),5,org.hsqldb.server.Server]]: Failed to set properties org.hsqldb.HsqlException: no valid database paths: maformed database enumerator: server.database.0 mem:monitoring 

I am looking through the code what this error means, and I found the error code in hsqldb on this page => http://hsqldb.svn.sourceforge.net/viewvc/hsqldb/base/tags/2.2.5/src/org/hsqldb /server/Server.java?revision=4369&view=markup

 private IntKeyHashMap getDBNameArray() { final String prefix = ServerProperties.sc_key_dbname + "."; final int prefixLen = prefix.length(); IntKeyHashMap idToAliasMap = new IntKeyHashMap(); Enumeration en = serverProperties.propertyNames(); for (; en.hasMoreElements(); ) { String key = (String) en.nextElement(); if (!key.startsWith(prefix)) { continue; } int dbNumber; try { dbNumber = Integer.parseInt(key.substring(prefixLen)); } catch (NumberFormatException e1) { **printWithThread("maformed database enumerator: " + key);** continue; } String alias = serverProperties.getProperty(key).toLowerCase(); if (!aliasSet.add(alias)) { printWithThread("duplicate alias: " + alias); } Object existing = idToAliasMap.put(dbNumber, alias); if (existing != null) { printWithThread("duplicate database enumerator: " + key); } } return idToAliasMap; } 

So hsqldb uses the whole argument as a key: "There are no valid database paths: database enumerator: server.database.0 mem: monitoring "

So this seems like a mistake, or did I do something wrong?

OK, I found a solution, I changed the way I provide the arguments for the exec maven plugin.

from this:

 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <mainClass>org.hsqldb.server.Server</mainClass> <arguments> <argument>--database.0 file:target/monitoring</argument> </arguments> </configuration> </plugin> 

:

 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <mainClass>org.hsqldb.server.Server</mainClass> <arguments> <argument>--database.0</argument> <argument>file:target/monitoring</argument> </arguments> </configuration> </plugin> 

And he works

+4
source share
2 answers

I changed the way arguments are passed to the exec maven plugin

from this:

 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <mainClass>org.hsqldb.server.Server</mainClass> <arguments> <argument>--database.0 file:target/monitoring</argument> </arguments> </configuration> </plugin> 

:

 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <mainClass>org.hsqldb.server.Server</mainClass> <arguments> <argument>--database.0</argument> <argument>file:target/monitoring</argument> </arguments> </configuration> </plugin> 

And he works

+9
source

I found out that if you need to run HSQL in server mode with maven and continue to run integration tests, you should use the maven-antrun-plugin and ant Java task since exec-maven-plugin does not support branching mode:

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <dependencies> </dependencies> <executions> <execution> <phase>pre-integration-test</phase> <configuration> <target> <property name="test_classpath" refid="maven.test.classpath" /> <java classname="org.hsqldb.server.Server" fork="yes" spawn="yes"> <arg line="--database.0 mem:test --dbname.0 test" /> <classpath> <pathelement path="${test_classpath}" /> </classpath> </java> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> 

it is assumed that your hsqldb dependency has a scope of validation.

+3
source

All Articles