Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade the hibernate-validator 4.3.0.Final to the Glassfish 3.1.2?

At the moment, the Hibernate Validator has released the latest version as 4.3.0.Final here. I have tried to upgrade it to my Glassfish 3.1.2 as the following step: -

1. Remove the GLASSFISH/glassfish/modules/bean-validator.jar
2. Copying the hibernate-validator-4.3.0.Final.jar to GLASSFISH/glassfish/modules
3. Restart the Glassfish
4. The Glassfish cannot start. It seems hang.

After searching via the Google, I've found that the file named "bean-validator.jar" was created by the Glassfish team as an OSGi version. Sadly, I cannot find how to create it. Could you please help to advise further? Thank you very much for your help in advance. I'm looking forward to hearing from you soon.

like image 387
Charlee Chitsuk Avatar asked May 11 '12 09:05

Charlee Chitsuk


2 Answers

A (slightly outdated) description of how to build Glassfish's bean-validator.jar can be found here.

What's needed in general is an OSGi bundle which includes Hibernate Validator itself and the Bean Validation API. With this bundle you should be able to replace the original bean-validator.jar. Additionally you need the JBoss Logging bundle, which is used since release 4.3 by Hibernate Validator as logging API and already comes in form of an OSGi bundle.

If you're building a web application, you could also package HV 4.3 within your WAR and turn off class loader delegation by providing the file WEB-INF/glassfish-web.xml with the following contents:

<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <class-loader delegate="false" />
</glassfish-web-app>

That way the HV classes will be loaded from your application instead of from the module provided by Glassfish.

You might also be interested in the issue GLASSFISH-15648 which aims to provide a dedicated Glassfish update package for HV.

like image 105
Gunnar Avatar answered Nov 03 '22 12:11

Gunnar


As my case was ear, rather than war, based on suggestion of Gunnar, I did a patched version of the module, that is deployable to Glassfish (My version is 3.1.1 OSE).

Someone might find it still useful, see my blog for my solution (including step-by-step approach): http://peter-butkovic.blogspot.de/2012/11/glassfish-311-oss-with-hibernate.html

like image 36
Peter Butkovic Avatar answered Nov 03 '22 12:11

Peter Butkovic