1

I am trying to set up liquibase with maven for sql server 2012. I am using the sqljdbc4.jar and trying to connect to sql server using windows authentication. With windows authentication, I have also included the line below as a VM argument to read the file sqljdbc_auth.dll

-Djava.library.path="D:\Microsoft JDBC Driver 4.0 for SQL Server\sqljdbc_4.0\enu\auth\x86"

I can't figure out why when I run liquibase in maven (liquibase:update -PlocalDB -e -X) it is hanging and getting this error:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.1:update (default-cli) on project Database: Error setting up or running Liquibase: liquibase.exception.DatabaseException: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientConnectionId:47817196-07c1-4fc8-92e2-7e03ca044fcb -> [Help 1]

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.liquibase</groupId>
<artifactId>Database</artifactId>
<version>1.0</version>
<properties>
    <skipTests>true</skipTests>
    <jdk-version>1.6</jdk-version>
    <sqlserver-version>4.0</sqlserver-version>
    <liquibase-version>3.1.1</liquibase-version>
</properties>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${jdk-version}</source>
                    <target>${jdk-version}</target>
                    <skipTests>${skipTests}</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>${liquibase-version}</version>
                <configuration>
                    <changeLogFile>src/main/resources/changelogs/changelog-master.xml</changeLogFile>
                    <driver>${database.driver}</driver>
                    <url>${database.url}</url>
                </configuration>
                <executions>
                    <execution>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>update</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<profiles>
    <profile>
        <id>localDB</id>
        <properties>
            <database.driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</database.driver>
            <database.url>jdbc:sqlserver://computername:1433;databaseName=Test_Liquibase;integratedSecurity=true</database.url>
        </properties>
    </profile>
</profiles>
<dependencies>
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>sqljdbc4</artifactId>
        <version>${sqlserver-version}</version>
    </dependency>
    <dependency>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-core</artifactId>
        <version>${liquibase-version}</version>
    </dependency>
</dependencies>

EDIT full stack trace from maven

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.1:update (default-cli) on project Database: Error setting up or running Liquibase: liquibase.exception.DatabaseException: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientConnectionId:38797943-7fe8-49e7-8565-5f72dfd6ed1e -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.1:update (default-cli) on project Database: Error setting up or running Liquibase: liquibase.exception.DatabaseException: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientConnectionId:38797943-7fe8-49e7-8565-5f72dfd6ed1e at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 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.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: org.apache.maven.plugin.MojoExecutionException: Error setting up or running Liquibase: liquibase.exception.DatabaseException: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientConnectionId:38797943-7fe8-49e7-8565-5f72dfd6ed1e at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:381) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientConnectionId:38797943-7fe8-49e7-8565-5f72dfd6ed1e at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:61) at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:330) ... 21 more Caused by: liquibase.exception.DatabaseException: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientConnectionId:38797943-7fe8-49e7-8565-5f72dfd6ed1e at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:231) at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:141) at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:52) ... 22 more Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset ClientConnectionId:38797943-7fe8-49e7-8565-5f72dfd6ed1e at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667) at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1654) at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:1789) at com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:4838) at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:6154) at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:6106) at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2907) at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2234) at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41) at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012) at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:223) ... 24 more

Bobby
  • 51
  • 2
  • 8
  • Are you able to get a stacktrace of maven when it is hanging? ctrl+break will usually do it on windows and kill -QUIT PID on unix for java apps but I'm not sure if maven gets in the way of that. – Nathan Voxland May 01 '14 at 19:54
  • @NathanVoxland I have edited my question with the full stack trace from Maven, hope this helps... – Bobby May 01 '14 at 20:08

2 Answers2

0

Liquibase appears to be trying to open a connection and failing with a "Connection reset ClientConnectionId" error from the JDBC driver.

The connection call is just driverObject.Connect(url, properties) where properties is the username and password if specified in maven. Since you are not specifying them they should be null.

Are you able to connect to the database normally with the URL you are giving it? It may be a firewall/network issue. Otherwise I would be suspicious of the windows authentication attempt causing problems.

Nathan Voxland
  • 15,453
  • 2
  • 48
  • 64
  • I am able to connect to the database normally through SSMS, using Windows Authentication or Sql Server Authentication. If i try connecting to the db using the liquibase-maven-plugin using Sql Server Authentication, it says my login fails. I know my login does work when I connect to the db through weblogic, so my connection string should be correct... – Bobby May 02 '14 at 15:46
  • I've not tried connecting to sqlserver with windows auth and maven. http://stackoverflow.com/questions/13495203/how-to-add-sqljdbc-auth-dll-to-my-maven-project lists some steps that may help. – Nathan Voxland May 03 '14 at 21:16
0

changed maven to use java 7, instead of java 6, windows authentication and SQL server authentication works and I was able to connect. :)

Bobby
  • 51
  • 2
  • 8