2015-12-09 49 views
1

當前正試圖在Jboss EAP 6.4上構建應用程序的部署,但出現以下錯誤。使用提供的hibernate-core時未找到類

Caused by: java.lang.NoClassDefFoundError: Lorg/hibernate/Session; 
     at java.lang.Class.getDeclaredFields0(Native Method) [rt.jar:1.8.0_66] 
     at java.lang.Class.privateGetDeclaredFields(Class.java:2583) [rt.jar:1.8.0_66] 
     at java.lang.Class.getDeclaredFields(Class.java:1916) [rt.jar:1.8.0_66] 
     at org.jboss.seam.Component.initMembers(Component.java:560) [jboss-seam-2.3.1.Final.jar:2.3.1.Final] 
     at org.jboss.seam.Component.<init>(Component.java:244) [jboss-seam-2.3.1.Final.jar:2.3.1.Final] 
     at org.jboss.seam.Component.<init>(Component.java:205) [jboss-seam-2.3.1.Final.jar:2.3.1.Final] 
     at org.jboss.seam.init.Initialization.addComponent(Initialization.java:1255) [jboss-seam-2.3.1.Final.jar:2.3.1.Final] 
     ... 14 more 
Caused by: java.lang.ClassNotFoundException: org.hibernate.Session from [Module "deployment.test.war:main" from Service Module Loader] 
     at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.6.Final-redhat-1] 
     at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.6.Final-redhat-1] 
     at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.6.Final-redhat-1] 
     at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.6.Final-redhat-1] 
     at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.6.Final-redhat-1] 
     ... 21 more 

我有以下依賴關係,我認爲會使用內置到jboss模塊中的休眠。有什麼我失蹤或做錯了嗎?

<dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
      <version>4.3.2.Final-redhat-2</version> 
      <scope>provided</scope> 
    </dependency> 
+1

您是否嘗試過將模塊依賴添加到'jboss-deployment-structure.xml'或您的'MANIFEST.MF'中? –

回答

1

你有三個選擇:

  • 變化範圍,以編譯讓行家添加在你的應用程序的類路徑休眠庫;
  • 在WEB-INF文件夾添加JBoss的部署,structure.xml文件與org.hibernate作爲模塊dependecy在內,像這樣:

    <jboss-deployment-structure> <deployment> <dependencies> <module name="org.hibernate" /> </dependencies> </deployment> </jboss-deployment-structure>

  • 在你的POM文件,在該結構中添加以下的插件,使得行家添加在MANIFEST.MF文件上述依賴性:

    <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <archive> <manifestEntries> <Dependencies>org.hibernate</Dependencies> </manifestEntries> </archive> </configuration> </plugin> </plugins>

相關問題