Hibernate Tools and SQL Server integrated Security

Hi Community,

I’m rather new to Hibernate and currently exploring all the functionalities but I do have one issue where I’m stuck and I hope someone can point me in the right direction. Hibernate tools are always throwing an error when I try to connect to my MS SQL Server DB using integrated Security (Windows Authentication) in the “Hibernate Configurations”-View in Eclipse.
The error indicates that the “sqljdbc_auth.dll” file is already loaded in another classloader. I can’t figure out why and where this happens and ultimately how to solve this.

I’m running the following setup:
Eclipse Photon 4.8.0
Hibernate Tools 5.4.7
JDK 1.8 x64
MS SQL JDBC 6.0 Driver (tried different versions as well, including the latest one)

As a side note: Connecting to the DB from the Java Code itself (using Hibernate) is working properly. It’s only the Hibernate Tools which I can’t get working.

The full stack trace of the error-message:

org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
  org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
  Error calling Driver#connect
    org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
    Error calling Driver#connect
    com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:dd9decbd-2588-47e9-ae06-caadcb27472e
    This driver is not configured for integrated authentication. ClientConnectionId:dd9decbd-2588-47e9-ae06-caadcb27472e
    java.lang.UnsatisfiedLinkError: Native Library C:\Program Files\Java\jre1.8.0_231\bin\sqljdbc_auth.dll already loaded in another classloader
    Native Library C:\Program Files\Java\jre1.8.0_231\bin\sqljdbc_auth.dll already loaded in another classloader

Would be glad if someone has any Idea how this can be solved.
Many thanks
Jan

Hey Jan,

Can you please describe what tools (JBoss Tools version?) you are using and what manipulation you are executing when this happens? Is there a sample project we can use to try and replicate this?

Cheers,
Koen

Hey Koen,

thanks for your fast response.
I’ve installed the Jboss Tools just two days ago from the Eclipse Marketplace, therefore assuming it’s the latest available version (attached a screenshot for your reference).

What I did is the following:

  1. Created a new Maven Project in Eclipse and only added Hibernate-core 5.4.14.final and mssql-jdbc driver as depency to my pom.xml
  2. Created a hibernate.cfg.xml containing the connection string for my database:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                         "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
 <session-factory name="">
  <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
  <property name="hibernate.connection.url">jdbc:sqlserver://myMSSQLSERVER:1433;databaseName=myDB;integratedSecurity=true;</property>
  <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
  <property name="hibernate.show_sql">true</property>
 </session-factory>
</hibernate-configuration>
  1. Placed the “sqljdbc_auth.dll” (x64) from the MS SQL JDBC driver into Java/JDK(JRE)/bin folder (also tried different locations or adding its path to java.library.path or as native library into the project itself) in order to be able to use Windows authentication for the DB connection.
  2. Switched to the Eclipse-View “Hibernate Configurations” and created a new configuration for my sample project using the existing hibernate.cfg.xml.
    When trying to expand this configuration (by selecting “Rebuild” or “Refresh”) the error message is thrown. (Tried to illustrate the steps with additional screenshots but it looks like I can only attach one to my post)

Maybe I did something completely wrong here…just worked through different tutorials to get started.

Cheers,
Jan