Hibernate - Exception ao tentar conectar SQL Server

O código abaixo funciona quando eu tento conectar no MySQL que está instalado na minha máquina (localhost), mas quando tento conectar a uma base do SQL Server em outra máquina, não funciona…

[code]import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class TestaConexao {
public static void main(String[] args) {
try {
EntityManagerFactory factory = Persistence
.createEntityManagerFactory(“persistenceUnit”);
System.out.println("\n\nAchou o persistenceUnit\n\n");
EntityManager manager = factory.createEntityManager();
System.out.println("\n\nEntityManager criado com sucesso\n\n");
manager.close();
System.out.println("\n\nEntityManager encerrado com sucesso\n\n");
factory.close();
System.out.println("\n\nFactory encerrado com sucesso\n\n");
} catch (Exception e) {
System.out.println("\n\nErro:\n\n");
e.printStackTrace();
System.out.println("\n\nFim do StackTrace\n\n");
}
}
}[/code]

O StackTrace é:

javax.persistence.PersistenceException: org.hibernate.AnnotationException: Unable to load Search event listener at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:737) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34) at com.iddeia.dao.TestaConexao.main(TestaConexao.java:11) Caused by: org.hibernate.AnnotationException: Unable to load Search event listener at org.hibernate.cfg.search.SearchConfiguration.enableHibernateSearch(SearchConfiguration.java:149) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:851) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730) ... 4 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.hibernate.cfg.search.SearchConfiguration.enableHibernateSearch(SearchConfiguration.java:146) ... 6 more Caused by: java.lang.NoSuchMethodError: org.hibernate.event.EventListeners.getPostCollectionRecreateEventListeners()[Lorg/hibernate/event/PostCollectionRecreateEventListener; at org.hibernate.cfg.search.CollectionSearchConfiguration.enableHibernateSearch(CollectionSearchConfiguration.java:18) ... 11 more

E o meu arquivo persistence.xml é:

[code]<?xml version="1.0" encoding="UTF-8"?>


org.hibernate.ejb.HibernatePersistence



        <property name="hibernate.connection.driver_class" value="net.sourceforge.jtds.jdbc.Driver"/>
        <property name="hibernate.connection.url" value="jdbc:jtds:sqlserver://192.168.5.217:1433"/>
        <property name="hibernate.connection.username" value="usr_lex"/>
        <property name="hibernate.connection.password" value="lex_usr"/>
        <property name="hibernate.dialect" value=" org.hibernate.dialect.SQLServerDialect"/>
    </properties>
</persistence-unit>

[/code]

Não conheço muito de Java, programo a um ano, e nunca tentei conectar no SQL Server, e não encontrei uma sugestão que funcionasse no google, toda ajuda será muito bem vinda :slight_smile: