Wednesday, May 20, 2009

SAP Portal - FAQ 2

1. What is SAP Enterprise Portal?
SAP EP offers users role-specific, Web-based and secure access to all relevant information, applications and services. Employees only need a desktop and a Web Browser, and can begin work once they have been authenticated in the portal.

2. What components does SAP Enterprise Portal contain?
SAP Enterprise Portal contains the NetWeaver components Portal, Knowledge Management, and Collaboration. In addition, SAP provides pre-defined content. At the moment the portfolio contains more than 100 business packages, which are shipped in multiple languages.

3. What is the relationship between Web Dynpro and SAP Enterprise Portal? Are iViews and Web Dynpro competing technologies?
Web Dynpro is SAP's programming model for developing professional and interactive Web user interfaces for business applications.

An iView is a logical portal content module representing a visual application or part of one. One or more iViews are combined on a portal page, which is then assigned to users by the role definition. Web Dynpro UIs are integrated in SAP Enterprise Portal with iViews.

4. What personalization functions does SAP Enterprise Portal provide?
Portal roles are a central element of SAP Enterprise Portal. They structure the content and are defined for specific end users.

A role is a collection of task-specific content. Roles are defined based on responsibilities and areas of interest, and are created by a role administrator. A user can be assigned one or more roles (for example, the roles employee and staff). The roles define the content of the portal navigation as well as the content of the portal. Role assignment can therefore be seen as a pre-personalization of the portal - a personalization that is performed by the administrator and not by the user (personalization level 1). Depending on their permissions, users can also adjust the look and feel of the portal, maintain user-specific attributes (personalization level 2), change portal pages by adding or deleting iViews (personalization level 3), and personalize individual iViews (personalization level 4).

5. What tools does SAP provide for creating portal content?
SAP provides tools for creating and developing portal content, depending on the target group and the complexity of the applications.

One distinguishes between

Portal Content Studio: An administration environment integrated in SAP Enterprise Portal that is used for code-free development of portal content using wizards.

SAP NetWeaver Visual Composer: Model-based development of portal content by simply using graphic tools.

SAP NetWeaver Developer Studio (Web Dynpro perspective): Based on the powerful Web Dynpro programming model, application developers can develop Web user interfaces for professional business applications.

SAP NetWeaver Developer Studio (J2EE + PDK perspective): The SAP NetWeaver Developer Studio offers complete support when developing Java projects.

SAP ABAP Workbench: The ABAP Workbench provides the Business Server Page (BSP) technology for creating Web user interfaces.

All the portal content created using these tools can be seamlessly integrated in SAP Enterprise Portal using the portal services already presented.

6. What are the key features of the portal?
The portal is more than just a "page paste" and different services for handling the interaction between iViews. Typical examples for the integration technology are:

Client Eventing: Enables iViews to communicate with one another at the client side and to communicate with the portal itself.

Work Protect: Function providing an infrastructure for handling unsaved data in portal applications, for example if users navigate in the portal without first having stored their entries in an application.

Session Management: Contains in particular the session persistence to retain the last session status of the user (for example when navigating to another portal page) as well as a server session termination function for releasing resources on the backend system (for example when closing the browser).

Portal Navigation: SAP Enterprise Portal offers more than simply navigation between individual portal pages, in particular.

Object-based navigation (OBN): It provides users with a navigation feature based on the actual business objects from productive backend systems.

Drag&Relate: iViews can contain objects representing business elements of a backend application (for example customer). If users pull such an object, as with Drag&Drop, and relate it to another object in the Drag&Relate target object area, they can navigate between different applications containing similar, but not identical business objects.

Dynamic Navigation: The portal enables you to assign navigation objects to pages and iViews as context-sensitive dynamic navigation iViews. This means that navigation targets are provided dynamically depending on the action selected.

7. Which security features does SAP Enterprise Portal offer?
The portal offers the following security features to help keep your portal secure.

Authentication: When users access the portal, they must provide some form of identification in the form of user ID and password, client certificates, and so on. The portal supports authentication with user ID and password, X.509 certificates, integrated Windows authentication, external Web access management tools.
Single Sign-On: Once users have successfully logged on to the portal, they can access all information, applications, and services without repeatedly having to log on.

Authorization: ACL-based permissions ensure that users can only access portal objects for which they have the required authorization. Authorization for applications integrated in the portal are handled by the systems on which the applications run.

User Management: Existing corporate LDAP directories in your system landscape can be leveraged by the portal. Alternatively user data can be retrieved from a SAP Web Application Server ABAP or from a database.

Secure Communications: Secure Sockets Layer (SSL) and Secure Network Communications (SNC) can be used to build a secure channel between the user's Web browser, the portal server, and backend systems.
Secure network architecture: Recommendations for a secure network architecture for the portal are available in the Portal Security Guide.

Security logging: Security-relevant events such as user logon, or changes to permissions, are logged.

8. How is user management implemented in SAP Enterprise Portal?
The portal uses the 'User Management Engine' (UME) which is an integral part of SAP Web Application Server Java. The UME manages user and user-related data (roles, groups) which can be retrieved from an LDAP directory, a SAP Web Application Server Java, a database, or a combination of these. Administration tools allowing you to manage users, groups, and roles are integrated in the portal user administrator role. A configuration tool for configuring the UME is integrated in the portal system administrator role.
In addition, the UME provides many features such as self-registration with approval workflow, notification emails, and so on.

9. How can I integrate the user management of the portal with that of other systems?
The portal user management is very flexible and allows you to use a variety of repositories for storing and retrieving user data. In particular, it allows you to leverage existing user repositories in your system rather than having to set up a new user repository.

For example, if you are using your portal in a system landscape that includes many non-SAP systems, you can provide a central user base using an LDAP directory and configure the portal to use the LDAP directory as its user repository.

On the other hand, if you are using your portal in a system landscape that consists of SAP systems only, you can set up Central User Administration (CUA) on one of the ABAP-based systems and configure your portal to use the ABAP user management as its user repository.

SAP Portal - FAQ 1

1) Accessing a Portal Component in the Default Mode?
Ans: doContent();

2) Extending class when Developing your Portal Components?
Ans: AbstractPortalComponent.

3) Portal Runtime calls the methods in the Life Cycle
Ans: init(), service(), destroy()

4) What are the Parameters that we have to pass to doConent();
Ans: IPortalComponentRequest ,IPortalComponentResponse;

5) How do u access a Resource from a request object
Ans: request.getResource();

6) Personalization concept what are the data type, the type attribute supports
Ans : String , Date , Select , Boolean (however, the Date does not work in my try out)

7) How do u get the property from the IPortalCompenentProfile
Ans : getProperty(String)

8) What is the method has to be overridden by the class that extends from PageProcessorComponent
Ans : getPage(); A static inner class extends JSPDynPage and in getPage, new the inner class.

9) Give the sequence of methods execution of DynPage
Ans :
1) doInitialization()
2) doProcessAfterInput()
3) doProcessBeforeOutput()

10) sequence of method calls when an event occurs
Ans :
1) doProcessAfterInput()
2) on[eventhandlername]
3) doProcessBeforeOutput()

11) how do u get the getCurrentEvent();
Ans :
IPageContext myContext = PageConectFactory.createPageConext(request,responce);
Event = myContext.getCurrentevent();

12) onClientClick() and onClick() are specified then which method will be called first
Ans : onClientClick();

13) JSPDynPage uses _________ type of approach
Ans : Model View Controller

14) The two properties in the component profile indicate that a JSP need to be compiled into portal component :
Ans :
Property name = JSP
Property name = ComponentType

15) Which one is true in the following statement
a) <%@ taglib uri = hbj prefix = htmlb>

b) <%@ taglib uri = hbj prefix = hbj>

c) <%@ taglib uri = hbj prefix = htmlb>

d) <%@ taglib uri = htmlb prefix = hbj>

Ans : a ( I think the answer shall be d.)

16) How do u call a jsp file :
Ans : setJspName();

17) If java Script are used _______tag is necessary for the page
Ans : Page tag

18) Which tag is used for including bean in the jsp file
Ans : [jsp:]

19) What is the scope of the bean
Ans : Session

20) Give the objects that are extend form the IPrincipal
Ans : IGroup, IRole, IUser, IUserAccount, IUserMaint,

21) ____is the Central object from which all UME object factories are obtained
Ans : UMFactory

22) IUser user = UMfactory.getUserfactory().getUserbyLogonID(uid)
String userName = user.getDisplayName();
String email = user.getEmail();
Response.write( userName + username+ Email :+ email);

1) Displays the username and Email ID
2) Throws an exception
3) Doesnt Compile
Ans : 1.

23) List the methods used to create successful user
Ans :
1) NewUser(uid);
2) setFirstName()
3) setLastName()
4) setEmail()
5) setPassword();

24) can we construct an unique id manually .
Ans : false can create a unique id .

25) Unique IDs are used to identify objects across data sources.
Ans : ..

26) How do u retrieve log on information
Ans : umdata.enrich(map);

27) What is the return type of map.get("");
Ans : String

28) How do u load the data in the Client Eventing across the iviews
Ans : EPCM.loadClientData();

29) What is the object available in the pages
Ans : EPCM

30) What problems does HTMLB the overcomes on servelts
Ans :
Visualization and business logic are not separate
Development has to take care of different web clients and versions
NamesSpace conflicts with form elements

31) Stored data is identified by the key¦..
Ans : Namespace+name

32) Frame Work Levels
Ans :
Level = 0 ---- not supported by both javaScript, Java
Level = 1 ---- only by browser (java Script )
Level = 2 ---- both javaScript and Java

33) Features of portal Services in the portal
Ans :
1) portal services are way to provide functionality to portal component
2) portal services implement no user interface
3) portal service may be accessed from out side portal framework

34) Why do we need custom portal Services in the portal
Ans :
1) Can be used by other Portal Application
2) Provide commonly used Functionality
3) Can be exposed as webservice

35) To build a new portal service interface must be implemented
Ans :
IService

36) Life cycle of a portal service
Ans :
Init()
Afterinit()
Destroy()

37) Service name =
Ans :
.
.
.
.

38) Portal service name is myService …what would be the name of interface that extends IService
Ans : IMyService

39) JCA/J2EE connector Architecture is not API. True /False
Ans : true

40) ConnectorFrameWork is SAP Extended API from CCI . all methods in Connector FrameWork has methods with suffix as EX()….
Ans : False only some methods

41) What is the method used to get connection in the Java Connectors
Ans : Service.getConnection();

42) How do u get the locale from the request object.
Ans : Request.getLocale();

43) What is the return type for the table type structure .
Ans : IRecordSet.

44) Give the name of the method that returns resource bundle for the current locale.
Ans : getResourceBundle()

45) Localization.properties
Localization_de_DE.properties.
Localization_en_EN.properties.
What is the Resource bundle name : ?
Ans : Localization

46) What is the data type that returns by the method getString (key)
Ans : String

47) How do u access the a key in the properties file xyz = abc
Ans : getString ("xyz")

48) What type of objects can be translated
Ans : Text

49) the portal translation process is supported by tools
Ans :
Translation worklist coordination
Worklist translation

50) to customize the Logoff screen to the portal ----file is used to change
Ans : masthead

51) SAP Recommends not to modify the SAP code , then what are the process to customize the code
Ans :
1) copy the existing file and rename it according to customer name space
2) create new custom component

52) how can we customize the company Branding
Ans :
1) masthead
2) through customize applicaton

53) Their one question on Desktop inner page

54) What are the components that are added to Portal Desktop
Ans :
Default Frame work
Themes

55) What is the jsp name that contains log on page
Ans : umLogonPage.jsp

56) Authschemes.xml is modified to get custom log on component

57) How do u access portal services from WebDynpro applications
Ans : WDPortalUtils

58) Cache Level :
Ans : none ,session ,user,shared

59) getCachingLevel() is used to get the Cachelevel

60) When will the doinitialization () method is called
Ans :
1 When the page is loaded for the first time
2 When the page is refreshed
3 When object is called from the another object

61) Cached objects are retrieved using the --- method
Ans : get(key)

62) How can the portal service access to external Web Service
Ans :
Generate java proxy out of WSDL file with PDK
You can execute the java proxy as portal service

SAP Portal - Create Custom Layout and Apply the Layout

Create a layout JSP in NetWeaver Developer Studio (NWDS)

mylayout.jsp under the dist/jsp folder

lyt:template
...
/lyt:template

Define component in portalapp.xml

component name="myLayout"
config:
ClassName com.sapportals.portal.pb.layout.PageLayout
ResourceBundleName: pagebuilder_nls
profile:
ComponentType: com.sapportals.portal.layout
com.sap.portal.pcm.Title:
com.sap.portal.pcm.Description:
com.sap.portal.reserved.layout.TagLibLayout : /SERVICE/com.sap.portal.pagebuilder/taglib/layout.tld
com.sap.portal.reserved.layout.TagLibHtmlb: /SERVICE/com.sap.portal.htmlb/taglib/htmlb.tld
com.sap.portal.reserved.layout.TemplateFile: mylayout.jsp
com.sap.portal.reserved.layout.Cont1: the_container_id [title: my container, orientation: vertical]

Deploy the PAR to Portal

Create the layout in Portal Content, actually not necessarily under the Layout Templates.

Set the "Object is a Template" to "Yes"

DONE

SAP Portal - Collapse Portal Favorite as Default

Content Administration -> Portal Content -> select the page/workset -> Edit -> Object

select the category "Navigation" and set the "Initial State of Navigation Panel" to "Always Closed".

Monday, May 18, 2009

SAP Portal - JSP DynPage

By default, NWDS will generate two lines for a JSP DynPage component.

property name="ComponentType" value="jspnativa"
property name="JSP" value="pagelet/abc.jsp"

It is necessary to remove these two lines. For me, if not, componentRequest value will not be passed to the page and the value will be null.

SAP Portal - KM Service

import com.sap.netweaver.bc.sf/lib/bc.sf.framework_api.jar.
import com.sap.netweaver.bc.util/lib/bc.util.public_api.jar

and handle WcmException

Thursday, May 14, 2009

SAP Portal - Enable Collabration Room in Portal Application

Download supporting libraries
  1. log in SAP Portal, System Administration -> Support -> Portal Runtime -> Browse Deployment
  2. navigate to ROOT/WEB-INF/portal/portalapps/com.sap.netweaver.coll.shared/lib
  3. download the coll.shared.roomobject_api.jar
  4. download \portalapps\com.sap.portal.usermanagement\lib\com.sap.security.api.ep5.jar
  5. download \portalapps\com.sap.netweaver.bc.rf\lib\bc.rf.framework_api.jar
  6. download \portalapps\com.sap.netweaver.coll.shared\lib\coll.shared.extension_api.jar
  7. download \portalapps\com.sap.netweaver.coll.shared\lib\coll.shared.types_api.jar
  8. download \portalapps\com.sap.netweaver.kmc.util\lib\kmc.util.core_api.jar
Place these jars in a local file system
  1. actually the downloaded file will be called com.sap.portal.support.browse.zip
  2. extract the jar to C:\development\sap-portal-7.0.18\lib
Import these jars into NetWeaver Developer Studio
  1. in NWDS, Windows -> Preferences -> Java -> Classpath Variables -> New and add PORTAL_HOME=C:\development\sap-portal-7.0.18\lib
Import these jars into Portal Project
  1. in a Portal project, right click on the project, Properties -> Java Build Path -> Libraries -> Add Variable
  2. select PORTAL_HOME, click on Extend
  3. select the coll.shared.roomobject_api.jar and rest, click on OK
Add service reference in the portalapp.xml
  1. application-config :: property name = "ServicesReference" :: value = "..., com.sap.netweaver.coll.shared, ..."
DONE

Tuesday, May 12, 2009

SAP Portal - User's Own Layout

I created my own layout. Deployed on Portal. then created a layout in Portal Content.

However the layout is not listed when creating a page. Any idea?

Thursday, May 07, 2009

SAP Portal - Redirect in Portal Component

You will need to import javax.servlet.http.HttpServletResponse.

SAP NetWeaver Developer Studio 7.0.18. (aka 2004s)

Java build path. Extend ECLIPSE_HOME and add plugins/com.tssap.ext.libs.j2ee_xxx/lib/servlet.jar.

HttpServletResponse httpResponse = request.getServletResponse(true);
try { httpResponse.sendRedirect(url); } catch (IOException e) {}

SAP Portal - Direct Access to an iView

https://.../irj/portal?NavigationTarget=ROLES://portal_content/e0040034/e0040034.myLinkedReport

After ROLES, it is the PCD id.

or

https://.../irj/servlet/prt/portal/prtmode/preview/prtroot/pcd!3aportal_content!2fe0040034!2fe0040034.myLinkedReport

Wednesday, April 08, 2009

Temporary Objects in SAP Portal

At some circumstances, e.g. when the pop-up window is blocked by browser, modifying certain objects, such as the Default Page Template in SAP Portal will leave some temporary objects uncleaned and they will not expire.

This may cause SAP Portal behavior different among users. The reason is that some users may be associated with some temp objects and others may be with other temp objects.

The tool to clean these temporary objects is to use PCD inspector. Search for all associations or links to the temp object and delete these links first. Then delete these temp objects.

After it, System Admin -> Support Desk -> Portal Content Directory -> PCD Admin -> Release cache.

After it, reboot the server (depends).

Thursday, April 02, 2009

SAP Portal - Direct Access to Portal Content Administration

I made a mistake and configured the Default Page Template::Element in Framework Page to None instead of Framework Page. 10 minutes later, I was getting errors like "disablePersonalize" is undefined, etc.. and I can't get back to Content Administration to change it back.

Try the NavigationTarget as portal?NavigationTarget=navurl://06d9a4f1c16a67d0305579b9459fb574.

It saved me.

Wednesday, March 18, 2009

SQL - Delete in Two Tables

delete from a.doc_data where sur_doc_nbr in (select sur_doc_nbr from a.doc where deld=1)
delete from a.doc_attr where sur_doc_nbr in (select sur_doc_nbr from a.doc where deld=1)
delete from a.doc where deld=1

Friday, March 06, 2009

aggregates not allowed in WHERE clause

use HAVING, e.g.

SELECT player_name, AVG(score) as score FROM NBA.score_box WHERE box_year > 2004 GROUP BY player_name HAVING count(Game) > 100 ORDER BY score

Monday, February 23, 2009

Tomcat Timezone Issue

Noticed that Tomcat sometimes uses different time zone other than that of the system.

Solution is to define a TZ environment variable in the user profile and use the user to start up Tomcat.

e.g. TZ=US/Eastern

Saturday, February 21, 2009

CVS User

I used webmin to initialize the CVS repository and it was owned by root:root.

The default repository path is /var/cvs.

To enable a normal "cvsuser" write into the repository, I chown -R cvsuser.cvsgroup /var/cvs.

Java 6 on CentOS 5.2

Can't shutdown Tomcat because of the memory restriction when initialize VM.

After yum install jpackage-utils, it solved.

PostgreSQL Create a New Database

  1. su - postgres
  2. createdb -O

PostgreSQL Create a New User

  1. su - postgres
  2. createuser -S -D -R -P
  3. enter password

PostgreSQL Authentication

PostgreSQL default authentication control really sucks. I modified it like this,
  1. su - postgres
  2. psql
  3. show hba_file;
  4. vi the hba_file and comment out all default settings
  5. add a line "local all all md5"
  6. now it works from command line and phpPgAdmin web screen
But I want the authentication for user postgres works as default, so I add first line as "local all postgres indent sameuser"

Install Java 6 on CentOS 5.2

  1. run /usr/sbin/alternatives --config java, it gives no response.
  2. run uname -m and it gives i386. it means it is a linux not a linux64.
  3. download jdk rpm from java.sun.com, at the time, sun provides JDK 6 Update 12. select the Linux and the rpm.bin
  4. chmod of the bin file and make it executable, run it
  5. Get error -bash: ./jdk-6u12-linux-i586-rpm.bin: /bin/sh: bad interpreter: Permission denied
  6. after some research, i realized that the /tmp is shared managed. it won't allow me to run any scripts there. so i moved the bin file to my home directory and run it, it installed the java automatically
  7. run rpm -qa | grep java and got jdk-1.6.0_12-fcs, run rpm -qa | grep sun also returns a bunch of packages
  8. run /usr/sbin/alternatives --config java, it still gives no response but run java -version, it gives the 1.6.0_12 back.
  9. done.

Monday, February 09, 2009

Unicode in Web Application

Let's say you store a unicode string in a database. The database encoding is UTF-8. The string is 似水流年.

In your web application, you allow users type 似水流年 and you get it from HTTP request and obtain a string.

When you compare the string obtained from request and the string stored in the database, they will not match.

What you need to do is to convert the non-unicode string to unicode. Here is one of the way, simple and elegant.

str = new String(str.getBytes("ISO-8859-1"), "UTF-8");

You would need to handle the UnsupportedEncodingException, but I doubt if there is any JVM not supporting ISO-8859-1 to UTF-8 conversion.

I am not sure if the ISO-8859-1 shall be different on different servers. I tried on my development workstation which is a Windows XP + Eclipse 3.3 + Tomcat 6 + Java 1.6 and my production server which is a Linux RH + Tomcat 6 + Java 1.6. They all work very well and so far I am OK with it hard coded.

Tuesday, February 03, 2009

For-Each Loop

for(Type type : types) {
... type ...
}

The For-Each loop makes Java code much more beautiful and clean than before. We shall use it any time we can.

Several exceptions,
  1. The program needs access to the iterator in order to remove the current element. The for-each loop hides the iterator, so you cannot call remove. Therefore, the for-each loop is not usable for filtering.
  2. Similarly it is not usable for loops where you need to replace elements in a list or array as you traverse it.
  3. Finally, it is not usable for loops that must iterate over multiple collections in parallel. These shortcomings were known by the designers, who made a conscious decision to go with a clean, simple construct that would cover the great majority of cases.

Wednesday, January 28, 2009

Java First Moment of a Day

Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);

Java First Moment of a Month

Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);

Java First Moment of a Year

Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_YEAR, 1);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);

Java First Moment of a Week

Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);

Monday, January 12, 2009

Spring, Velocity and Dropdown List

Here is how I put a dropdown list, e.g. groups, on one of my Spring, Velocity web applications.

First, the key word is springFormSingleSelect. In my velocity file, I wrote

#springFormSingleSelect("command.group", ${groups}, "style='width:270px;'")

Second, use referenceData to populate values in the "groups" in the Controller class.

referenceData(...) {
Map model ...
... add (key, value) into a Map called groups
model.put("groups", groups);
return model;
}

Third, create a custom property editor, GroupEditor extends PropertyEditorSupport and override the setAsText method.

Note the Spring Framework will pass you the groupId and you need to create a Group object from the groupId, then call setValue(group).

Fourth, register the GroupEditor in the initBinder method.

binder.registerCustomerEditor(Group.class, new GroupEditor());

You may find the groups data will disappear after onSubmit. Don't worry, there is an easy fix. Instead of return a new ModelAndView, return showForm(request, response, errors, model). You can put whatever you need into the "model".

I spent a full weekend to sort everything out. Hope it can help you.

Tuesday, December 16, 2008

XQuery XQL

Combine SQL, OQL (Object Query Language) and XPath (XML Path Language).

Monday, December 15, 2008

Method signature and method header

The signature of a method consists of the name of the method and the description (i.e., type, number, and position) of its parameters.

Example:
  • toUpperCase()
  • println(String s)
Note: the names of the parameters have no relevance for the signature

The header of a method consists of the signature plus the description of (the type of) the result.

Example:
  • String toUpperCase()
  • void println(String s)
The keyword void denotes the fact that the method does not return any result (i.e., the method implements an action and not a function).

Two methods of the same class can have the same name, provided they have different signatures. Methods with the same name (but with different signatures) are said to be overloaded. For example, the substring() method in the class String.

Thursday, November 20, 2008

2G Memory is not enough for RSA Profile

IBM RSA 7.0.0.7, 2G memory, not able to start WAS 6.1.19 server Profile.

JVMDUMP013I Processed Dump Event "systhrow", detail "java/lang/OutOfMemoryError".

Friday, November 14, 2008

RSS - Really Simple Syndication

RSS is another way of building a dynamic content website and publishing news.

History 1997, now RSS 2.0 in 2003. 50% sites still use RSS 0.91, 25% RSS 1.0, 12.5% 0.9x and 12.5% 2.0.

With RSS,
  1. you create a RSS document and save it with a xml extension
  2. upload the file to your website
  3. register it with a RSS aggregator
The aggregator searches the registered websites for RSS documents, verify the link and displays information about the feed so clients can link to documents that interests them.

Java RSS programming - ROME
Render RSS on web pages - RSS2HTML
Include rss2html output in a html page - Server Side Include (xyz.shtml)

Thursday, October 23, 2008

Start Tomcat in Eclipse

Error: Timeout waiting for Tomcat v6.0 Server at localhost to start. Server did not start after 45s.

Solution: Window -> Preferences -> Server -> Server timeout delay

set it to Unlimited.

Monday, October 20, 2008

Enabling PostgreSQL on Linux System Startup

#chkconfig --list to list all services

To enable PostgreSQL at startup
#chkconfig --all postgresql
#chkconfig postgresql on --level 2
#chkconfig postgresql on --level 3
#chkconfig postgresql on --level 5

Thursday, October 02, 2008

RUP Notes

The Rational Unified Process (RUP) is a proprietorial process that has been developed by the Rational Software Corporation, now part of IBM.

RUP provides the software developer with a DISCIPLINED approach to the development process.

The aim of RUP is to ensure a high-quality result that satisfies user requirements within a predictable budget and schedule. It was designed to be fully compatible with object-oriented technology and the UML. It supports component-based software development.

RUP is a configurable process. It uses use cases to drive the development activities. Use cases facilitate the development from the beginning of the development process through to testing. And they give you a means to trace the process flow through the development of the system and the delivered product.

RUP is the opposite of sequential approaches. It is an iterative and incremental approach to the software life cycle. RUP encourages continuous integration. (Note, here it is "encourage", which means you still need to implemente your own continuous integration, or also called continuous build. Since RUP as a process to focus the final executible deliverables, continuous build servics as compliment to build the deliverables automatically. Sometime the build can also include regression tests which is even better.)

RUP deals errors and flaws in the system over successive iterations, thus makes the system more robust and stable.

Coming behind RUP are requirements management and change control. RM ensures the system better meets the customer's expectations, also limits the size of the project to acceptable levels(scope). Change control helps keep track of defects, misunderstandings, and project commitments and to associate them with specific artifacts.

RUP is architecture-centric, its early iterations has a main thrust to produce and validate a software architecture.

In RUP, quality control has been incorporated into the process. This quality assessment uses objective measurements and criteria for all activities and participants in the process.

RUP has four phases and each phase has iterations. At the end of each phase, comes a milestone, which is a predefined point in time by which certain goals must be achieved and certain decisions made. During the inception phase, the original vision of the product is transformed into a project(my understanding, a well defined plan, definition of deliveriables, iterations, etc.). Formulate the vision, establish business cases and specify the project scope, make decisions on what to invest time and money on. Business cases include success criteria, risk assessment, estimation of resources, phase plan indicating the dates of milestones, prototyping.

The goal of the elaboration phase is more thorough analysis of the problem domain, to establish and define the architecture, to address and eliminate high-rish elements of the project, to determine how the work should be divided into iterations(I think it is difficult but critical. It needs strategic thinking, knowledge and experience. But it is also where the value of a good architect lies.) At the end of the elaboration phase, the decision must be made to build or not the system.

The third phase is the construction. In its final iteration the construction delivers a constructed software system.

RUP defines a transition phase, where the product is supplied to its end-users. Plan the packaging, pricing, roll out, support, training, transition strategy, production details.

It's recommended to have a "postmortem" analysis of the project, addressing how well the original and revised success criteria have been met.

There are nine core workflows in the RUP, either engineering process workflows or supporting process workflows. Business modeling, requirements capture, application/system analysis and design, implementation, testing, deployment

Thursday, September 11, 2008

JDBC ResultSet Column Name with Multiple Tables

For SQL like, "select a.col1, b.col2 from atab a, btab b where a.id=b.aid and b.id=?", when extracting values from ResultSet, what column name to use?

Incorrect - a.col1, b.col2.
Correct - col1, col2.

What if same column names in both tables, like a.col3 and b.col3?

Write SQL like "select a.col3 as acol3, b.col3 as bcol3 ...", then name the column in getXXX method as acol3 and bcol3.

Thursday, August 28, 2008

Customize 401 Error Page with HTTP Basic Authentication

For HTTP Basic Authentication, you define the auth type as BASIC.

After adding an error-page element in web.xml to customize 401 error page, HTTP auth will not work.

So far with Tomcat 6.0, I have found no way to make them work.

Monday, August 25, 2008

Tomcat DataSourceRealm

PostgreSQL version 8.

userTable="schema1.users" works and the schema name should be lower case too in the database.

Schema1 or SCHEMA1 won't work.

Wednesday, August 06, 2008

External JACC Provider in WebSphere 6.1

In WebSphere Application Server version 6.1, you can choose Default Authorization or External Authorization by JACC Provider.
  1. Internal accepts "welcome.do" but external TAM provider doesn't, it accepts "/welcome.do"
  2. I switched from Default to External but failed to switch it back. Even from the admin console it looked fine, but the server kept using TAM as authorization provider. What I had to do was to reinstall RSA.

Friday, August 01, 2008

TAM Error AWXJC0050E

[8/1/08 11:16:51:373 EDT] 00000020 SystemErr R Caused by:
com.tivoli.pd.as.jacc.cfg.TAMConfigException: AWXJC0048E An error occurred during the configuration. The details are:
com.tivoli.pd.as.jacc.cfg.ConfigActionFailedException: AWXJC0050E The Tivoli Access Manager user, sec_master, failed to add the Tivoli Access Manager user, JACC_-264539269/cledt-123691.agna.amgreetings.com, to the Tivoli
Access Manager group, iv-admin. The details are: Wrappered Exception:java.net.BindException: Address already in use:
NET_Bind[HPDCO1050E Socket could not be created (8920).].. at
com.tivoli.pd.as.jacc.cfg.TAMConfigController.execute(TAMConfigController.java:156)

For this error, note the port 8920 in the message, then change the client listener port from default 8900:8999 to 8921:8999.

Have a $ in your password?

In WAS 6.1 administrative console, when define a LDAP connection and enter the Bind password. It has a $. For example, the password is "abc$$cba".

What you need to enter is "abc$$$$cba".

Wednesday, May 14, 2008

Struts InvalidCancelException

2.1. Bug 38374 - Validation always skipped with Globals.CANCEL_KEY




2.1.1. Issue: Cancel Processing



The Struts <html:cancel> tag sets a request parameter (org.apache.struts.taglib.html.Constants.CANCEL) which causes validation to be skipped.


Spoofing this request parameter however, could be used maliciously in order to circumvent an applications validation and proceed with the request processing with erroneous and potentially damaging data.


See [WWW] Bug 38374 for full details.



2.1.2. Resolution: Cancellable Property



A new cancellable property has been introduced which indicates whether an action is allowed to be cancelled or not. In Struts 1.2.9 this is set to true or false for an action in the struts-config.xml using the <set-property> notation. From Struts 1.3.x a new cancellable attribute has been added to the <action> element.


Now any action where the cancellable property is not set to true will throw an InvalidCancelException.



2.1.3. Upgrade Implications



Any existing applications that use the Cancel processing will need to modify their struts-config.xml to set the cancellable property for actions which require it.


In Struts 1.2.9 the <set-property> is used to set the cancellable property for an action....



<action path="/fooAction"
input="/foo.jsp"
validate="true">
<set-property property="cancellable" value="true"/>
<forward name="success" path="/bar.jsp"/>
</action>

From Struts 1.3.x a new cancellable attribute can be used....



<action path="/fooAction"
input="/foo.jsp"
validate="true"
cancellable="true">
<forward name="success" path="/bar.jsp"/>
</action>

In both Struts 1.2.9 and Struts 1.3.x an exception handler can be configured to handle the InvalidCancelException



<action path="/fooAction"
input="/foo.jsp"
validate="true"
cancellable="true">
<forward name="success" path="/bar.jsp"/>
<exception key="errors.cancel"
type="org.apache.struts.action.InvalidCancelException"
path="/foo.jsp"/>
</action>


2.1.4. Test Cases



This bug was tested using the struts-examples webapp (see struts-examples.war in the binary distribution). If you fire up the examples webapp, select the Taglib Test Pages link, then select the <html:cancel> link you will be presented with a page where you can try the Cancel button for four different configurations.

Tuesday, April 29, 2008

Cancel Button for CancellableFormController

input type="submit" name="_cancel" value="Cancel"

where by default "_cancel" is the cancelParamKey. You can use setCancelParamKey() to override it.

Redirect in Spring MVC

return new ModelAndView(new RedirectView(redirectURL, true), model);

Thursday, April 24, 2008

Form Validation Error Message

Use SpringFramework, SimpleFormController, and CustomDateEditor.

When the date input doesn't match the specified format, it will report an error message. The message is very much in Java developer's language, not user oriented.

To replace the message with your own, just put a line like that in your messages.properties,

typeMismatch=Invalid or incomplete input.

Spring Framework - Date Field in a SimpleFormController

  1. Override the initBinder method.
  2. Create a SimpleDateFormat, e.g. MM/dd/yyyy HH:mm:ss where M is month, d is day, y is year, H is hour(0-23), m is minute, and s is second.
  3. Set the date format lenient false, which means inputs do not have to match the format exactly
  4. Create a CustomDateEditor(dateFormat, true), where true means empty allowed.
  5. Register the editor to Date.class.

Thursday, April 10, 2008

Postgresql - Generate Primary Key before Insert

First define the primary key column as serial, it is a integer, but a sequence table will be created automatically to match it. For example, if you define an April_ID as type serial in table April, a sequence table called April_April_ID_SEQ will be created automatically when creating the April table.

Second in your program, use select nextval('schema.april_april_id_seq') to obtain the next value for primary key. You don't need to plus 1 since Postgresql does it for you. If using Spring JDBC template, just call getJdbcTemplate().queryForInt(the sql).

Third, use the value just obtained as parameter in the insert sql.

Done.

Monday, April 07, 2008

Velocity Layout in Spring

Spring 2.5.2/Velocity 1.5

In web.xml, define org.springframework.web.servlet.DispatcherServlet as spring. Mapping *.xhtml to spring. I leave html for real html files.

In spring-servlet.xml, define

viewResolver class=org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver

  • viewClass = org.springframework.web.servlet.view.velocity.VelocityLayoutView
  • layoutUrl = layouts/mainlayout.vm
  • cache = true
  • suffix = .vm
  • exposeRequestAttributes = true
  • exposeSessionAttributes = true
  • exposeSpringMacroHelpers = true
  • dateToolAttribute = dateTool
  • numberToolAttribute = numberTool

velocityConfigurer class = org.springframework.web.servlet.view.velocity.VelocityConfigurer

  • resourceLoaderPath = WEB-INF/views
  • velocityProperties directive.foreach.counter.name = loopCounter
  • directive.foreach.counter.initial.value=0

Create a layout file, mainlayout.vm under WEB-INF/views/layouts. Put html, body, stylesheet stuff in. Note the stylesheet file shall sit outside WEB-INF. e.g. stylesheet href = "includes/main.css" means the main.css file sits at [web-root]/includes forlder.

Put $screen_content whereever you want.

In spring controller, return the ModelAndView name "dashboard", create a dashboard.vm file under WEB-INF/views.

In the dashboard.vm file, put any content in.

Monday, March 31, 2008

Books for JMS

Enterprise Messaging Using JMS and IBM(R) WebSphere(R) (IBM Press Book) (Paperback)
  • Paperback: 352 pages
  • Publisher: IBM Press (February 25, 2004)
  • Language: English
  • ISBN-10: 0131468634
  • ISBN-13: 978-0131468634
Editorial Reviews

This book offers start-to-finish guidance for building reliable, high-performance JMS-based messaging infrastructure with IBM WebSphere technologies.

IBM expert Kareem Yusuf systematically introduces the latest versions of JMS—both 1.1 and 1.02b. Once you've thoroughly mastered JMS development on any platform, Yusuf turns to the exceptional JMS support found in IBM's WebSphere products. Using extensive code examples, he walks you step-by-step through WebSphere JMS development, configuration, deployment, and administration in several real-world scenarios.

Coverage includes:
  • Roles and goals of messaging infrastructure in the enterprise
  • Key JMS concepts: messaging domains, messages, and Application Server Facilities
  • Defining/structuring content, choosing message types, and manipulating messages
  • The JMS API, explained through detailed code examples
  • Using JMS with EJB, message-driven beans, servlets, and portlets
  • Working with IBM WebSphere JMS providers, administered objects, and tools
  • Hands-on tutorials: EJB message exchange, integration with non-JMS applications, and SSL security
  • Resource location and physical topologies for maximizing availability and efficiency

Whether you're developing enterprise messaging infrastructure, architecting it, or managing it, this bookdelivers indispensable guidance-straight from the frontlines.

HTTP Request Headers

An add-on called Tamper Data on Firefox can add and modify HTTP request headers. It can even read input from a text file. This feature makes it very useful because you can save one header file for each applicaiton.

Its only problem is the header need to applied for every request. It doesn't remember or recall.

I also tested another add-on on Firefox called Modify Headers. It only worked the very first try but failed ever after.

Neither Tamper Data nor Modify Headers works on Internet Explorer.

It is said that IBM Page Details can work on IE.

Thursday, March 27, 2008

Books for Web Services

Web Services

Developing Web Services for Web Applications: A Guided Tour for Rational Application Developer and WebSphere Application Server (Ibm Illustrated Guide Series) (Paperback)

  • Paperback: 400 pages
  • Publisher: Mc Press; Pap/Cdr edition (September 15, 2005)
  • Language: English
  • ISBN-10: 1931182213
  • ISBN-13: 978-1931182218

Editorial Reviews

This book shows you how easy it is to create and use Web Services with IBM® Rational Application Developer or Web Developer, and WebSphere Application Server.

Intended for novice to intermediate Java programmers, Developing Web Services for Web Applications teaches users how to create Web Services, deploy Web Services to a server, and create client applications that use Web Services. Each chapter of the book teaches a key Web Service concept and takes you on a detailed, guided tour for creating or using a particular Web Service. Even if you’re completely new to Web Services, by the time you finish the lessons in this book, you’ll have all the skills needed to create useful Java programs with Web Services.

Using the “guided tour” approach, the book comes with practical step-by-step instructions and numerous screen captures, making it easy to follow along. While most books teach how to use either a development tool or a particular technology, Developing Web Services for Web Applications combines learning about Web Services with using Rational Developer tools. Each chapter develops a complete Web Service and/or application, with sample code and solution files provided on the accompanying CD-ROM. Also included in each chapter are additional exercises to help reinforce the concepts covered in that chapter.

By the end of the tour, you’ll be able to use Rational Developer tools to build your own Web Services, and you’ll understand why Web Services are gaining popularity as a way to provide services across the Internet.

Developing Web Services for Web Applications:

  • Is perfect for all skill levels, from those taking their first steps to those looking to explore more advanced topics
  • Teaches you Web Services concepts and terminology as you learn how to use the Rational Developer tools
  • Shows you how to create, deploy, publish, and use Web Services
  • Explores troubleshooting, using relational databases, using JavaServer Faces Web applications, adding security features, and much more

Contents:

Introduction
Chapter 1: Creating your first Web service and Web application
Chapter 2: Deploying and publishing your Web service
Chapter 3: Discovering Web services
Chapter 4: Handling Web service errors
Chapter 5: Using databases, part 1
Chapter 6: Using databases, part 2
Chapter 7: Using Web services with JavaServer Faces, part 1
Chapter 8: Using Web services with JavaServer Faces, part 2
Chapter 9: Securing Web services, part 1
Chapter 10: Securing Web services, part 2
Appendix A: Installing WebSphere Express

JMS Suggested Readings

Introductions

JMS Programming

JMS and WebSphere

Samples

Web Services Suggested Readings

Introductions

Java Web Services

Samples

Tutorials

Tuesday, March 18, 2008

Struts Configuration Editor in RSA 7

Once we couldn't open struts configuration file using Struts Configuration Editor. Right click the file, the Editor was not shown in the list.

We solved it by doing the following,

Opened the welcome perspective, enabled web development. Went back to J2EE or Web perspective and right clicked the struts-config.xml, the Editor was listed.

Tuesday, March 04, 2008

J2C CICS COBOL

In COBOL, some field might be defined as "OCCURS 300 TIMES". IBM Rational Software Architect version 7.0.0.3 translates it to an array in Java Binding Class with both lower bound and upper bound 300.

That causes problem when client sends up less than 300 records.

I solved it by editing the generated Java Binding Class and modifying the lower bound validation to use 0 instead of 300.

Tomcat Debug in Eclipse

Tomcat can be started in non-debug mode, but in debug mode, it got error,

Transport dt_socket failed to initialize, rc = 509.

JAVA version = 1.4.2_16
JAVA_HOME = <>\j2sdk1.4.2_16\bin
IDE = Eclipse 3.2
Web Server = Tomcat 5.0.28

I solved this by copying the two dll files (dt_shmem.dll, dt_socket.dll) from "<>\j2sdk1.4.2_16\jre\bin" to "<>\j2sdk1.4.2_16\bin".

Tuesday, January 08, 2008

Commons Logging and IBM WebSphere 6.1

RSA 7.0.0.3/WAS 6.1.

Apache Commons Logging has a problem with WAS 6.1. Its Log4JLogger either can't be loaded or be reported not compatible with LogFactory.

The root cause is WebSphere uses commons-logging and so it's in the root classloader. In addition, WebSphere ships a commons-logging.properties with the following properties set:

org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger

Therefore by default the application will use JDK logging and not log4j. The solution is to ensure that the right classloader mode is set and the application has an appropriate commons-logging.properties:

Set application classloader mode as PARENT_LAST. Also, add a commons-logging.properties to the application classpath with the following entries:

priority=1
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl

The priority flag was introduced in Commons Logging 1.1 to allow an ordering based on priority. To ensure that an application's commons-logging.properties will take precedence over WebSphere's file, a priority of greater that 0.0 must be set.

Wednesday, January 02, 2008

This project needs to migrate WTP metadata

Hello There, I had exactly the same error message and none of the above fixes worked. The problem I found were the following
1) The runtime the old code is still pointing to is WAS 6.0 not WAS 6.1 (in RAD7)
2) RAD7 has more options to change more settings

The Solution: I had to fix the problem on the WAR file that is used by the EAR file Following is my fix for the problem in RAD7 PART I with the WAR PROJECT
\---------------------------
1) Right click on the war project and click on properties.
2) Click on Targeted Runtimes in the properties
3) Now check your desired Runtime WebSphere Application Server 6.1
4) Now click on the WebSphere Application Server 6.1 Runtime in the same window
5) You will see under Runtime Composition com.ibm.ws.ast.st.runtime.61 JRE 5.0: WebSphere v61 JRE
6) Now click on Add/Remove Project Facets link in the same window
7) It opens a new windows Project Facets. This page has dependencies when checking the boxes. Therefore...
8) Here First check Java, I selected the version 5.0.
9) Then check Dynamic Web Module (as I am using web module), I selected 2.4
10) Then check WebSphere Web (coexistence) 6.1
11) Then check WebSphere Web (Extended) 6.1
12) Click Finish
13) Click OK in the properties window
14) Now again open the same properties window
15) You will see new types on the Left Hand Side(LHS) windows namely J2EE Module Dependencies.
16) Click J2EE Module Dependencies. Select from the drop down the EAR file name that should have this WAR file
17) Click Java Build Path on the LHS window.
18) Make sure you see WebSphere Application Server v6.1 under your libraries tab on the Right Hand Side(RHS) window.
19) Click on Project Facets and make sure you see the 4 facets namely Dynamic Web Module, Java, WebSphere Web (Co-existence) and WebSphere Web (Extended) listed with the correct values.
20) Click on the Server on the LHS window.
21) Make sure you see the WebSphere Application Server v6.1 selected on the RHS window. If not, select it.
22) Click on Targeted Runtimes. Mostly you should see this time only WebSphere Application Server v6.1
23) Click OK
24) Manually Refresh and Rebuild this project.

PART II with the EAR project
\----------------------------
1) Right click on the EAR project and click properties
2) Click J2EE module dependencies.
3) Make sure desired xxxxxx.war file is checked.
4) Click on Targeted Runtimes.
5) Make sure you have WebSphere Application server 6.1 is checked
6) Click on project Facets
7) Make sure you have EAR 1.4, WebSphere Web (coexistence) 6.1, WebSphere Web (Extended) 6.1 are selected. If not, go to step 5 and click on the add/remove proejct facets link to do it.
8) click on server and check WebSphere Application Server v6.1
9) Manually Refresh and Rebuild this project.

You should be all set. All the best.

Friday, December 21, 2007

IBM HATS in Passport Advantage

HATS version 7.0 under

Rational Software/IBM WebSphere Host Integration Solution (HIS) for ... v 7.0/

IBM WebSphere Host Access Transformation Services (HATS) Standard v7.0 ... (C97NZML)
IBM WebSphere Host Access Transformation Services Run-Time Web Enablement ... (C97P2ML)

It's so hard to find anything in IBM Passport Advantage.

Tuesday, December 11, 2007

CICS ECI Resource Adapter - execute timeout

The execute timeout can be specified at creating method in a J2C bean.

0 - No timeout, this is the default value.
any positive int value - in milliseconds

How to Add a VM Argument to WAS 6.1

Actually the WAS 6.1 is the embedded one inside RSA 7.0.

Open the Administrative Console. Navigate through server -> process definition -> Java Virtual Machine -> Customer Variables.

Done.

Monday, November 26, 2007

J2C CICS ECI - Generate Simple JSP

Do the same steps as generate a web service, instead, select Simple JSP at the J2EE Resource Type.

Enter /minzyWeb as the Web project, ou as the JSP folder.

Show Advanced, if the Resource Reference is missing, enter eisOrderUpdateRef.

Click on Finish.

Notice 4 jsp files were created under WebContent\ou.

J2C CICS ECI - Generate Web Service

Start Web Page, Web Service, or EJB from J2C Java Bean wizard.

Enter \minzyConnect\src\tliu\minzy\eis\ou\OrderUpdateJ2CImpl.java as the J2C bean implementation. Click on "Next >".

Select "Web Service" and click on "Next >".

Browse and select /minzyWeb, show advanced and enter eisOrderUpdateRef as the resource reference, keep JNDI lookup name as eis/OrderUpdate as proposed.

Click on Finish.

Notice minzyWeb was changed to have a reference to minzyConnect, 10 classes generated under tliu.minzy.eis.ou, OrderUpdateJ2CImpl.wsdl generated under WEB-INF/wsdl and webservices.xml, etc under WEB-INF.

Note, do not remove the "gen" folder. It is the generated folder for the 10 new classes.

J2C CICS ECI - Generate J2C Bean Classes

Select DIC44010.cpy and start J2C Java Bean wizard.

Select ECIResourceAdapter (IBM 6.0.2.1) under J2C 1.5. (CTG 6.1 needs this match up)

Give eis/OrderUpdate as JNDI name.

Click on "New...", select WAS v6.1 as server.

Enter tcp://10.104.252.233 as Connection URL. (For remote, tcp://, for WAS and CTG on same server, local:), AMGCOHA3 as server, 32006 as the port number, user and password etc.. (configurations here shall be obtained from CTG admin)

After that, enter minzyConnect as project, tliu.minzy.eis.ou as package, OrderUpdateJ2C as interface, the implementation class will automatically be given as OrderUpdateJ2CImpl.

At next step, click on Add... to add a method.

Give updateOrder as the method name.

Click on Browse... and select OrderUpdateBind as input type and check on Use the input type for output.

If execute time out is a required argument, enable the Show Advanced and expand Interaction Spec to select executeTimeout - int.

Click on Finish and enter DIC44010 as the Function name.

Click on Finish and generate the J2C Java bean.

Notice the OrderUpdateJ2C and OrderUpdateJ2CImpl were created under tliu.minzy.eis.ou, cicseci6021 i was created and minzyConnect was updated to have cicseci6021 in its build path.

Wednesday, November 21, 2007

J2C CICS ECI - Generate J2C Data Binding Classes

Select the DIC44010.cpy file and summon the J2C CICS/IMS Java Data Binding wizard.

Choose mapping COBOL to Java.

Select z/OS for Platform, IBM-037 for Code page. Click on Query.

Select the DFHCOMMAREA which is the CICS common area.

Select "Shorten names" as Generation Style, minzyConnect as project, tliu.minzy.eis.ou as package, OrderUpdateBind as class.

Class OrderUpdateBind, OrderUpdateBind_DFH_PAL_ID_DATA_DFH_EPC_DATA and OrderUpdateBind_DFH_PAL_ID_DATA will be created under tliu.minzy.eis.ou.

J2C CICS ECI - Obtain COBOL Copybook

RSA J2C wizard in version 7 accepts only the copybook of common area. It used to accept the whole COBOL program in WSAD version 5.1. I obtained the whole program and I found out I needed to trim it to the copybook only and rename it from DIC44010.ccp to DIC44010.cpy. The wizard actually tells the difference between ccp and cpy.

The copybook looks like this,
01 DFHCOMMAREA.
02 DFH-INPUT-FIELDS.
05 DFH-MRG-NBR PIC 9(07) VALUE ZEROS.
05 DFH-DC-NBR-FILLING PIC X(02) VALUE SPACES.
05 DFH-SESSION-CNT PIC 9(02) VALUE ZEROS.
05 DFH-PAL-ID-DATA OCCURS 5 TIMES.
10 DFH-PAL-ID-NBR PIC 9(03) VALUE ZEROS.
10 DFH-PAL-EPC-NBR PIC 9(09) VALUE ZEROS.
10 DFH-EPC-DATA OCCURS 300 TIMES.
15 DFH-EPC-NBR PIC 9(12) VALUE ZEROS.
02 DFH-STATUS-FIELDS.
05 DFH-RETURN-CODE PIC 99 VALUE ZEROS.
05 DFH-RETURN-TEXT PIC X(80) VALUE SPACES.
05 DFH-PROGRAM-NAME PIC X(08) VALUE SPACES.
05 DFH-ERROR-STATUS PIC X(04) VALUE SPACES.
05 DFH-ERROR-RECORD PIC X(16) VALUE SPACES.
05 DFH-ERROR-SET PIC X(16) VALUE SPACES.
05 DFH-ERROR-AREA PIC X(16) VALUE SPACES.
05 DFH-DML-SEQUENCE PIC 9(08) VALUE ZEROS.
Do not edit the file.

I created a eis folder under minzyConnect. I put DIC44010.cpy under the newly created eis folder.

J2C CICS ECI - Review the Environment

In this trial, I will create a J2C service to call a CICS COBOL program. I use
  • IBM Rational Software Architect (RSA) v 7.0.0.3
  • IBM WebSphere Application Server (WAS) v 6.1, embedded in RSA 7
  • IBM CICS Transaction Gateway (CTG) v 6.1
CTG connection URL is tcp://10.104.252.233, port 32006, server name AMGCOH3, user name ctgwebu, and password ***.

Note, if WAS and CTG sit at the same server, CTG connection URL shall be local:.

Project minzyConnect is created to hold the data binding and J2C beans.

Project minzy is created as EAR holder, and its module project minzyWeb, minzyEnt (for EJB), and minzyClient are also created.

Tuesday, November 20, 2007

CICS Transaction Gateway

Connection URL set to "local" if the servlet sits at the same server. Set to "tcp:" if the servlet needs to connect a remore CICS Transaction Gateway, e.g. tcp://9.100.101.102:2006.

Friday, November 16, 2007

Informatica Upgrade to 8.1.1 - Client

Informatica is a Web Service Hub. When the server upgrades to 8.1.1, from the client side, do the followings,
  1. Open the Hub's home page, e.g. http://host:7333/wsh/
  2. Click on the "Batch Web Services"
  3. Click on the WSDL icon under Metadata WSDL
  4. Right click on the pop-up page and select "View Source"
  5. Save the content as MetaData.wsdl
  6. Do the same for DataIntegration WSDL, save as DataIntegration.wsdl
  7. Import these two files to a RSA project
  8. Add axis-1.4.jar to the project
  9. Create a Java Application Run,
  10. Set main class as org.apache.axis.wsdl.WSDL2Java
  11. Check "Include libraries when searching for a main class" on
  12. Select Arguments tab
  13. Enter "--NStoPkg http://www.informatica.com/wsh=com.informatica.www -W informatica-8.1.1/MetaData.wsdl" as Program arguments, where the informatica-8.1.1 is the folder of MetaData.wsdl file
  14. Run this Java Application
  15. Informatica client code for MetaData service will be generated
  16. Do the same for DataIntegration service
  17. There are some changes from version 7, especially of the connection, workflow and folder
  18. Modify the client application accordingly

CICS ECI Resource Adapter

The CICS resource adapter makes use of interfaces within J2EE Connector Architecture to facilitate the communication between J2EE applications and CICS information systems. The JCA defines a programming interface called the Common Client Inteface (CCI). This interface can be used, with minor changes, to communicate with any EIS. This CICS Transaction Gateway provides resource adapters that implement the CCI for interfactions with CICS.
  • ECIResourceAdapter (IBM : 5.1): This version of the CICS ECI resource adapter is based on Version 1.0 of the J2EE Connector Architecture (JCA 1.0). Because CICS ECI resource adapter for Java verion 5.1 is a JCA 1.0 resource adapter, it will only run in a JCA 1.0 application server or WAS version 5.0.2 (or above). Select CICS 5.1 resource adapter if targeting a WAS v 5.0 server.
  • ECIResourceAdapter (IBM : 6.0.2): This version of the CICS ECI resource adapter is based on version 1.5 of the JCA (JCA 1.5). It runs on WAS 6.0.
  • ECIResourceAdapter (IBM : 7.0.0): This version based on JCA 1.5. It runs on WAS 6.1.

If you select Configure Resource Adapter Deployment on the Deployment Information page of the J2C wizard, you can use the Resource Adapter Deployment page to configure RAR.

The resource adapter can be deployed as a standalone resource adapter or as part of an EAR file. Typical environments use the standalone method, giving all modules on the application server visibility to the adapter.

Note: Multiple resource adapters should not be installed as standalone on the same runtime server, especially if they are for the same EIS type (for example, CICS ECI 5.1 and CICS ECI 6.2). This is because all standalone resource adapters share the same class loader.

My note: It's probably easier for application maintanence to deploy the adapter per EAR file.

Wednesday, October 31, 2007

Axis 1.1 and 1.2

Some Web Service software, such as Informatica, generate stub classes to access web services. Some classes were generated based on Axis 1.1 and they use org.apache.axis.enum.Style.

In Axis 1.2, that class has been replaced by org.apache.axis.constants.Style. When clients try to make connections to web services, it will get an error that enum.Style cannot be found.

I think it will solve the problem to regenerate the stub classes with Axis WSDL2Java emitter from the WSDL definition files. We will see the result after several days.

Monday, October 22, 2007

DelegetingActionProxy

DelegetingActionProxy solves the problem of having to create an action as subclasses of ActionSupport. It is better to define beans in the Spring application context are proxies to the Struts Actions.

For example, class SpringIndexAction extends Action and declares a setter for the productionManager property. We add an action declaration to the Struts configuration file struts-config.xml.
[action path="/sindex"
type="org.springframework.web.struts.DelegatingActionProxy"
validate="false"]
[forward name="success"
path=".index"/]
[/action]

Notice the action type is set to DelegatingActionProxy, which is a Spring class that delegates all calls to the real bean of the SpringIndexAction class.

Before we can use DelegatingActionProxy, we first need to add the ContextLoaderPlugin bean to the Struts configuration file.
[plug-in
className="org.springframework.web.struts.ContextLoaderPlugin"]
[set-property property="contextConfigLocation"
value="/WEB-INF/actionContext.xml"/]
[/plug-in]

We declare the SpringIndexAction in the actionContext.xml file.
[beans]
[bean name="/sindex" class="com.....actions.SpringIndexAction"]
[property name="productManager"][ref
bean="productManager"/][/property]
[/bean]
[/beans]

When we now make a request to the /sindex.do URL, DelegatingActionProxy looks up the bean with its name set to /sindex. It uses the beans defined in the WebApplicationContext that is loaded by the ContextLoaderPlugin declared in the file specified in its contextConfiguration property. The /sindex bean is the actual SpringIndexAction, it is instantiated, and its productManager property is set.

The difference after using DelegetingActionProxy is that the SpringIndexAction is a fully Spring-managed bean and we have no manual dependency lookup code in the Action.

Monday, October 15, 2007

Form-based Authentication in WAS

Form-based login

One of the login challenges defined in J2EE Specification is form-based login. It enables the application developer to customize the login process and present an application-specific form by making use of the Form Login Authentication Method.

Form login works in the following manner:

1. An unauthenticated user requests a resource protected by the Form Login authentication type.
2. The application server redirects the request to the Login Form defined previously in the Web deployment descriptor.
3. On the HTML login form, the user enters the user ID and password and submits the form.
4. The action triggered by the form submission runs a special WebSphere Application servlet j_security_check. The Web container, after receiving a request for the j_security_check servlet, dispatches the request to another WebSphere servlet that authenticates the user.
5. If the servlet authenticates the user successfully, the originally requested resource is displayed.

Form login configuration using WebSphere Studio

1. Open the web.xml file under the Web project. A Web Deployment Descriptor should be opened in a deployment descriptor editor window.
2. Select the Pages tab, then modify the Login section.
3. Type in the realm name, for example: SecureRealm.
4. Click the drop-down list and select FORM as the Authentication method.
5. In the Login page, click Browse and select your login page from the project, for example: /login/login.html.
6. In the Error page, click Browse and select your login page from the project, for example: /login/loginerror.html (we have used the same page for login and error, but you can define a custom error.jsp page that will present actual error code and error messages).
7. Save and close the Web deployment descriptor file.

Setting the Authentication Method for the application Web module will create a [login-config] section in a Web deployment descriptor XML file, as shown in the following example.

[login-config]
[auth-method]FORM[/auth-method]
[realm-name]SecureRealm[/realm-name]
[form-login-config]
[form-login-page]/login/login.html[/form-login-page]
[form-error-page]/login/loginerror.html[/form-error-page]
[/form-login-config]
[/login-config]

Simple form-based login does not require any extra code development on the server side. The j_security_check servlet used by WebSphere Application Server enforces only the name of the input fields that the developer should put in the custom Login Form. These fields are as follows:

* j_username should be the input field in which a user will type the user ID.
* j_password should be the input field into which the user will type the password.

The action required for the HTTP POST method is j_security_check. A simple HTML code for the custom Login Form is given in the following example:

[!-- ............... --]
[form method="post" action="/itsobank/j_security_check"]
[table width="80%"]
[tr]
[td width="20%" align="right"]Userid:[/td]
[td][input size="20" type="text" name="j_username" maxlength="25"][/td]
[/tr]
[tr]
[td align="right"]Password:[/td]
[td][input size="20" type="password" name="j_password" maxlength="25"][/td]
[/tr]
[tr]
[td][/td]
[td][input type="submit" name="action" value="Login"] [input type="reset" name="reset" value="Clear"][/td]
[/tr]
[/table]
[/form]
[!-- ............... --]

Form-based logout

One of the IBM’s extensions to the J2EE Specification is the form-based logout. After logging out, the user is required to re-authenticate to have access to protected resources again. This logout form can be on any page with calling a POST action on the ibm_security_logout servlet. This form must exist within the same Web application to which the user gets redirected after logging out.

[form method="post" action="ibm_security_logout" name="logout"]
[input type="submit" name="logout" value="Logout"]
[input type="hidden" name="logoutExitPage" value="/login/login.html"]
[/form]

A Real Case with WAS Security

This case worked under RSA 7.0 and WAS 6.1.

In the application, it defined two roles, tliu:passw0rd:101:101:Thomas Liu and authenticated_user. Only users with administrator role can access administrator pages and carry out administrator functions. Any users authenticated with a pair of user id and password can access general pages and carry out general functions.

In the application.xml file of the EAR project, two security-roles were defined.

[security-role id="admin"]
[role-name]administrator[/role-name]
[/security-role]
[security-role id="user"]
[role-name]authenticated_user[/role-name]
[/security-role]

In the ibm-application-bnd.xml file of the EAR project, one authorization table with two authorizations was defined.

[authorizationTable xmi:id="AuthorizationTable_1126620398213"]
[authorizations xmi:id="RoleAssignment_1126807102767"]
[specialSubjects
xmi:type="applicationbnd:AllAuthenticatedUsers"
xmi:id="AllAuthenticatedUsers_1140011292114"
name="AllAuthenticatedUsers" /]
[role
href="META-INF/application.xml#user" /]
[/authorizations]
[authorizations xmi:id="RoleAssignment_1140011292114"]
[role
href="META-INF/application.xml#admin" /]
[groups xmi:id="Group_1140011292114" name="ceadmin" /]
[/authorizations]
[/authorizationTable]

In the web.xml file of the web project, two security-constraint, one login-config, and two security-role were defined.

[security-constraint]
[display-name]Administrators Constraint[/display-name]
[web-resource-collection]
[web-resource-name](Administrator Web Resource Collection)[/web-resource-name]
[description][/description]
[url-pattern]/admin/*[/url-pattern]
[http-method]GET[/http-method]
[http-method]PUT[/http-method]
[http-method]HEAD[/http-method]
[http-method]DELETE[/http-method]
[http-method]OPTIONS[/http-method]
[/web-resource-collection]
[auth-constraint]
[description][/description]
[role-name]administrator[/role-name]
[/auth-constraint]
[user-data-constraint]
[transport-guarantee]NONE[/transport-guarantee]
[/user-data-constraint]
[/security-constraint]
[security-constraint]
[web-resource-collection]
[web-resource-name](Users Web Resource Collection)[/web-resource-name]
[description][/description]
[url-pattern]/document/*[/url-pattern]
[http-method]GET[/http-method]
[http-method]PUT[/http-method]
[http-method]HEAD[/http-method]
[http-method]POST[/http-method]
[http-method]DELETE[/http-method]
[/web-resource-collection]
[auth-constraint]
[description][/description]
[role-name]authenticated_user[/role-name]
[/auth-constraint]
[user-data-constraint]
[transport-guarantee]NONE[/transport-guarantee]
[/user-data-constraint]
[/security-constraint]
[login-config]
[auth-method]FORM[/auth-method]
[form-login-config]
[form-login-page]/login.do[/form-login-page]
[form-error-page]/login_error.do[/form-error-page]
[/form-login-config]
[/login-config]
[security-role]
[description][/description]
[role-name]administrator[/role-name]
[/security-role]
[security-role]
[description][/description]
[role-name]authenticated_user[/role-name]
[/security-role]


The above login-config enabled the application to use a WebSphere extension called Form-based authentication. WAS Form-based authentication will be introduced in a later post.

In WAS administrative console, in Applications - Enterprise Applications - [Appl] - Security role to user/group mapping, there were two lines

Role | Everyone? | All authenticated? | Mapped users | Mapped groups
authenticated_users | unchecked | checked | null | null
administrator | unchecked | unchecked | null | ceadmin


WAS was defined to use File-based J2EE security. See a previous post about File-based J2EE security for details.

In the groups.props, add a line ceadmin:101:tester:CE Administrative Group, where the 101 was the group number.

In the users.props, add a line tester:password:101:101:CE Admin Tester, where the first 101 was the user number and the second group number.

With the above definitions, the application was able to make use of WAS security and can distinguish users by their authentication and role.

Friday, October 12, 2007

LDAP Browser in Eclipse

Actually I was installing LDAP browser plugin in my Rational Software Architect 7. I defined a remote update site using the URL http://directory.apache.org/studio/update/1.x and installed the LDAP Browser on my RSA.

That site was somehow a little bit weird. I tried the connection for several times before I was able to see the LDAP browser selection.

I used the "Connections" view to set up a new connection to LDAP server. After connected, I switched to the LDAP Browser view and saw three roots, DIT, Searches and Bookmarks.

The LDAP server which I connected was quite a big one. I easily got lost in the DIT tree. So I had to use the search. I learned something new here which was called the LDAP query.

For example, I needed to search any records that has a uid of ABC. What I needed to put in the "Filter" was (&(uid=ABC)). In my application, it had a query like (&(cn=my_group)(member=uid={0}, *)). It was very interesting, at least to me, since LDAP query was a new thing to me.

The searching speed was actually quite cool. Boom, the result was out. Since I would need to view that record from time to time. I saved it as a bookmark.

So far, the experience was good.

Friday, October 05, 2007

WAS 6.1/RSA 7.0 File-based Authentication

To enable file-based authentication,
  1. start up WAS 6.1 in RSA 7.0
  2. run administrative console
  3. security > secure administration, applications, and infrastructure
  4. check on "Enable administrative security"
  5. check on "Enable application security" (might be checked on automatically when check on "Enable administrative security")
  6. check off "Use Java 2 security to restrict ..." (if on, be ready to define web resource and beans and roles)
  7. select "Standalone custom registry" from the "Available realm definitions"
  8. click on "Set as current"
  9. click on "Configuration", the "Standalone custom registry" page will be shown
  10. click on "Custom properties"
  11. add two properties, usersFile ${USER_INSTALL_ROOT}/File-based_JACC/users.props, groupsFile $USER_INSTALL_ROOT}/File-based_JACC/groups.props
  12. in Windows explorer, go to folder \runtimes\base_v61\profiles\AppSrv01, e.g. C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01, and create a new folder "File-based_JACC"
  13. under the newly created folder, create two files, users.props and groups.props,
  14. in users.props, add entry "wsadmin:password:100:100:Administrator"
  15. in groups.props, add entry "admins:100:wsadmin:Administrative group"
  16. go back to "Standalone custom registry" page in the administrative console
  17. enter "wsadmin" into "Primary administrative user name"
  18. select "Automatically generated server identity"
  19. make sure the "Custom registry class name" is "com.ibm.websphere.security.FileRegistrySample" (shall be by default)
  20. click on "OK" and click on "Save" if asked
  21. click on "Apply" and click on "Save" if asked
  22. right click on the "WebSphere Application Server v6.1" in "Servers" view and select "Open"
  23. expand "Security" and check on "Security is enabled on this server"
  24. enter "wsadmin" in "User ID" and "password" in "Password"
  25. save changes made to the server
  26. restart the server, the server should be ready to use file-based authentication.

Wednesday, October 03, 2007

Ant with JUnit in WID 6.0.2

Since I had a junit task in my ant script, I added the junit.jar into ant::Runtime::Classpath::Global Entries. The interesting part was, WID warned me no tools.jar in the classpath and asked me if I wanted to ignore it.

I searched tools.jar under WID installation. None of them was exactly fit to me. So I decided to ignore it.

Run the ant script, it completed successfully. Question is, what does tools.jar do in ant classpath?

IBM WebSphere Integration Developer

Current version is 6.0.2. Updates will be made available through the Rational Product Updater. As I installed it on 10/2/2007, necessary updates were available and required to be installed.
  • WebSphere Integration Developer Fix Pack 6.0.2.2
  • WebSphere Integration Developer 6.0.2.2 Interim Fix 002
  • WebSphere Integration Developer 6.0.2.2 National Language Support Interim Fix
  • J2EE Connector Tools 6.0.1.5
Downloading these fixpacks failed three times since the operation timed out. Learned from IBM forum that the interim fix may cause error. Cross off the two interim fixes. Failed the fourth time.

If IBM WebSphere Process Server Test Environment is also installed, its updates are not provided through the Rational Product Updater, but may be obtained by visiting http://www.ibm.com/software/integration/wps/support/. Current updates are Fixpack 2 to 6.0.2, released on 7/31/2007.

Started using WID without updates. Since we use Harvest, I started with installing Harvest plugin. WID 6.0.2 uses Eclipse 3.0.2. Harvest plugin site is the same for Eclipse 3.2, 3.1, and 3.0. The site is http://supportconnectw.ca.com/public/harvesteclipse.

Carefully selected Eclipse 3.0, then plugin version 6.20.2. Check out a project from Harvest, no problem. Synchronize the workspace with Harvest, it suggested removing local files.

Harvest plugin was actually installed under rwd. Locate it and uninstall it. Do the plugin installation again, select 6.20.1 and then carefully select the destination to eclipse not rwd. This time the synchronization worked fine.

WID 6.0.2 uses Sun JDK 1.4.2 as default JRE. It has WAS 5.1 and 6.0, but not 6.1. It has the default perspective Business Integration, the only one cannot be found in Rational Software Architect 7.0.0.3.

Tuesday, October 02, 2007

JACC - Java Authorization Container Contract

The Java Authorization Container Contract (JACC) is a specification that was introduced in Java 2 Platform, Enterprise Edition (J2EE) 1.4 through the Java Specification Request (JSR) 115 process. This specification defines a contract between J2EE containers and authorization providers. This enables any third-party authorization providers to plug into any J2EE 1.4 Application Servers such as WebSphere to make authorization decisions when a J2EE resource is being accessed. The access decisions is made through the standard java.security.Policy object.

When an authenticated user makes a request to a web or a EJB resource, the security runtime makes the decision of whether to allow the access. This is called an access decision. Based on JACC, the appropriate permission object is created, the appropriate policy context handlers are registered, and the appropriate policy context identifier (contextID) is set. A call is made to the java.security.Policy object that is implemented by the provider to make the access decision.

In IBM WebSphere Application Server (WAS), when security is enabled, the default authorization is used unless a JACC provider is specified. The default authorization does not require special setup, and the default authorization engine makes all of the authorization decisions. However, if a JACC provider is configured and set up for WAS, all of the enterprise bean and web resource access decision will be delegated to the JACC provider.

Monday, October 01, 2007

WAS 6.1 Startup Error on SystemOut.log

My WAS 6.1 on RSA 7.0.0.3 has this error when starts up.
[10/1/07 9:48:28:785 EDT] 0000000a WrappingFileO E archiveCurrentFile TRAS0016E: An unexpected exception while trying to archive log file C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\logs\server1\SystemOut.log Exception is java.io.IOException: Unable to rename file C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\logs\server1\SystemOut.log to C:\Program Files\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\logs\server1\SystemOut_07.10.01_09.48.28.log. Logging continues.
It was said on IBM WID Forum that the fix for this issue will be available in 6.0.2.25 fixpack.

Friday, September 28, 2007

Log4JCategoryLog

Apache common logging 1.0 used Log4JCategoryLog. In version 1.1, replace it with Log4JLogger. The commons-logging.properties file will look like this,
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

web.xml version 2.4

In web.xml version 2.4, taglib shall be defined inside a jsp-config section.

Monday, September 17, 2007

升级FC6->FC7

折腾了好几个晚上,想把自己的一台老爷机从FC6升级到FC7,未果。
根本的原因是,FC7不认PATA的硬盘。就算用RESCUE碟都不行。
记住,自此一定不能升级内核。

Tuesday, September 11, 2007

Hibernate and Struts - Identifier Altered

In our application, we used Hibernate 3.1.2, Spring 1.2.6 and Struts 1.2.4. One of the page flows was to gather input from a form and insert a record into database then go back to the list page.

We saw messages like that,
org.hibernate.HibernateException: identifier of an instance of ... was altered ...
...
org.hibernate.event.def.DefaultFlushEventListener.onFlush...
...
In the beginning of investigation, we found the Hibernate related code did not flush after insert. We added the flush, but it didn't solve the problem.

Then we read Spring document and found HibernateTemplate recommended over Session. So we replaced Session with Template. But it didn't solve the problem.

Because because it had no problem going back to list after update, we tried to use saveOrUpdate and replace save. But it was the same.

Finally we noticed the Hibernate flush was scheduled after the page was forwarded, no matter what the setting of transaction.flush_before_completion was true or false. We also noticed the struts always recovered the form after forward. We tried to reset the data bean in the form right after insert. And this time, it solved the problem.

Thursday, September 06, 2007

Hibernate and MS SQL - Nullability Problem

The nullability problem happens when Hibernate 3 deletes an instance with any null value property defined not nullable.
org.springframework.orm.hibernate3.HibernateSystemException: not-null property references a null or transient value: com.ag.applications.forms.entity.qstnaire.QstnaireBean.qstnaireNam; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: com.ag.applications.forms.entity.qstnaire.QstnaireBean.qstnaireNam
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.ag.applications.forms.entity.qstnaire.QstnaireBean.qstnaireNam
To get rid of the error, edit the hbm.xml file and change the not-null="true" to "false".

However, it is necessary to define some properties not nullable. In this case, modify the application and let the property has non-null value or get the instance from database by primary key, then delete it.

This problem was reported to Hibernate on August, 2007. No known release fixes it.

Wednesday, September 05, 2007

Hibernate and MS SQL - Delete Operation

When does delete operation, application prompts message,
Data Access Error: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition.
This is because Spring 1.2 is incompatible with Hibernate 3. I heard Spring 2.0 solved this problem, but I found a workaround solution with Spring 1.2.

Here is the solution, in applicationContext.xml, set the property "checkWriteOperations" of "org.springframework.orm.hibernate3.HibernateTemplate" to false.

Tuesday, September 04, 2007

Hibernate and MS SQL - Unsupported prepareStatement

Insert operation generated by Hibernate didn't work with MS SQL. I was using Hibernate 3.1.2, WAS 6.1, JVM 1.5. And I was testing two JDBC drivers.

For IBM ConnectJDBC for MS SQL,
java.sql.SQLException: [IBM][SQLServer JDBC Driver]Unsupported method: Connection.prepareStatement
at com.ibm.websphere.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.ibm.websphere.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.ibm.websphere.jdbc.base.BaseConnection.prepareStatement(Unknown Source)
at com.ibm.websphere.jdbcx.base.BasePooledConnection.prepareStatement(Unknown Source)
at com.ibm.websphere.jdbcx.base.BaseConnectionWrapper.prepareStatement(Unknown Source)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.pmiPrepareStatement(WSJdbcConnection.java:3980)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:3854)
For DirectData ConnectJDBC for MS SQL,
java.sql.SQLException: [DataDirect][SQLServer JDBC Driver]Unsupported method: Connection.prepareStatement(String, String[])
at com.ddtek.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.ddtek.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.ddtek.jdbc.base.BaseConnection.prepareStatement(Unknown Source)
at com.ddtek.jdbcx.base.BasePooledConnection.prepareStatement(Unknown Source)
at com.ddtek.jdbcx.base.BaseConnectionWrapper.prepareStatement(Unknown Source)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.pmiPrepareStatement(WSJdbcConnection.java:3980)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:3854)
There is a saying that the Connection.prepareStatement(String sql, String[] columnNames) is not supported. Workaround solution is to set the "hibernate.jdbc.use_get_generated_keys" to false in the hibernate settings, either in the properties or in the cfg.xml.

Here is the definition of the property.
Enable use of JDBC3 PreparedStatement.getGeneratedKeys() to retrieve natively generated keys after insert. Requires JDBC3+ driver and JRE1.4+, set to false if your driver has problems with the Hibernate identifier generators. By default, tries to determine the driver capabilites using connection metadata.

eg. true|false

Here is the quote from mdiamonte in DataDirect forum.
Against SQL Server 2000, the driver can not implement this method correctly in the general case because SQL Server 2000 does not allow you to return the value of an arbitrary column from an insert, update or delete statement. At least not with out making an extra round trip to the server, which negates the purpose of this method.

I have seen implementations of this method by other drivers where the value returned will be the value of the identity column regardless of which column was actually asked for. I believe that implementation is bad. I feel it is much worse for a driver to return incorrect information than it is to not be able to return the information. Assuming the id column in the statement is an identity column, then Hibernate may have just gotten lucky that it worked in the testing that they did.