Monday, 15 March 2010

Advantages of Spring and Hibernate Integration

"Spring Integrates very well with Hibernate". So what? One might think. Spring integrates very well with lots of technologies, what benefits we get out of Hibernate integration. I'm trying to list out important benefits that applications get from Spring and hibernate integration.

1. Services layer

The most important benefit is the Spring framework itself. Because of the Spring integration, applications can leverage all the features of spring framework. For example POJO style serve interfaces, IoC, Aspects, Remoting etc...

Spring framework provides all these features out-of-box. And a good thing about Spring framework is that it's really easy to plug any custom component into the framework.

With spring POJOs, IoC and Remoting it's very easy to develop services layer. Otherwise, we need to implement EJB Session Bean (stateful or stateless) or depend on the frameworks like JSF, Struts or Servlets to implement the business logic which is not ideal. All of these frameworks business logic from Presentation layer or tedious to develop and maintain (Struts, for example).

2. HibernateTemplate

Spring provides template for managing sessions, transaction across the application. Without the hibernate template, applications need to manage these on their own.

Note:
With the Hibernate 3.0.1, Spring can manage the transactions and session management across the application without the template. Only thing you don't get without Hibernate template is Exception translation. But there are other options.

3. HibernateDaoSupport

Spring provides a class called HibernateDaoSupport. DAO Implementation class implements this class to get all the convenience methods that HibernateTemplate provides. If applications are not using HibernateTemplate, then it's good to take advantage of HibernateDaoSupport.

Note: Important thing to note is that any DAO wants to use HibernateDaoSupport needs to extend the class. So, it's always better to have a generic DAO that is super class for all the DAO's in the model and super class extends HibernateDaoSupport.

4. DAOException Translation

Hibernate 3 throws Runtime exceptions unlike checked exceptions thrown in the previous releases. Spring can translate these exceptions into SpringDAO exceptions and map them into Spring DAO exception hierarchy. But you have to use one of the following to get this

1. Use HibernateTemplate
2. @Repository

We discussed about the template earlier. Now let us look at the @Repository

@Repository annotation is auto-detected by the Spring’s exception translator post processor and does the transforms Hibernate exceptions into Spring DAO exceptions.

In this way you can go template-less in your spring hibernate development.

5. MVC Integration

If you are using Hibernate in you web application, which is using Spring MVC, then you can use the OpenSessionInViewFilter or OpenSessionInViewInterceptor and not create sessions per thread, instead create a session per Request.

Above are the important advantages that applications out of Spring integration with hibernate.










Tuesday, 24 February 2009

Error in CTS Docbase Configuration

Documentum CTS (Content Transformation Services) service error:

Below one is the common error that cause CTS service to stop.

ERROR

13:26:55,118 INFO [ main] CTSServerHandlerImpl - *************** Content Transformation 5.3 - Release Build 0.206 ICTSService Framework startup initiated. ***************
13:26:55,587 ERROR [ main] CTSServerHandlerImpl - Unable to start the default handler.
com.documentum.cts.exceptions.internal.CTSServiceManagerException: Unable to start the default handler.
Cause Exception was: A new instance of ICTSService with SUBTYPE = CTSPLUGIN could not be created
com.documentum.cts.exceptions.internal.CTSServiceException: Unable to start the default handler.
at com.documentum.cts.impl.services.CTSServiceBaseImpl.startAll(CTSServiceBaseImpl.java:930)
at com.documentum.cts.impl.services.CTSServiceBaseImpl.start(CTSServiceBaseImpl.java:565)
at com.documentum.cts.services.CTSServiceManager.getServiceBySubType(CTSServiceManager.java:545)
at com.documentum.cts.impl.services.ctsserver.CTSServerHandlerImpl.getMediaPluginHandler(CTSServerHandlerImpl.java:1165)
at com.documentum.cts.impl.services.ctsserver.CTSServerHandlerImpl.start(CTSServerHandlerImpl.java:559)
at com.documentum.cts.impl.services.CTSServiceBaseImpl.startAll(CTSServiceBaseImpl.java:925)
at com.documentum.cts.impl.services.CTSServiceBaseImpl.start(CTSServiceBaseImpl.java:565)
at com.documentum.cts.services.CTSServiceManager.registerServices(CTSServiceManager.java:268)
at com.documentum.cts.services.CTSServiceManager.bootstrapServiceFramework(CTSServiceManager.java:161)
at com.documentum.cts.services.CTSServiceManager.getInstance(CTSServiceManager.java:118)
at com.documentum.cts.services.ctsserver.CTSServerStartup.main(CTSServerStartup.java:107)

Enable the dmcl.trace in dmcl.ini
trace_file =
trace_lvel=

Cause: CTS not configured properly for one of the docbases.

Solution:
1. Find out the docbase from CTS logs
2. Delete the configuration for that docbase (make sure profiles are deleted from docbase under System/MediaServer)
3. Configure CTS for the docbase again

Monday, 23 February 2009

How to deploy webservice on WAS V6.0?

This article details the steps required to deploy webservice on Websphere Application Server(WAS) V6.0 on a developemnt environment and test it.

WAS V6.x implements the JAX-RPC 1.1 specification. WAS has multiple implementaitons of webservices stack. WAS websphere implentation supports JAX-RPC, JAX-WS.

Since V5, a derivative of Apache Axis 1.0 has been used in WAS. There is buil-in webservices engine that supports Axis.


I am goign to talk about deplying webservice developed using Axis, though it will be same for any webservice developed on technology that supports JAX-RPC.

Deploy webservice as EAR:

To deploy Web services that are based on the Web Services for Java 2 Platform, Enterprise Edition (J2EE) specification, you need an enterprise application, also known as an enterprise archive (EAR) file that is configured and enabled for Web services. Deploying webservice as a EAR files is the easiest way.

Steps


  1. Login Admin Console




  2. Click Applications.


  3. Click Install New Application.






  4. Click on the Browse button to locate the UserAdmin.war file.


  5. Then type in the context name you want to access the servicenam



  6. Click Next and keep the default values in the Generate Default Bindings page.


  7. Ignore the security warning in the Application Security Warning page and click Continue.


  8. In the first step keep all default values and just check the Deploy Web Services option.
    Keep default values in step 2, 3 and 4. If you wish to change the host



  9. Click Finish.


  10. Click Save to Master Configuration.


  11. Click Save.


  12. Browse through the list of applications in Applications - > Enterprise Applications.


  13. Find the Webservice name and Start the application.


Testing

To test the webservice that we just deployed, we should have a client application. There are numerous tools out there which make our task easier. One of such popular tools is 'SOAPUI'.Learn more about it http://www.soapui.org/. Install a free version.And follow the instructions to access the EndPoint.


Virtual Hosts & PORTS

A virtual host is a configuration enabling a single host machine to resemble multiple host machine. Virtual hosts enable you to isolate, and independently manage, multiple sets of resources on the same physical machine.

Each virtual host has a logical name and a list of one or more DNS aliases by which it is known. A DNS alias is the TCP/IP host name and port number used to request the servlet, for example yourHostName:80. When no port number is specified, 80 is assumed.


By defaut WAS comes with 2 virtual hosts, admin_host and default_host. Each virtual host will have a set of ports as aliases. These can be viewed on Environment -> Virtual Hosts > admin_host > Host Aliases. You should know the port on which the webservices engine is running to access the webservice.

For example on WAS V6.0, webservices engine is on 10000. So a service named 'TestService' can be accessed as below end point:

http://localhost:10000/WebServices/services/TestService and add '?wsdl' to the link for viewing the WSDL definition of the WebService.
























Saturday, 21 February 2009

Rename a Docbase

Why to Rename?

Renaming the Docbase is helpful in the following situation:

1.During Migration
2.Setting up new content server environment
3.Data refresh

Often, Documentum Administrators need to setup a new content server environment, other than Production, like, Staging, Test, UAT etc.... Also need a time to time refresh of data in order to have maintain an up to date UAT environment or a Staging environment.

Administrators usually take a snapshot of the production. It would be quite helpful to have a different docbase names in different environments.

Administrators tasks:

1. Restore the database on the target database server with a new name (or same as in source).
2. Change the docbase owner (if required)
3. Run following queries

Update acl_domain

Update dm_sysobject_s set acl_domain='NewDocbaseName' where acl_domain='OldDocbaseName'

Update Object_Name docbase_config_object

Update dm_sysobject_s set object_name = 'NewDocbaseName' where object_name='OldDocbaseName' --> implies change of AEK.key

Update dm_sysobject_s set owner_name= 'NewDocbaseName ' where owner_name='OldDocbaseName'

Update r_host_name:
update dm_server_config_sset r_host_name = 'newservername' where r_host_name = 'oldservername'

Update r_install_domain:

update dm_server_config_s set r_install_domain = 'newservername' where r_install_domain = 'oldservername'

Update web_server_loc:

update dm_server_config_sset web_server_loc = 'newservername' where web_server_loc = 'oldservername'

Update projection_targets:

update dm_server_config_rset projection_targets ='newservername' where projection_targets = 'oldservername'

Update projection_notes:

update dm_server_config_rset projection_notes = 'newservername' where projection_notes = 'oldservername'

Update target_server on jobs:

update dm_job_s set target_server = 'newdocbase_name.newdocbase_name@newservername' where target_server = 'olddocbase_name.olddocbase_name@oldservername'

Update user_os_domain:

update dm_user_s set user_os_domain = 'newservername' where user_os_domain = 'oldservername'

Update user_login_domain:

update dm_user_s set user_login_domain = 'newservername' where user_login_domain = 'oldservername'

Check if any user_global_uique_id has the old server name:

Select user_name, user_global_unique_id from dm_user_s where user_global_unique_id like 'oldservername:%'

If so update them by:

update dm_user_s set user_global_unique_id = ':user_name' where user_global_unique_id = 'newservername:user_name'

Update Mount point

update dm_mount_point_s set host_name='newservername' where host_name = 'newservername'
Update dm_location_s:

select file_system_path
from dm_location_s where file_system_path like 'D:\Documentum\data\olddocbase%'

Update each entry with the new docbase name.

Update do_mail, do_method links in the dm_server_config

Developer Tasks:
In order to make sure that name change doesn't affect the client applications, developers should not hard code following in code

1. Docbase name
2. Docbase owner name (get it from the IDfSession)
3. ACL domain of public ACLs