Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
As some of you have noticed, our previous Java EE 5 compatible releases had problem incoroprating the famous Hibernate framework. Portability is important for us, so I am happy to explain how one can use Hibernate with our CE release. Update: The feature is available on the 2007 JavaOne DVD, which unfortunatelly is not availabe for download at this moment (04/06/2007). CE 1.0 SP1 will also contain this feature; the feature is not available on CE 1.0 SP0, downloadable at the moment on the service marketplace. In our engine we use parent-first rule when loading resources. Components are coupled on classloading level by creating the respective parent-child classloader hierarchy. While this approach gives us predictable and simple hierarchy, it causes inconveniences in some rare cases. The Hibernate scenario is such case. We took some time to think how similar problems can be solved in the future - we wanted to have generic solution, not just local fix. Alternatives were to introduce some filtering concept or to restructure our classloaders. With thousands of applications deployed, forming layers of frameworks, one has to think about predictability of the classloading behaviour - supportability is valuable asset. On the other hand, restructuring was not needed, just slight extension in few scenarios. This quickly led to the decision to extend the classloading structure of the apps in the manner I will describe below. I will skip number of details, as I know you are eager to finally run that Hibernate application. Here we go...
What we need is to get the Hibernate classes loaded with the highest priority, no matter what classloading dependency our application has specified. For this purpose, the heavy resources classloader is introduced, working in the following manner :
  • created with the resources located in the lib folder in the root if the ear, only when the application version is Java EE5
  • first in the parent list. This guarantees the following delegation order when loading a resource :
    1. heavy loader (and it's parent respectively)
    2. default references, specified by the containers during deploy. Usually contain the standard Java EE APIs
    3. application specific references (specified in the application-j2ee-engine.xml)
    4. all other application resources contained in the EAR
You need to do two things in order to run your Hibernate application :
  1. Pack the Hibernate framework as shared library (see Applications and shared libraries) or as part of your application. My advice is to pack it as shared library if you have more than one application, using it. In both cases it is mandatory that the application packing the Hibernate binaries :
    • is Java EE 5 one
    • all the Hibernate jars are located in the /lib folder.
    • the EAR contains application-service.xml (even if practically empty) - this is achieved by adding the SAP Application Library Container facet to your project
  2. Switch on the Heavy loaders behaviour as it is switched off by default :
    • start the Config tool
    • change the Define_Heavy_Resources property of the library_container to true; save the change
    • restart the whole instance for the change to take effect
    • deploy your application(s)
  3. Check that the heavy loader is created and contains all Hibernate jars. I assume you packed Hibernate as shared library in application named com.vendorX/Hibernate :
    • using telnet, issue >ll | grep com.vendorX/Hibernate
    • you should get as output two classloaders [com.vendorX/Hibernate] [com.vendorX/Hibernate-library-loader] The second one is the heavy classloader - check via the llr command that it contains all related jars. In the example I have (Thank Adrian) it looks like this : >llr com.vendorX/Hibernate-library-loader   Loader name:     [com.vendorX/Hibernate-library-loader]   Direct parent loaders:     [library:javax~persistence~api]     [library:ejb_api]   Direct child loaders:     [com.vendorX/Hibernate]   Resources:    C:usrsapCE1...app_libraries_containerlibjboss-archive-browsing.jar     C:usrsapCE1...app_libraries_containerliblucene-core-2.0.0.jar     C:usrsapCE1...app_libraries_containerlibasm-attrs.jar     C:usrsapCE1...app_libraries_containerlibantlr-2.7.6.jar     C:usrsapCE1...app_libraries_containerlibcommons-collections-2.1.1.jar     C:usrsapCE1...app_libraries_containerlibcommons-logging-1.0.4.jar     C:usrsapCE1...app_libraries_containerlibjavassist.jar     C:usrsapCE1...app_libraries_containerlibhibernate3.jar     C:usrsapCE1...app_libraries_containerliblog4j-1.2.11.jar     C:usrsapCE1...app_libraries_containerlibhibernate-annotations.jar     C:usrsapCE1...app_libraries_containerlibhibernate-entitymanager.jar     C:usrsapCE1...app_libraries_containerlibcglib-2.1.3.jar     C:usrsapCE1...app_libraries_containerlibehcache-1.2.jar     C:usrsapCE1...app_libraries_containerlibdom4j-1.6.1.jar     C:usrsapCE1...app_libraries_containerlibasm.jar
With this, I hope you have enough knowledge to port your applications to our engine.
6 Comments