JPA方言问题nosuchmethod例外

时间:2015-02-16 09:16:42

标签: java jpa jenkins nosuchmethoderror dialect

我正在尝试为我的公司设置测试环境。他们选择使用JPA连接到那里的microsoft sql server数据库。问题是我重新创建数据库并使用他们的源代码无法连接到它。 这是我得到的junit错误(仍然是方言,而不是junit)

[junit] com.companyname.kernel.persistence.jpa.UnicodeSQLServerDialect.registerColumnType(IILjava/lang/String;)V
[junit] java.lang.NoSuchMethodError: com.companyname.kernel.persistence.jpa.UnicodeSQLServerDialect.registerColumnType(IILjava/lang/String;)V
[junit]     at com.companyname.kernel.persistence.jpa.UnicodeSQLServerDialect.<init>(Unknown Source)
[junit]     at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
[junit]     at java.lang.Class.newInstance(Class.java:438)
[junit]     at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveDefaultableStrategy(StrategySelectorImpl.java:159)
[junit]     at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.resolveStrategy(StrategySelectorImpl.java:136)
[junit]     at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:78)
[junit]     at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:68)
[junit]     at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:165)
[junit]     at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
[junit]     at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
[junit]     at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
[junit]     at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1887)
[junit]     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
[junit]     at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852)
[junit]     at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845)
[junit]     at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398)
[junit]     at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844)
[junit]     at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:75)
[junit]     at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
[junit]     at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
[junit]     at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
[junit]     at com.companyname.kernel.services.DBService.start(Unknown Source)
[junit]     at IntegrationUtil.Services.InitiDbservice(Unknown Source)
[junit]     at com.companyname.manage.operation.rejectinvoiceOperationTest.serviceStart(Unknown Source)

然后我做了一些阅读,发现这通常是由图书馆冲突引起的:

hibernate-commons-annotations.jar 4.0.5 
hibernate-entitymanager.jar
hibernate-c3p0.jar 4.3.8
hibernate-core.jar 4.3.8
hibernate-entitymanager.jar 4.3.8 final
hibernate-validator.jar 5.1.3 final
hibernate-jpa-2.1-api.jar 1.0.0 final
c3p0.jar 0.9.2.1 

JPA信息:

<persistence-unit name="TestPU" transaction-type="RESOURCE_LOCAL">      
<properties>
<property name="hibernate.connection.url" value="jdbc:log4jdbc:sqlserver://127.0.0.1:1433;database=JPADB;" />
<property name="hibernate.connection.driver_class" value="net.sf.log4jdbc.DriverSpy" />
<property name="hibernate.dialect" value="com.companyname.kernel.persistence.jpa.UnicodeSQLServerDialect" />
<property name="hibernate.connection.autocommit" value="true" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.hbm2ddl.auto" value="update" />


<!-- use c3p0 connection pool -->
<property name="hibernate.c3p0.min_size" value="3" />
<property name="hibernate.c3p0.max_size" value="100" />
<property name="hibernate.c3p0.timeout" value="1800" />
<property name="hibernate.c3p0.max_statements" value="0" />  
</properties>

方言代码:

registerColumnType( Types.VARBINARY, "image" );
    registerColumnType( Types.VARBINARY, 8000, "varbinary($l)" );
    registerColumnType( Types.LONGVARBINARY, "image" );
    registerColumnType( Types.LONGVARCHAR, "text" );
    registerColumnType( Types.BOOLEAN, "bit" );

新发现: 我使用笔记本电脑上的eclipse连接到数据库服务器并且工作正常 但是当詹金斯试图这样做时会出现上述错误。

我发现这些都没有错,但我希望你们中的一个会花时间帮我解决。欢迎任何指示。

1 个答案:

答案 0 :(得分:0)

我把球放在这个球上...... 好像我在更改库后没有重新编译我的数据库模块。

立即解决这个问题