I'm reviewing pom.xml of an old project which I'm trying to run on Jboss AS 7.1.1. This pom contains a lot of dependencies with artifacts like:
- hibernate-core
- hibernate-validator
- hibernate-jpa-2.0-api
- hibernate-entitymanager
- ...
As Jboss 7.1.1 has a module org.hibernate
I've managed to remove these dependencies except of hibernate-core
by creating \META-INF\jboss-deployment-structure.xml
with following content:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<deployment>
<dependencies>
<module name="org.hibernate"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
So in order to be able to compile WAR file I need to have this dependency
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
but I can't understand why I can't set it with provided
scope. If it is included in org.hibernate
module, why I can't do so? If I set it as provided
, I'm getting the following error:
Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration
I want to set it with provided
scope just to exclude it from WAR file
Instead of jboss-deployment-structure.xml if you are using maven in project better to provide hibernate and supported module as manifest entry. you can achieve this by following code in pom.xml
then add your other required dependencies with the scope provided so they can be loaded at run time with out bundling in war, use following as an example.