Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 1.4
-
Fix Version/s: None
-
Labels:None
-
Environment:Mac OS X 10.6.3
Maven 2.2.1
Java 1.6.x
-
Number of attachments :2
Description
Actually, I tried to use the version 1.4 of the sql-maven-plugin with this configuration:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://localhost:3306</url>
<username>userWeUsed</username>
<password>passwordWeUsed</password>
<autocommit>true</autocommit>
<srcFiles>
<srcFile>target/classes/update.sql</srcFile>
</srcFiles>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.13</version>
</dependency>
</dependencies>
</plugin>
The request is the following one:
UPDATE
`databaseToUpdate`.`tableToUpdate`
SET
`XMLCONFIGURATION` = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlConfiguration>
<params>
<entry>
<key>keyOne</key>
<value>valueOne</value>
</entry>
<entry>
<key>keyTwo</key>
<value>valueTwo</value>
</entry>
<entry>
<key>keyThree</key>
<value>valueThree</value>
</entry>
</params>
</xmlConfiguration>'
WHERE
`NAMESPACE` = 'system';
With version 1.1 or 1.3 of the sql-maven-plugin, the request goes well. With the version 1.4, the result is the following:
------------------------------------------------------------------------
[ERROR]BUILD ERROR
------------------------------------------------------------------------
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlConfiguration>
<p' at line 4
------------------------------------------------------------------------
Trace
org.apache.maven.lifecycle.LifecycleExecutionException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlConfiguration>
<p' at line 4
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlConfiguration>
<p' at line 4
at org.codehaus.mojo.sql.SqlExecMojo.execute(SqlExecMojo.java:646)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlConfiguration>
<p' at line 4
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:409)
at com.mysql.jdbc.Util.getInstance(Util.java:384)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2562)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2512)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:781)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:624)
at org.codehaus.mojo.sql.SqlExecMojo.execSQL(SqlExecMojo.java:1011)
at org.codehaus.mojo.sql.SqlExecMojo.runStatements(SqlExecMojo.java:975)
at org.codehaus.mojo.sql.SqlExecMojo.access$200(SqlExecMojo.java:66)
at org.codehaus.mojo.sql.SqlExecMojo$Transaction.runTransaction(SqlExecMojo.java:1207)
at org.codehaus.mojo.sql.SqlExecMojo$Transaction.access$100(SqlExecMojo.java:1154)
at org.codehaus.mojo.sql.SqlExecMojo.execute(SqlExecMojo.java:612)
... 19 more
I tried to use some configuration values of the plugin without success.
-
- build.log
- 03/Aug/10 2:29 AM
- 56 kB
- Laurent Prévost
-
- MSQL-59-IT.patch
- 30/Jul/10 3:24 PM
- 2 kB
- Robert Scholte
Activity
The file does not changed between the different tries (version 1.1, 1.2, 1.3 and 1.4). There are other update requests done correctly in the same file.
Examples:
UPDATE
`databaseToUpdate`.`tableToUpdate`
SET
`fieldOne` = 'valueOne',
`fieldTwo` = 'valueTwo'
WHERE
`ID` = 1;
There are three other similar request done correctly (I see the output with the option printResultSet that the request before the one that causes the exception are done properly).
For the quotes (` for field, table and database names, ' for strings), they come from MySQL statements used through tools like phpMyAdmin.
So if the quotes are illegal characters, it seems to be an inconsistent behavior between some request in the same files. We use these quotes in all our requests (we have more than one sql file with a lot of SQL statements).
In addition, I just did a test without the special quotes and it does not work. It produces the same exception.
It seems that I previously forget to provide some usefull data about the database product and version:
database name=MySQL
database version=5.1.48-log
database major version=5
database minor version=1
jdbc driver name=MySQL-AB JDBC Driver
jdbc driver version=mysql-connector-java-5.1.13 ( Revision: $
)
jdbc driver major version=5
jdbc driver minor version=1
I also tried different MySQL connectors (5.1.10 to 5.1.13) without success.
If you replace these special single quotes with standard double quotes the sql statement should be valid.
If you take a closer look at the stacktrace you'll see it's the driver which is throwing the exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
AFAIK there's hasn't been any preprocessing of the sql-files before passing it to the driver. The sql file should be passed to the driver as it is.
Are you sure about no processing before the file is passed to the driver. I am really surprised because if I switch the version 1.4 to 1.3 of the sql-maven-plugin, it works fine.
I tried with double quotes (to be sure, I used this character ") and I obtain this result:
------------------------------------------------------------------------
[ERROR]BUILD ERROR
------------------------------------------------------------------------
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"databaseToUpdate"."tableToUpdate"
SET
"XMLCONFIGURATION" = '<?xml ver' at line 2
------------------------------------------------------------------------
Trace
org.apache.maven.lifecycle.LifecycleExecutionException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"databaseToUpdate"."tableToUpdate"
SET
"XMLCONFIGURATION" = '<?xml ver' at line 2
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"databaseToUpdate"."tableToUpdate"
SET
"XMLCONFIGURATION" = '<?xml ver' at line 2
at org.codehaus.mojo.sql.SqlExecMojo.execute(SqlExecMojo.java:646)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"databaseToUpdate"."tableToUpdate"
SET
"XMLCONFIGURATION" = '<?xml ver' at line 2
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:409)
at com.mysql.jdbc.Util.getInstance(Util.java:384)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2562)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2512)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:781)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:624)
at org.codehaus.mojo.sql.SqlExecMojo.execSQL(SqlExecMojo.java:1011)
at org.codehaus.mojo.sql.SqlExecMojo.runStatements(SqlExecMojo.java:975)
at org.codehaus.mojo.sql.SqlExecMojo.access$200(SqlExecMojo.java:66)
at org.codehaus.mojo.sql.SqlExecMojo$Transaction.runTransaction(SqlExecMojo.java:1207)
at org.codehaus.mojo.sql.SqlExecMojo$Transaction.access$100(SqlExecMojo.java:1154)
at org.codehaus.mojo.sql.SqlExecMojo.execute(SqlExecMojo.java:612)
... 19 more
Maybe I am wrong with your suggestion about the double quotes.
One fact that I thought now is that the time processing of the plugin when the problem occurs is really long in regards to the time that a correct processing.
I reallize that the exception comes from the MySQL connector but I tried the same query without any modifications directly from the commande line (mysql binary) with success (with carriage return, unchanged quotes, ...)
I reallize that the exception comes from the MySQL connector but I tried the same query without any modifications directly from the commande line (mysql binary) with success (with carriage return, unchanged quotes, ...)
This is kind of interesting. It looks like you have an encoding-issue. Could you try to configure it in the plugin[1]?
[1] http://mojo.codehaus.org/sql-maven-plugin/execute-mojo.html#encoding
Sorry for previous updates, I just removed real names for database and tables.
I tried to add this <encoding>UTF-8</encoding> to the plugin configuration (all the project is in UTF-8) and the result is the same as the first exception. Is it something else to check for the encoding that I possibly miss ?
This could be related to MSQL-33, this is one of the few touching sql-files.
I tried to convert the file to UTF-8 and done the test again with the same result. I can try with another encoding eventually.
If you run the command with -X you'll see extra debug statements. One of the lines you can expect is {{SQL: }} followed by the statement which is java.sql.Statement will execute.
I tried with -X token to the command. There is the result (it seems that the request is truncated):
[sql:execute]
[DEBUG]copy /pathToSqlScript/update.sql to /var/folders/7o/7ofiJPKHFk832PaysV69ME+++TI/Tmp/update.1663648525sql
[DEBUG]connecting to jdbc:mysql://localhost:3306
Executing file: /var/folders/7o/7ofiJPKHFk832PaysV69ME+++TI/Tmp/update.1663648525sql
[DEBUG]SQL:
UPDATE
`databaseToUpdate`.`tableToUpdate`
SET
`XMLCONFIGURATION` = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlConfiguration>
<params>
<entry>
<key>keyOne</key>
<value>valueOne</value>
</entry>
<entry>
<key>keyTwo</key>
<value>valueTwo</value>
</entry>
<entry>
<key>keyThree</key>
<value>valueThree</value
[ERROR]Failed to execute:
UPDATE
`databaseToUpdate`.`tableToUpdate`
SET
`XMLCONFIGURATION` = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlConfiguration>
<params>
<entry>
<key>keyOne</key>
<value>valueOne</value>
</entry>
<entry>
<key>keyTwo</key>
<value>valueTwo</value>
</entry>
<entry>
<key>keyThree</key>
<value>valueThree</value
------------------------------------------------------------------------
[ERROR]BUILD ERROR
------------------------------------------------------------------------
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlConfiguration>
<p' at line 4
------------------------------------------------------------------------
[DEBUG]Trace
org.apache.maven.lifecycle.LifecycleExecutionException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlConfiguration>
<p' at line 4
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlConfiguration>
<p' at line 4
at org.codehaus.mojo.sql.SqlExecMojo.execute(SqlExecMojo.java:646)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlConfiguration>
<p' at line 4
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:409)
at com.mysql.jdbc.Util.getInstance(Util.java:384)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3566)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3498)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2562)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2512)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:781)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:624)
at org.codehaus.mojo.sql.SqlExecMojo.execSQL(SqlExecMojo.java:1011)
at org.codehaus.mojo.sql.SqlExecMojo.runStatements(SqlExecMojo.java:975)
at org.codehaus.mojo.sql.SqlExecMojo.access$200(SqlExecMojo.java:66)
at org.codehaus.mojo.sql.SqlExecMojo$Transaction.runTransaction(SqlExecMojo.java:1207)
at org.codehaus.mojo.sql.SqlExecMojo$Transaction.access$100(SqlExecMojo.java:1154)
at org.codehaus.mojo.sql.SqlExecMojo.execute(SqlExecMojo.java:612)
... 19 more
Laurent,
I've written an integration-test for your case (see attachment). We're using Derby instead of MySQL because of it embedded JDBC driver. What's more interesting is the output of the sql-m-p. Here the sql-statement is complete.
[ERROR] Failed to execute: UPDATE `databaseToUpdate`.`tableToUpdate` SET `XMLCONFIGURATION` = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xmlConfiguration> <params> <entry> <key>keyOne</key> <value>valueOne</value> </entry> <entry> <key>keyTwo</key> <value>valueTwo</value> </entry> <entry> <key>keyThree</key> <value>valueThree</value> </entry> </params> </xmlConfiguration>' WHERE `NAMESPACE` = 'system'
So I would expect there's a difference between the two sql files. It would be great if you could could check out the current code and apply my patch. Next execute 'mvn verify' to see the results.
btw, here my mvn -v
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200) Java version: 1.6.0_12 Java home: C:\Java\jdk1.6.0_12\jre Default locale: nl_NL, platform encoding: Cp1252 OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
I patch and run mvn verify, there is the log:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building SQL Maven Plugin
[INFO] task-segment: [verify]
[INFO] ------------------------------------------------------------------------
[INFO] [plugin:helpmojo
]
[INFO] Using 'UTF-8' encoding to read mojo metadata.
[INFO] Applying mojo extractor for language: java
[INFO] Mojo extractor for language: java found 2 mojo descriptors.
[INFO] Applying mojo extractor for language: bsh
[INFO] Mojo extractor for language: bsh found 0 mojo descriptors.
[INFO] [plugin:descriptor
]
[INFO] Using 'UTF-8' encoding to read mojo metadata.
[INFO] Applying mojo extractor for language: java
[INFO] Mojo extractor for language: java found 2 mojo descriptors.
[INFO] Applying mojo extractor for language: bsh
[INFO] Mojo extractor for language: bsh found 0 mojo descriptors.
[INFO] [resources:resources
]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/user/Desktop/sql-maven-plugin/src/main/resources
[INFO] [compiler:compile
]
[INFO] Compiling 1 source file to /Users/user/Desktop/sql-maven-plugin/target/classes
[INFO] [resources:testResources
]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] [compiler:testCompile
]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test
]
[INFO] Surefire report directory: /Users/user/Desktop/sql-maven-plugin/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.codehaus.mojo.sql.SqlExecMojoTest
Tests run: 25, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.508 sec
Running org.codehaus.mojo.sql.SqlSplitterTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.014 sec
Results :
Tests run: 27, Failures: 0, Errors: 0, Skipped: 0
[INFO] [jar:jar
{execution: default-jar}]
[INFO] Building jar: /Users/user/Desktop/sql-maven-plugin/target/sql-maven-plugin-1.4.jar
[INFO] [plugin:addPluginArtifactMetadata
]
[INFO] [invoker:install
]
[INFO] Installing /Users/user/Desktop/sql-maven-plugin/pom.xml to /Users/user/Desktop/sql-maven-plugin/target/local-repo/org/codehaus/mojo/sql-maven-plugin/1.4/sql-maven-plugin-1.4.pom
[INFO] Installing /Users/user/Desktop/sql-maven-plugin/target/sql-maven-plugin-1.4.jar to /Users/user/Desktop/sql-maven-plugin/target/local-repo/org/codehaus/mojo/sql-maven-plugin/1.4/sql-maven-plugin-1.4.jar
[INFO] [invoker:run
]
[INFO] Building: derby/pom.xml
[INFO] ..SUCCESS (3.1 s)
[INFO] Building: msql-59/pom.xml
[INFO] ..FAILED (3.4 s)
[INFO] The build exited with code 1. See /Users/user/Desktop/sql-maven-plugin/target/it/msql-59/build.log for details.
[INFO] Building: msql-9/pom.xml
[INFO] ..SUCCESS (3.6 s)
[INFO] ---------------------------------------
[INFO] Execution Summary:
[INFO] Builds Passing: 2
[INFO] Builds Failing: 1
[INFO] Builds Skipped: 0
[INFO] ---------------------------------------
[ERROR] The following builds failed:
[ERROR] * msql-59/pom.xml
[INFO] ---------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] : org.apache.maven.plugin.invoker.InvokerSession@4ce51960
1 build failed.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17 seconds
[INFO] Finished at: Tue Aug 03 09:30:46 CEST 2010
[INFO] Final Memory: 40M/86M
[INFO] ------------------------------------------------------------------------
And this is the mvn -v from Command Line and NetBeans:
Command Line:
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.6.0_20
Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
Default locale: fr_CH, platform encoding: MacRoman
OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
NetBeans:
NetBeans: Executing '/opt/apache-maven-2.2.1/bin/mvn -Dnetbeans.execution=true --fail-fast -v'
NetBeans: JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.6.0_20
Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
Default locale: fr_CH, platform encoding: MacRoman
OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac"
This output is even different from the original one. Here it looks like the sql file is replaced by some part of the pom.xml.
Looks like MSQL-9 is somehow responsible for this issue.
To be able to filter any sql-file we had to write it to a temporary file. If enableFiltering is not set (this is the default), it should just copy the file. If you run the goal in debug-mode the file won't be deleted, so maybe you can confirm that this file indeed contains pom.xml-data.
The copying and filtering is done by the MavenFileFilter. I noticed there's a new release available. Could you try to update the dependency by adding the following snippet to the sql-maven-plugin:
<dependency><groupId>org.apache.maven.shared</groupId><artifactId>maven-filtering</artifactId><version>1.0-beta-4</version></dependency>
I checked the temp files with the debug mode and I saw that the content is the following:
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3 <modelVersion>4.0.0</modelVersion>
4 <groupId>org.codehaus.mojo</groupId>
5 <artifactId>sql-maven-plugin-test</artifactId>
6 <version>0.0.1-SNAPSHOT</version>
7
8 <build>
9 <plugins>
10 <plugin>
11 <groupId>org.codehaus.mojo</groupId>
12 <artifactId>sql-maven-plugin</artifactId>
13 <version>@project.version@</version>
14 <dependencies>
15 <dependency>
16 <groupId>org.apache.derby</groupId>
17 <artifactId>derby</artifactId>
18 <version>10.2.2.0</version>
19 </dependency>
20 </dependencies>
21
22 <configuration>
23 <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
24 <url>jdbc:derby:$
/testdb;create=true</url>
25 <srcFiles>
26 <srcFile>src/main/sql/update.sql</srcFile>
27 </srcFiles>
28 </configuration>
29 </plugin>
30 </plugins>
31 </build>
32 </project>
I also tried to change the dependency in the pom of the plugin and run the verify goal again with the same result.
I am not sure to understand correctly what you ask me to do. I hope I did the operations correctly.
One line I don't understand:
[DEBUG] copy /Users/prevole/Desktop/sql-maven-plugin/target/it/msql-59/src/main/sql/update.sql to /var/folders/7o/7ofiJPKHFk832PaysV69ME+++TI/
Tmp/update.2075667218sql
It should just copy the file according the source of DefaultMavenFileFilter[1]
So before copying src/main/sql/update.sql the file contains the sql and afterwards the copy -Tmp-/update.2075667218sql contains the pom. Both should be 100% the same. If they're not, then it looks like you've found a bug in plexus-utils. I couldn't an open issue about it at JIRA[2]
About upgrading the maven-filtering: you have two options: since you have the source you can update it there, otherwise you can add this dependency to the pom of the IT in the sql-m-p section, next to the derby dependency. Both ways it'll use version 1.0-beta-4.
[1] https://maven.apache.org/shared/maven-filtering/xref/org/apache/maven/shared/filtering/DefaultMavenFileFilter.html#119
[2] http://jira.codehaus.org/browse/PLXUTILS
I am sorry, but I wrongly done the patch on your integration test MSQL-59. I did the test again from scratch and checked the files carrefully. At this step, I am sure that the temp file is the same as the file contained in /src/main/sql/update.sql. Previously, this file contained the pom.xml data. I am sorry for the trouble I occured.
Now, the content of the file seems to be correct but the test fail again. with this log:
[DEBUG] copy /Users/user/Desktop/sql-maven-plugin/target/it/msql-59/src/main/sql/update.sql to /var/folders/7o/7ofiJPKHFk832PaysV69ME+++TI/Tmp/update.1672718519sql
[DEBUG] connecting to jdbc:derby:/Users/user/Desktop/sql-maven-plugin/target/it/msql-59/target/testdb;create=true
[DEBUG] Committing transaction
[INFO] Executing file: /var/folders/7o/7ofiJPKHFk832PaysV69ME+++TI/Tmp/update.1672718519sql
[DEBUG] SQL: UPDATE `databaseToUpdate`.`tableToUpdate` SET `XMLCONFIGURATION` = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xmlConfiguration> <params> <entry> <key>keyOne</key> <value>valueOne</value> </entry> <entry> <key>keyTwo</key> <value>valueTwo</value> </entry> <entry> <key>keyThree</key> <value>valueThree</value> </entry> </params> </xmlConfiguration>' WHERE `NAMESPACE` = 'system' [ERROR] Failed to execute: UPDATE `databaseToUpdate`.`tableToUpdate` SET `XMLCONFIGURATION` = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <xmlConfiguration> <params> <entry> <key>keyOne</key> <value>valueOne</value> </entry> <entry> <key>keyTwo</key> <value>valueTwo</value> </entry> <entry> <key>keyThree</key> <value>valueThree</value> </entry> </params> </xmlConfiguration>' WHERE `NAMESPACE` = 'system'
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Lexical error at line 2, column 2. Encountered: "`" (96), after : "".
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace org.apache.maven.lifecycle.LifecycleExecutionException: Lexical error at line 2, column 2. Encountered: "`" (96), after : "". at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at org.codehaus.classworlds.Launcher.main(Launcher.java:375) Caused by: org.apache.maven.plugin.MojoExecutionException: Lexical error at line 2, column 2. Encountered: "`" (96), after : "". at org.codehaus.mojo.sql.SqlExecMojo.execute(SqlExecMojo.java:646) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694) ... 17 more Caused by: java.sql.SQLSyntaxErrorException: Lexical error at line 2, column 2. Encountered: "`" (96), after : "". at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source) at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source) at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source) at org.codehaus.mojo.sql.SqlExecMojo.execSQL(SqlExecMojo.java:1011) at org.codehaus.mojo.sql.SqlExecMojo.runStatements(SqlExecMojo.java:975) at org.codehaus.mojo.sql.SqlExecMojo.access$200(SqlExecMojo.java:66) at org.codehaus.mojo.sql.SqlExecMojo$Transaction.runTransaction(SqlExecMojo.java:1207) at org.codehaus.mojo.sql.SqlExecMojo$Transaction.access$100(SqlExecMojo.java:1154) at org.codehaus.mojo.sql.SqlExecMojo.execute(SqlExecMojo.java:612) ... 19 more Caused by: java.sql.SQLException: Lexical error at line 2, column 2. Encountered: "`" (96), after : "". at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source) ... 33 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 39 seconds
[INFO] Finished at: Wed Aug 04 09:27:36 CEST 2010
[INFO] Final Memory: 13M/81M
[INFO] ------------------------------------------------------------------------
We can see that the ` is not allowed. I do not know if it is a derby limitation or the sql-maven-plugin. Without the `, the output says that the database does not exist. Now the problem seems to be unknown database items. I never worked with derby database so I cannot easily do other tests now.
Just like me you run into derby-specific problems because the sql is invalid for derby.
So here you see the file correct, while in the original testcase the sql-file got broken. It's like you've got a corrupt version of the sql-m-p or one of it's dependencies...
The query contains some special types of single quotes. Is this coincidence or is this really the content of the sql-file? AFAIK these are illegal characters for referring to tables.