2013-01-29 4 views
0

Я пытаюсь использовать JPA + Hibernate 4.5.1 в проекте JSF/Primefaces. Я использую c3p0 для объединения пулов. Когда приложение запускается, c3p0 пытается инициализировать пул, но аутентификация завершается с ошибкой.Конфигурация с использованием JPA/Hibernate и Jasypt

Это мой persistence.xml:

<persistence-unit name="ba"> 

    <properties> 
     <property name="hibernate.connection.driver_class" value="net.sourceforge.jtds.jdbc.Driver"/> 
     <property name="hibernate.connection.url" value="jdbc:jtds:sqlserver://x.x.x.x:1433/ba"/> 
     <property name="hibernate.connection.username" value="ba"/> 
     <property name="hibernate.connection.password" value="ENC(UcsChwXw5vYnM7w2S9XUaw==)" />    
     <property name="hibernate.connection.provider_class" value="org.jasypt.hibernate4.connectionprovider.EncryptedPasswordC3P0ConnectionProvider"/> 
     <property name="hibernate.connection.encryptor_registered_name" value="configurationHibernateEncryptor"/> 
     <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/> 
     <property name="hibernate.connection.release_mode" value="on_close"/> 
     <property name="hibernate.archive.autodetection" value="class, hbm"/> 
     <property name="hibernate.show_sql" value="true"/> 
     <property name="hibernate.c3p0.validate" value="true"/> 
     <property name="hibernate.c3p0.min_size" value="5"/> 
     <property name="hibernate.c3p0.max_size" value="20"/> 
     <property name="hibernate.c3p0.timeout" value="8"/> 
     <property name="hibernate.c3p0.max_statements" value="50"/> 
     <property name="hibernate.c3p0.preferredTestQuery" value="SELECT 1;"/> 
     <property name="hibernate.c3p0.idle_test_period" value="5"/> 
     <property name="hibernate.c3p0.idle_test_period" value="1200"/> 
     <property name="hibernate.c3p0.acquire_increment" value="1"/> 
    </properties> 

</persistence-unit> 

Я поместил следующее в: контекста сервлета

@Override 
    public void contextInitialized(ServletContextEvent contextEvent) { 
    StandardPBEStringEncryptor strongEncryptor = new StandardPBEStringEncryptor(); 
    strongEncryptor.setAlgorithm("PBEWithMD5AndDES"); 
    strongEncryptor.setPassword("password");  
    HibernatePBEEncryptorRegistry registry = HibernatePBEEncryptorRegistry.getInstance(); 
    registry.registerPBEStringEncryptor("configurationHibernateEncryptor", strongEncryptor); 

}

Это "ошибка" линии:

INFO: Initializing c3p0 pool... [email protected] 
d [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSou 
[email protected] [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDe 
lay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterA 
cquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> n 
ull, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTest 
er, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, 
forceIgnoreUnresolvedTransactions -> false, identityToken -> 2rxe6q8s1103xfe10g 
g38n|1712f3d, idleConnectionTestPeriod -> 1200, initialPoolSize -> 3, maxAdminis 
trativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 8, maxIdleTimeExcess 
Connections -> 0, maxPoolSize -> 20, maxStatements -> 50, maxStatementsPerConnec 
tion -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManag 
[email protected] [ description -> null, driverClass -> null, factoryClassLo 
cation -> null, identityToken -> 2rxe6q8s1103xfe10gg38n|bc294a, jdbcUrl -> jdbc: 
jtds:sybase://x.x.x.x:yyyy/crystal, properties -> {encryptor_registered_name= 
configurationHibernateEncryptor, user=******, password=******, autocommit=true, 
release_mode=auto} ], preferredTestQuery -> null, propertyCycle -> 0, statementC 
acheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnecti 
onOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflecti 
veProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLoc 
ation -> null, identityToken -> 2rxe6q8s1103xfe10gg38n|1976f39, numHelperThreads 
-> 3 ] 


Jan 29, 2013 11:16:25 AM com.mchange.v2.resourcepool.BasicResourcePool$Scattered 
AcquireTask run 
WARNING: com[email protected]1de3 
1b1 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to 
acquire a needed new resource, we failed to succeed more than the maximum number 
of allowed acquisition attempts (30). Last acquisition attempt exception: 
java.sql.SQLException: Login failed for user 'xxxxx'. 
     at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.j 
ava:372) 
     at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820) 
     at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258) 
     at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:603) 
     at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java 
:352) 
     at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java 
:50) 
     at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:185) 
     at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManag 
erDataSource.java:134) 
     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnecti 
on(WrapperConnectionPoolDataSource.java:183) 
     at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnecti 
on(WrapperConnectionPoolDataSource.java:172) 
     at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionRe 
sourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:152) 
     at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResource 
Pool.java:1074) 
     at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPe 
ndingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1061) 
     at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourc 
ePool.java:32) 
     at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.ru 
n(BasicResourcePool.java:1796) 
     at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(Thre 
adPoolAsynchronousRunner.java:635) 

Jan 29, 2013 11:16:25 AM com.mchange.v2.resourcepool.BasicResourcePool forceKill 
Acquires 
WARNING: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicR 
[email protected] is interrupting all Threads waiting on a resource to check o 
ut. Will try again in response to new client requests. 
Jan 29, 2013 11:16:25 AM com.mchange.v2.resourcepool.BasicResourcePool forceKill 
Acquires 
WARNING: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicR 
[email protected] is interrupting all Threads waiting on a resource to check o 
ut. Will try again in response to new client requests. 
+0

Что скажет журнал: какая ошибка? – snow8261

+0

@ snow8261, проверьте обновление. – javaMS

ответ

0

Th это ошибка. Пожалуйста, нажмите здесь для получения более подробной информации: http://sourceforge.net/tracker/?func=detail&aid=3515794&group_id=183612&atid=905944

Чтобы исправить это, один из файлов, предоставленных Jasypt-hibernate4 (EncryptedPasswordC3P0ConnectionProvider), должен быть изменен в соответствии с деталями, указанными в ссылке.

 Смежные вопросы

  • Нет связанных вопросов^_^