JBoss Community

Re: Running Seam 2 archives on Jboss 7

created by jaikiran pai in JBoss AS7 Development - View the full discussion

Matt Drees wrote:

 

Ales Justin wrote:

 

but my test app is quite old so it failed to find some HibValidator class.

 

To get my app running I had to bundle org.hibernate:hibernate-validator-legacy:4.0.2.GA with my app.  It was provided on AS6, I think, but it's not available on AS7, apparently.

 

 

The way classloading works in AS7 is different from what was in previous versions. Here's a quick intro:

 

https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7

https://docs.jboss.org/author/display/AS7/Implicit+module+dependencies+for+deployments (work in progress article)

 

To briefly summarize the behaviour, I'll just copy/paste a message that I sent out in some other discussion:

 

Classloading has changed drastically in AS7. In earlier versions of JBoss AS, if an application did not package a jar for some dependent code (like logging) then the classloading system would delegate loading of that class to the "parent" classloader which would pick it up from the server level jars which we ship (example: log4j jars). More details about the classloading in previous versions can be found here http://community.jboss.org/wiki/JBossClassLoadingUseCases.

 

Now in AS7, the classloading system is based on module classloaders. Each application will have a module classloader associated with it and the "module" specifies it's "dependencies" on other module. Each module is a collection of classes and resources. In the early stages of deployment processing, a deployment in AS7 by default doesn't have any module dependencies, unless explicitly specified (see later part of the mail on how to do it). The deployment processing implementation code implicitly adds some module dependencies based on what kind of a application is being processed. For example, if the deployment has EJBs, then the deployment processing code explicitly adds a dependency on Java EE module. So effectively, all the Java EE API classes are now "visible" to this deployment and can be loaded by the classloader associated with this deployment. Furthermore, all the jar contained in the .war/WEB-INF/lib or .ear/lib are added to the module dependencies. If an application depends on some other library which isn't part of this set, then it has to be explicitly specified as a module dependency by the application developer. This can be done via the MANIFEST.MF file which should contain a "Dependencies" attribute as follows:

 

Dependencies: org.hibernate.validator

 

In this example, the application is specifying a dependency on the "org.hibernate.validator" module (note that the module name and the package name need not always match. Module name can be arbitrary and is defined in the module.xml of the module. See JBOSS_HOME/modules folder and subfolders for examples).

 

Similarly, in your example, you'll have to setup an explicit dependency on the Hibernate validator module. If you don't want to add this dependency explicitly, then packaging those jar files within the .war/WEB-INF/lib (or .ear/lib) should get you past these issues (like it did in your case)

Reply to this message by going to Community

Start a new discussion in JBoss AS7 Development at Community