【问题标题】:Virgo Hibernate ClassNotFound处女座 Hibernate ClassNotFound
【发布时间】:2012-10-17 18:13:48
【问题描述】:

我正在尝试将示例应用程序部署到 virgo(我将第三方 jar 文件放在存储库/usr 上)。经过几个小时的解决项目依赖关系后,我得到了“org.springframework.orm.hibernate3.LocalSessionFactoryBean”的ClassNotFound,所以我在清单上添加了spring-orm依赖。问题得到了解决,但这次我得到了“org/hibernate/cfg/Configuration”的 NoClassDefFound。所以我在清单中的捆绑包上添加了“com.springsource.org.hibernate.core”,但没有任何反应: ... 引起:java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration 在 org.springframework.orm.hibernate3.LocalSessionFactoryBean.(LocalSessionFactoryBean.java:189) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance(未知来源) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(未知来源) 在 java.lang.reflect.Constructor.newInstance(未知来源) 在 org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) ...省略了20个常用框架 我不知道在哪里寻找可疑的东西!请帮帮我:|

【问题讨论】:

    标签: hibernate osgi classnotfound


    【解决方案1】:

    您需要特定于 Hibernate 的 jar。 Spring-ORM jar 只提供与 Hibernate 的集成。您仍然需要来自 Hibernate 的包含这些类的实现的实际 jar。希望这会有所帮助。

    【讨论】:

    • 我在存储库中有 hibernate jar 文件,如果找不到它们,我会得到 UnsatisfiedException 或类似的东西!
    • 你会得到 ClassNotFound 或 NoClassDefFound。您需要确保 Spring 和 Hibernate 的版本可以一起工作。缺少 Org.hibernate.cfg.Configuration。我已经多次遇到这个问题,通常是 Spring 期待一个特定的版本。打开 Hibernate jar 以查看该类是否存在。
    • 去过那里,做到了!我认为这里的问题是指处女座。你用过处女座吗?
    • 是的,问题是 Virgo 没有找到正确的类 java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration at org.springframework.orm.hibernate3.LocalSessionFactoryBean。
    【解决方案2】:

    需要查看hibernate jar包是否提供osgi模式,如果没有,需要使用maven-bundle-plugin插件重新打包。您需要在 META-INF 文件夹中查看 manifest.mf。 .mf 文件错误或不足:

    Manifest-Version: 1.0
    Implementation-Vendor: The Redisson Project
    Implementation-Title: Redisson/All-in-One
    Implementation-Version: 2.10.1
    Implementation-Vendor-Id: org.redisson
    Built-By: root
    Build-Jdk: 1.7.0_55
    Specification-Vendor: The Redisson Project
    Specification-Title: Redisson/All-in-One
    Created-By: Apache Maven 3.5.0
    Implementation-URL: http://redisson.org
    Specification-Version: 2.10
    Main-Class: org.redisson.RedissonNode
    

    .mf文件中:它所依赖的所有包都在Import-Package下,所有用户都可以使用Export-Package下的包,以上文件不包含这些

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-01
      • 1970-01-01
      • 2014-08-11
      • 2012-02-24
      • 2011-04-17
      • 2012-08-10
      • 1970-01-01
      • 2011-11-12
      相关资源
      最近更新 更多