Hibernate-Search 挂有许多(90)个实体类。

发布于 2024-08-27 13:27:59 字数 6036 浏览 11 评论 0原文

我正在为我的应用程序使用休眠搜索。它配置良好并且运行完美,直到不久前它突然停止工作。 据我所知,原因是我的模型(bean)类的数量。 我有大约 90 个类,在构建 Hibernate 配置时将它们添加到我的配置中。

当我禁用休眠搜索(删除搜索注释并使用配置而不是注释配置)时,我尝试启动我的应用程序,它工作正常。

但是,当我启用搜索时,同一个应用程序就会挂起。 我尝试调试并找到了它挂起的确切位置。

将所有类添加到我的 AnnotationsConfiguration 对象后,当我说 cfg.buildSessionfactory() 时, 它永远不会从那句话中出来。 (我已经等了几个小时了!!!)

此外,当我减少模型类的数量(比如减少一半,即 50 个)时,它会从该语句中出来,并且应用程序工作正常。

有人能告诉我为什么会发生这种情况吗? 我的休眠版本是: hibernate-core-3.3.1.GA.jar hibernate-annotations-3.4.0.GA.jar hibernate-commons-annotations-3.1.0.GA.jar hibernate-search-3.1.0.GA.jar

另外,如果需要避免使用 AnnotationsConfiguration,我读到我需要显式配置搜索事件侦听器。任何人都可以列出所有必要的侦听器及其各自的类吗? (我尝试了 Hibernate Search 书籍中给出的标准,但它们给了我 ClassNotFound 异常,并且我在类路径中拥有所有 neccesarty 库)

以下是我设法提取的 hibernate 跟踪的最后几行:

16:09:32,814  INFO AnnotationConfiguration:369 - Hibernate Validator not found: ignoring
16:09:32,892  INFO ConnectionProviderFactory:95 - Initializing connection provider: org.hibernate.connection.C3P0ConnectionProvider
16:09:32,895  INFO C3P0ConnectionProvider:103 - C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/autolinkcrmcom_data
16:09:32,898  INFO C3P0ConnectionProvider:104 - Connection properties: {user=root, password=****}
16:09:32,900  INFO C3P0ConnectionProvider:107 - autocommit mode: false
16:09:33,694  INFO SettingsFactory:116 - RDBMS: MySQL, version: 5.1.37-1ubuntu5.1
16:09:33,696  INFO SettingsFactory:117 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.10 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ )
16:09:33,701  INFO Dialect:175 - Using dialect: org.hibernate.dialect.MySQLDialect
16:09:33,707  INFO TransactionFactoryFactory:59 - Using default transaction strategy (direct JDBC transactions)
16:09:33,709  INFO TransactionManagerLookupFactory:80 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
16:09:33,711  INFO SettingsFactory:170 - Automatic flush during beforeCompletion(): disabled
16:09:33,714  INFO SettingsFactory:174 - Automatic session close at end of transaction: disabled    16:09:32,814  INFO AnnotationConfiguration:369 - Hibernate Validator not found: ignoring
16:09:32,892  INFO ConnectionProviderFactory:95 - Initializing connection provider: org.hibernate.connection.C3P0ConnectionProvider
16:09:32,895  INFO C3P0ConnectionProvider:103 - C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/autolinkcrmcom_data
16:09:32,898  INFO C3P0ConnectionProvider:104 - Connection properties: {user=root, password=****}
16:09:32,900  INFO C3P0ConnectionProvider:107 - autocommit mode: false
16:09:33,694  INFO SettingsFactory:116 - RDBMS: MySQL, version: 5.1.37-1ubuntu5.1
16:09:33,696  INFO SettingsFactory:117 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.10 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ )
16:09:33,701  INFO Dialect:175 - Using dialect: org.hibernate.dialect.MySQLDialect
16:09:33,707  INFO TransactionFactoryFactory:59 - Using default transaction strategy (direct JDBC transactions)
16:09:33,709  INFO TransactionManagerLookupFactory:80 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
16:09:33,711  INFO SettingsFactory:170 - Automatic flush during beforeCompletion(): disabled
16:09:33,714  INFO SettingsFactory:174 - Automatic session close at end of transaction: disabled
16:09:33,716  INFO SettingsFactory:181 - JDBC batch size: 15
16:09:33,719  INFO SettingsFactory:184 - JDBC batch updates for versioned data: disabled
16:09:33,721  INFO SettingsFactory:189 - Scrollable result sets: enabled
16:09:33,723 DEBUG SettingsFactory:193 - Wrap result sets: disabled
16:09:33,725  INFO SettingsFactory:197 - JDBC3 getGeneratedKeys(): enabled
16:09:33,727  INFO SettingsFactory:205 - Connection release mode: auto
16:09:33,730  INFO SettingsFactory:229 - Maximum outer join fetch depth: 2
16:09:33,732  INFO SettingsFactory:232 - Default batch fetch size: 1000
16:09:33,735  INFO SettingsFactory:236 - Generate SQL with comments: disabled
16:09:33,737  INFO SettingsFactory:240 - Order SQL updates by primary key: disabled
16:09:33,740  INFO SettingsFactory:244 - Order SQL inserts for batching: disabled
16:09:33,742  INFO SettingsFactory:420 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
16:09:33,744  INFO ASTQueryTranslatorFactory:47 - Using ASTQueryTranslatorFactory
16:09:33,747  INFO SettingsFactory:252 - Query language substitutions: {}
16:09:33,750  INFO SettingsFactory:257 - JPA-QL strict compliance: disabled
16:09:33,752  INFO SettingsFactory:262 - Second-level cache: enabled
16:09:33,754  INFO SettingsFactory:266 - Query cache: disabled
16:09:33,757  INFO SettingsFactory:405 - Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
16:09:33,759  INFO RegionFactoryCacheProviderBridge:61 - Cache provider: net.sf.ehcache.hibernate.EhCacheProvider
16:09:33,762  INFO SettingsFactory:276 - Optimize cache for minimal puts: disabled
16:09:33,764  INFO SettingsFactory:285 - Structured second-level cache entries: disabled
16:09:33,766  INFO SettingsFactory:314 - Statistics: disabled
16:09:33,769  INFO SettingsFactory:318 - Deleted entity synthetic identifier rollback: disabled
16:09:33,771  INFO SettingsFactory:333 - Default entity-mode: pojo
16:09:33,774  INFO SettingsFactory:337 - Named query checking : enabled
16:09:33,869  INFO Version:20 - Hibernate Search 3.1.0.GA
16:09:35,134 DEBUG DocumentBuilderIndexedEntity:157 - Field selection in projections is set to false for entity **com.xyz.abc**.
recognized hibernaterecognized hibernaterecognized hibernaterecognized hibernaterecognized hibernaterecognized hibernaterecognized hibernaterecognized hibernaterecognized hibernaterecognized hibernateDocumentBuilderIndexedEntity

不知道最后一行表示什么? ? (休眠识别......) 在最后一行之后,它不执行任何操作(也没有跟踪)并且只是挂起......

I am using hibernate search for my application. It is well configured and running perfectly till some time back, when it stopped working suddenly.
The reason according to me being the number of my model (bean) classes.
I have some 90 classes, which I add to my configuration, while building my Hibernate Configuration.

When, I disable hibernate search (remove the search annotations and use Configuration instead of AnnotationsConfiguration), I try to start my application, it Works fine.

But,the same app when I enable search, it just hangs up.
I tried debugging and found the exact place where it hangs.

After adding all the class to my AnnotationsConfiguration object, when I say cfg.buildSessionfactory(),
It never comes out of that statement. (I have waited for hours!!!)

Also when I decrease the number of my model classes (like say to half i.e. 50) it comes out of that statement and the application works fine..

Can Someone tell why is this happening??
My versions of hibernate are:
hibernate-core-3.3.1.GA.jar
hibernate-annotations-3.4.0.GA.jar
hibernate-commons-annotations-3.1.0.GA.jar
hibernate-search-3.1.0.GA.jar

Also if need to avoid using AnnotationsConfiguration, I read that I need to configure the search event listeners explicitly.. can anyone list all the neccessary listeners and their respective classes? (I tried the standard ones given in Hibernate Search books, but they give me ClassNotFound exception and I have all the neccesarty libs in classpath)

Here are the last few lines of hibernate trace I managed to pull :

16:09:32,814  INFO AnnotationConfiguration:369 - Hibernate Validator not found: ignoring
16:09:32,892  INFO ConnectionProviderFactory:95 - Initializing connection provider: org.hibernate.connection.C3P0ConnectionProvider
16:09:32,895  INFO C3P0ConnectionProvider:103 - C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/autolinkcrmcom_data
16:09:32,898  INFO C3P0ConnectionProvider:104 - Connection properties: {user=root, password=****}
16:09:32,900  INFO C3P0ConnectionProvider:107 - autocommit mode: false
16:09:33,694  INFO SettingsFactory:116 - RDBMS: MySQL, version: 5.1.37-1ubuntu5.1
16:09:33,696  INFO SettingsFactory:117 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.10 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ )
16:09:33,701  INFO Dialect:175 - Using dialect: org.hibernate.dialect.MySQLDialect
16:09:33,707  INFO TransactionFactoryFactory:59 - Using default transaction strategy (direct JDBC transactions)
16:09:33,709  INFO TransactionManagerLookupFactory:80 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
16:09:33,711  INFO SettingsFactory:170 - Automatic flush during beforeCompletion(): disabled
16:09:33,714  INFO SettingsFactory:174 - Automatic session close at end of transaction: disabled    16:09:32,814  INFO AnnotationConfiguration:369 - Hibernate Validator not found: ignoring
16:09:32,892  INFO ConnectionProviderFactory:95 - Initializing connection provider: org.hibernate.connection.C3P0ConnectionProvider
16:09:32,895  INFO C3P0ConnectionProvider:103 - C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/autolinkcrmcom_data
16:09:32,898  INFO C3P0ConnectionProvider:104 - Connection properties: {user=root, password=****}
16:09:32,900  INFO C3P0ConnectionProvider:107 - autocommit mode: false
16:09:33,694  INFO SettingsFactory:116 - RDBMS: MySQL, version: 5.1.37-1ubuntu5.1
16:09:33,696  INFO SettingsFactory:117 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.10 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ )
16:09:33,701  INFO Dialect:175 - Using dialect: org.hibernate.dialect.MySQLDialect
16:09:33,707  INFO TransactionFactoryFactory:59 - Using default transaction strategy (direct JDBC transactions)
16:09:33,709  INFO TransactionManagerLookupFactory:80 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
16:09:33,711  INFO SettingsFactory:170 - Automatic flush during beforeCompletion(): disabled
16:09:33,714  INFO SettingsFactory:174 - Automatic session close at end of transaction: disabled
16:09:33,716  INFO SettingsFactory:181 - JDBC batch size: 15
16:09:33,719  INFO SettingsFactory:184 - JDBC batch updates for versioned data: disabled
16:09:33,721  INFO SettingsFactory:189 - Scrollable result sets: enabled
16:09:33,723 DEBUG SettingsFactory:193 - Wrap result sets: disabled
16:09:33,725  INFO SettingsFactory:197 - JDBC3 getGeneratedKeys(): enabled
16:09:33,727  INFO SettingsFactory:205 - Connection release mode: auto
16:09:33,730  INFO SettingsFactory:229 - Maximum outer join fetch depth: 2
16:09:33,732  INFO SettingsFactory:232 - Default batch fetch size: 1000
16:09:33,735  INFO SettingsFactory:236 - Generate SQL with comments: disabled
16:09:33,737  INFO SettingsFactory:240 - Order SQL updates by primary key: disabled
16:09:33,740  INFO SettingsFactory:244 - Order SQL inserts for batching: disabled
16:09:33,742  INFO SettingsFactory:420 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
16:09:33,744  INFO ASTQueryTranslatorFactory:47 - Using ASTQueryTranslatorFactory
16:09:33,747  INFO SettingsFactory:252 - Query language substitutions: {}
16:09:33,750  INFO SettingsFactory:257 - JPA-QL strict compliance: disabled
16:09:33,752  INFO SettingsFactory:262 - Second-level cache: enabled
16:09:33,754  INFO SettingsFactory:266 - Query cache: disabled
16:09:33,757  INFO SettingsFactory:405 - Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
16:09:33,759  INFO RegionFactoryCacheProviderBridge:61 - Cache provider: net.sf.ehcache.hibernate.EhCacheProvider
16:09:33,762  INFO SettingsFactory:276 - Optimize cache for minimal puts: disabled
16:09:33,764  INFO SettingsFactory:285 - Structured second-level cache entries: disabled
16:09:33,766  INFO SettingsFactory:314 - Statistics: disabled
16:09:33,769  INFO SettingsFactory:318 - Deleted entity synthetic identifier rollback: disabled
16:09:33,771  INFO SettingsFactory:333 - Default entity-mode: pojo
16:09:33,774  INFO SettingsFactory:337 - Named query checking : enabled
16:09:33,869  INFO Version:20 - Hibernate Search 3.1.0.GA
16:09:35,134 DEBUG DocumentBuilderIndexedEntity:157 - Field selection in projections is set to false for entity **com.xyz.abc**.
recognized hibernaterecognized hibernaterecognized hibernaterecognized hibernaterecognized hibernaterecognized hibernaterecognized hibernaterecognized hibernaterecognized hibernaterecognized hibernateDocumentBuilderIndexedEntity

Donno what the last line indicates ??? (hibernaterecognized....)
After the last line it doesnt do anything (no trace too ) and just hangs....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

椵侞 2024-09-03 13:27:59

您需要向我们提供更多信息。您可以进行线程转储并显示日志的最后几行吗?

有可能是:
- 您的实体之一正在提出问题
- 某些锁或文件挂起(您使用的是哪个操作系统?某些限制并行打开的文件数量)

对于后者,如果在 linux 或 unix 上,您可以尝试使用

ulimit -n <number>

另外请确保您不时运行索引优化器到时间(检查 Hibernate Search 参考文档)。

You will need to give us more information. Can you take a thread dump and show the last few lines of your logs?

It's possible that either:
- one of your entity is posing problem
- some lock or file is hanging (which OS are you using? some limit the number of files open in parallel)

For the later, if on linux or unix, you can try to play with

ulimit -n <number>

Also make sure you run the index optimizer from time to time (check the Hibernate Search ref doc).

不顾 2024-09-03 13:27:59

我发现了问题所在。我没有注释我的超级类。我有一个类,它是几乎所有其他模型类的基类。
但奇怪的是,hibernate search 没有给出任何错误或警告......
我尝试了一个技巧来找到它实际悬挂的位置。
我在一个单独的线程中构建了 sessionfactory,并每 10 秒打印一次线程的跟踪。
令我惊讶的是,它实际上没有挂起,但堆栈跟踪正在更改,并且它始终位于注释反射包类中。

只是为了检查一下,我看到了我的超级类并对其进行了注释,瞧......它起作用了......

@Emmanuel Bernard:你能确认一下为什么 hibernate search 之前没有给出任何跟踪或错误吗?上吊了??

I found out the problem. I had not annotated my super class.I have a single class which is the base class for almost all my other model classes.
But it is strange that hibernate search did not give any errors nor warnings...
I tried a trick to find where actually it was hanging.
I built the sessionfactory in a separate thread and printed the Thread's trace every 10 odd secs.
To my surprise it actually did not hang, but the stacktrace was changing, and it always was in annotaion reflection package classes.

Just to check ,I saw my super class and annotated it, and voila......it worked......

@Emmanuel Bernard: Can you just confirm why did hibernate search not give any trace or error before and just hanged??

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文