【问题标题】:Weird ClassNotFoundException in WebLogic 10.3.6WebLogic 10.3.6 中奇怪的 ClassNotFoundException
【发布时间】:2013-06-12 07:57:48
【问题描述】:

我们有一个在 WebLogic 10.3.6 应用服务器中正常运行的 .ear 文件。 .ear 使用 Spring 3.0.5 和 Hibernate 3.5.2。

如果我们在另一个 WebLogic 10.3.6 服务器中部署相同的 .ear 文件,我们会收到下一个错误。

org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'filterService': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private nl.surf.adapter.generic.dao.MessageFilterDAO nl.surf.adapter.generic.service.FilterService.messageFilterDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/domain-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private nl.surf.adapter.generic.dao.MessageFilterDAO nl.surf.adapter.generic.service.FilterService.messageFilterDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/domain-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/domain-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
Caused by: java.lang.NoClassDefFoundError
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration

我尝试了几种解决方案:

  • 将 hibernate3.jar 放在 .war/WEB-INF/lib 中(所有 jars 现在都在 .ear/lib 中)
  • 在 .war/WEB-INF/weblogic.xml 中使用 true

似乎没有任何效果。 我有点迷路了……

【问题讨论】:

  • 自己解决了这个问题。还不能回答,明天再回答吧。
  • 我在抛出的异常中看到,web.xml 中缺少休眠注释引导。对吗?
  • 我在使用 Velocity 时遇到了同样的问题。我对解决 org/apache/velocity/app/VelocityEngine 的 NoClassDefFoundError 问题的方法很感兴趣。

标签: spring hibernate weblogic


【解决方案1】:

在网络上进行大量搜索并在 .ear 上进行反复试验后,我找到了解决问题的方法。

我已更改文件 META-INF/weblogic-application.xml 并在标签 下添加了标签

<prefer-application-packages>
  <package-name>org.apache.*</package-name>
  <package-name>antlr.*</package-name>
</prefer-application-packages>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-25
    • 1970-01-01
    • 2014-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多